How to change features threshold of decision trees after applying one hot encoder?
Well, a threshold of 0.5 for a binary feature does make sense.
It just means that when the feature takes a value > 0.5 (which is thus 1) then the split is made to (say) the right, and of the feature takes a value < 0.5 (i.e. 0) the decision tree takes the other path (left).
There is no sense in changing the threshold value: any value between 0 and 1 has the same effect as 0.5 and values lower than 0 or larger than 1 mean that no split is done and all observations go to the same child node.
I had some strings in my dataframe (female x male, region and so on) and I wanted to fit a decision tree. Therefore, I applied one hot encoder in all these categorical features - which returned a bunch of new columns with 0 and 1.
However, the the default of features' threshold in decision tree are 0.5. That doesn't make sense for these categorical columns.
Does someone know how I can change the threshold for lots of columns at once (without having to input the name of each column) in python?
I want something like: column female split in 0 and 1. I want to do all these before calculating statistics (AUC, ROC, ACC, etc).
ps: I also have some numerical data (income, for example), so I can't change the threshold for all the columns
ps2: The categorical 1 and 0 are in columns 6 to 30.