# Random Forest Classifier Output [closed]

Used a RandomForestClassifier for my prediciton model. But the output printed is either 0 or in decimals. What do I need to do for my model to show me 0 and 1's instead of decimals?

Note: used feature importance and removed the least important columns,still the accuracy is the same and the output hasn't changed much.

Also, i have my estimators equal to 1000. do i increase or decrease this?

edit:

target col
1
0
0
1

output col
0.994
0
0.355
0.768


thanks for reading this, if you did!

• Welcome to DataScienceSE. Please provide details, in particular code or example (what do you mean by 'decimal output'?), details about the data/task like size. number of classes, distribution,.. Jun 4 at 15:22
• @Erwan edited the question. does this help? Jun 4 at 16:42
• – Rob
Jun 15 at 8:39

Take the numbers given by the model and threshold them. Everything above X (usually .5) is mapped to 0, everything greater than X is mapped to 1.

• okay, thanks for this! Jun 4 at 16:27
• after thresholding, for some reason even the id column changes to the model output. any idea on how to stop this? Jun 4 at 17:50

On what data are you training on? Is your training data binary?

If not, then set a treshold when your target variable should be 1 and 0 otherwise. Then train your RandomForestClassifier on the binary labels. Could be that you are training your classifier on a continuous target variable and thats why your performance is so bad.

The generalization error for forests converges a.s. to a limit as the number of trees in the forest becomes large (Breiman, 2001)

More trees = better. However, it's also computationally more expensive. There is a trade-off. Start low ~64 trees and then work your way up, if the generalization error is still high

• yup, the training data is binary. Jun 4 at 16:27
• please provide some code Jun 4 at 18:39