# Can we use DecisionTreeClassifier of sklearn for continuous target variable?

I have a continuous target variable named "quality" which ranges from 0 to 10. Also I have 11 input variables in my dataset.

When I'm building my model using DecisionTreeClassifier() of sklearn then I'm getting a score of 60% but when I'm building my model using DecisionTreeRegressor() of sklearn then I'm getting accuracy of 3% only and also RMSE as 85%.

Also, when using Linear Regression my R-squared value is 0.376. Is it good?

Am I doing something wrong?

I need help. Thank you.

In the Wine Dataset you linked, the quality column is not a continues variable but a discrete. It takes integer value between 0 and 10.

When you use the DecisionTreeClassifier, you make the assumption that your target variable is a multi-class one with the values 0,1,2,3,4,5,6,7,8,9,10. So, the model tries to predict one of these and only these values.

When you use the DecisionTreeRegressor, the assumption is that any number between 0 and 10 is acceptable. Like the number 4.52356. As a result, the accuracy will be noticeable worst. If you still want to use the Regressor for some reason, you can try to round the outcome and then calculate the accuracy. Keep in mind that RMSA doesn't fit your problem. You have a multi-class and not a regression model.

• Now things are much clear. Thank you. I have 1 more doubt. Should I concat both the datasets(red &white wine) and build a single model or build seperate models for each of red and white wine? Which one will be better? – user9544852 Jul 15 at 12:21
• Also, can we remove some columns (input variables) which have a neutral correlation with target variable. Also, there are some outliers for some input variables. Can I remove them too? I'm asking this because someone told me that we cannot remove any columns or remove outliers in DecisionTree. – user9544852 Jul 15 at 12:27
• @user9544852 These should probably be separate questions (though do a search to see if they're already answered). – Ben Reiniger Jul 16 at 1:44
• @user9544852 as Ben Reiniger said, this is a whole new question. In short, outliers can be removed. However, you need to dig more and see if those outliers are wrong inputs (like typos) or have some meaning for your data. As for removing columns, you can do it before you train your model. After that, you need to keep the same features space for predictions – Tasos Jul 16 at 8:21
• Ok. Thank you so much. – user9544852 Jul 16 at 12:27

All algorithms support both Classification and Regression(continuous target variable). The interesting part is about what data we are going to train the model and how they perform on test data. we'll consider the best out come of the data.