Most datasets I see are:

feature 1, feature 2, feature 3, outcome

Where outcome is binary e.g. if they are cancer positive outcome will be 1 and 0 if they don't have cancer.

How do I create a dataset where there are multiple outcomes and each possible outcome has a set of features for it?

e.g. I have a question with 3 possible answers:

"What organ pumps blood around the human body?"
A. Heart
B. Liver
C. Church Organ

And each answer has a set of features with one answer being correct. How would I display this in a csv file? I want to read it into an xgboost algorithm for training.

question, option1 and features, option2 and features, option3 and features, correct option

Many thanks for your help!


The final feature vector would be a concatenation like (for multi-class prediction):

Question google count | option A google count | option B google count | option C google count | option C no. words | option A no. words | other features | label (1, 2, 3)

There is no need to put features related to option A close to each other (or in any particular order), they just need to be on the same column for all rows regardless of the label.

XGBoost parameters for multi-class classification are:

'objective': 'multi:softprob',
'num_class': 3
  • $\begingroup$ Ok, I understand what you're saying, thank you, but let's say one of my additional features is the number of pages returned in a google search when googling the question and answer: e.g. 1,000,000 for option a and question, 200,000 for option b and 0 for option c. How would I add these features to the dataset? Do I just add 3 more rows? optionaresults, optionbresults, optioncresults Because what I don't understand is will the results be attributed to the correct option in the model? If this makes sense? $\endgroup$ – OultimoCoder Mar 24 '19 at 13:35
  • 1
    $\begingroup$ @OultimoCoder updated the example $\endgroup$ – Esmailian Mar 24 '19 at 13:40
  • 1
    $\begingroup$ @Emailian Ahhhh thank you, where I was going wrong was I was assuming the features for each label had to be explicit. I didn't fully understand it. Your edits helped explain it better. I'll wait a day before choosing your answer as the correct one. $\endgroup$ – OultimoCoder Mar 24 '19 at 13:55

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.