I had no idea how to explain this in the title but anyway... Let's say I have a data points like this:

John, Happy | Greedy | Smart | Funny, 0.8
Ann, Smart | Sad | Funny, 0.6
Joel, Greedy | Prideful | Stupid, 0.2

Where the first part is the name the second is there characteristics and the third is their overall character score (how nice they are to be around or something). Is there a good way to work with this data so that I can work out what the best possible combinations are? Assume I have a large enough data set. There may be say 30 of those characteristics and any person can have any number of them and every characteristic is equally valid to every person.

Hopefully that explains it. Essentially I am want a way to organise the traits so that I can say "smart and happy" make a better combination than "sad and greedy". I also need to be able to asses the ultimate combination and be able to compare any two possible combinations.


It's a regression machine learning problem. Assuming you have 30 characteristics, one-hot encoded into 30 columns. And your target is the character score, min-max scaled into $[0, 1]$.

So we have X.shape=(None, 30), Y.shape=(None,) (just like what ncasas has stated), thus we can train a regression model using your favorite algorithm (linear regression, random forest, even neural network).

After we have this model working, as each person has and only has 3 characters, we can predict the character score for each character combination one by one. The time complexity is roughly $O(n^3)$. However, $n$ is small in your case, so maybe we can just brute-force every score on every combination. That's what you want.


The typical way to address this is to transform those characteristics into a representation where you compose a vector with one component for each possible characteristic, with a $1$ in the position of each characteristic owned by the individual, or zero otherwise.

This way, you would have:

name | greedy | smart | funny | sad | prideful | stupid | ... | score
John |   1    |   1   |   0   |  0  |    0     |   0    | ... | 0.8
Ann  |   0    |   1   |   1   |  1  |    0     |   0    | ... | 0.6
Joel |   1    |   0   |   0   |  0  |    1     |   1    | ... | 0.2

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.