1
$\begingroup$

Let's say this: I'm working on a machine learning project and I'm working on a dataset with a 4250,13 as shape and it is already grouped in 7 categories! Note that those categories can't be considered as predictor. Here is how my data is grouped in the categories feature 'FAC':

FSEG       32.852598 % of the dataset
FSTA       19.151644 % of the dataset
FD       19.003181 % of the dataset
FM      16.076352 % of the dataset
FT      5.132556 % of the dataset
PPSE       4.814422 % of the dataset
FSDC    2.969247 % of the dataset

I have a continuous output that I want to predict 'CGPA', so the task is a regression, my goal is to predict it in each category, and the final decision will be the category where the predicted output is maximized.

My approach to deal with this problem is to sample my dataset into 7 sub-datasets and train the model in all those 7 datasets. And for a new input, predict the output in each category, and the final category will be where the predicted output is maximal.

Now I want to know, is there any way to do it in one dataset and automatically predict the category where my output is max? With a single model instead of 7?

PS: I'm using python and scikit learn

Sound like random-forest but not sure that is it ... can someone help? Any help will be appreciated.

Here is my dataset with samples collected in each category. My final output is called CGPA and the category label is 'FAC'.

the sample dataset

$\endgroup$
  • $\begingroup$ You say you want to predict a continuous output for 7 categories and then choose the category with maximum output. Is your final output the category label? Do you care what the predicted output was for this or any of the other categories, or do you discard that data? $\endgroup$ – Imran Jul 24 '17 at 7:00
  • $\begingroup$ I need to have different the value of the continuous output in the 7 categories and then decide the category where the output is max.. i can say that my goal is to have 7 continuous output and finally choose a category according to that final output $\endgroup$ – Espoir Murhabazi Jul 24 '17 at 7:08
  • $\begingroup$ So if I just told you what the category with the highest output is, without telling you the predicted output, that would not work? $\endgroup$ – Imran Jul 24 '17 at 7:11
  • $\begingroup$ it can works and but I need to know the value of the output in each category , i can give the category to the user and sometime the final decision can be made by him, he can choose a category where the output is not max... but the ideal is to choose the category where the output is maximazed $\endgroup$ – Espoir Murhabazi Jul 24 '17 at 7:22
  • $\begingroup$ When you say your data is grouped into categories, do you mean that each row only gives the output for one category? Can you show us a few rows of your data? $\endgroup$ – Imran Jul 24 '17 at 8:25
2
$\begingroup$

A random forest will work, however standard regression will also work with categorical variables as predictors. You will have to "one-hot" encode your categorical predictors into 6 "dummy" variables (classes-1 = 7-1 = 6). The first dummy variable will encode 0/1 for whether or not the observation is class A, second dummy variable as 0/1 for class B, etc. You only need 6 dummy variables because if all of them are 0 for a given observation, that means the observation is in group 7 (G).

In some languages, such as R, the regression command will automatically do this one-hot conversion for you. For python, the pandas package can do this for you with pd.get_dummies(data).

$\endgroup$
  • $\begingroup$ The problem is not the the fact that i want to predict a continuous variable with categorical predictor, my problem is the fact that I want to predict a continuos output in each of those 7 categories and get the category which maximize my continuos outputs $\endgroup$ – Espoir Murhabazi Jul 24 '17 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.