# Why is a random forest regressor better than a random forest classifier when predicting a category?

I am building a model that recommends the optimal golf club based on data I have gathered. Since the model prediction should be a category, ie. a golf club, I would assume I would have to use a classifier algorithm. However, I have label encoded the types of golf clubs in an ordinal way from 1-14 (1 being the club with longer distance shots and 14 being the one for shortest shots) and have run both random forest regressor and classifier with scikit-learn and the regressor is more accurate. Why is this?

• First, it sounds more like a regression problem. Second, how do you judge “better”?
– Tim
Commented May 6, 2022 at 20:38
• The accuracy score of both differ by 4%. So it is not a big difference. However, looking at how to create a ml algorithm, it says that if the predicted output is a category a classification algorithm should be used. Hence I tried SVM, KNN, Random forest classification, decision tree classifier and NaivesBayes (all classification algorithm) however none give a better accuracy score that the random forest regressor. Commented May 6, 2022 at 20:46
• How did you calculate accuracy for regression?
– Tim
Commented May 6, 2022 at 21:20
• By using the method .score(X_test, y_test) Commented May 6, 2022 at 21:32

RandomForestRegressor and RandomForestClassifier return completely different metrics when you call the score functions. Regressor returns coefficient of determination ($$R^2$$), while for classifier the accuracy. You cannot compare those numbers, it's comparing apples to oranges. There is also no way to calculate accuracy for a regression problem because it doesn't do classification while accuracy is a classification metric (a poor one, by the way).