8

I've seen some machine learning questions on here so I figured I would post a related question: Suppose I have a randomly generated food list which includes an entree, dessert, and a drink. An example would be Chicken, cheesecake, orange juice. The user would rank how they personally like this combination from a scale of 1-5. After reach rating, another random set of food would appear.

My question is, what machine learning technique/algorithm would I use to predict what the user would rank a randomly generated set from all their previous data? In essence, use their opinion to predict their rating of new food sets. Any sites/books that may help?

ono
  • 2,984
  • 9
  • 43
  • 85

7 Answers7

3

You have stated a regression problem because you are trying to predict a continuous numerical value.

For each data instance, you can extract features and associate a value (1-5). The features can be the existence of a dish during the meal (e.g. has_cheesecake, has_orange_juice), where each feature is a boolean. Suppose there are N possible dishes; then each meal is a data instance (also known as a feature vector) with N features and an associated value. Below is an example with N=12, where the last (13th) column is the value.

0 0 0 1 1 0 0 0 1 0 0 0 5
1 0 0 1 0 1 0 0 0 0 0 0 3
0 0 0 0 0 0 1 1 0 0 0 1 4

You can then feed this into a machine learning program like Weka, and it will create a regression model for you. Then when you want to predict the user's ranking for a new meal, you feed in a new vector where the last column is unknown, like the following:

0 0 1 0 0 0 1 0 0 0 0 1 ?

The software will return a value to you, like 3.9.

stackoverflowuser2010
  • 38,621
  • 48
  • 169
  • 217
  • Question about the sample data: So the 12 boolean values are all the features that may show up, say 4 entrees, 4 desserts, and 4 drinks? Is that why you have 12? You are denoting which ones are present when rating the sentence with a 1. – ono Nov 20 '12 at 15:23
  • Correction: The boolean value of 1, not when you rate it. – ono Nov 20 '12 at 15:53
  • Also, how do you preform this in Weka? Is there a tutorial? – ono Nov 20 '12 at 16:47
  • Yes, 12 boolean values for 12 possible food items. A '1' indicates the presence of a particular food item during the meal. – stackoverflowuser2010 Nov 20 '12 at 18:09
  • Weka's documentation that comes with the software is more of a reference, so you will want to google "Weka tutorial site:.edu" to find some good tutorials. The "Data Mining: Practical Machine Learning Tools and Techniques" book by the Weka implementers is excellent. In the software, you will want to use the GUI Explorer first, so read the section on the Explorer. The most important part is getting data into Weka; you can use CSV or their own ARFF format. – stackoverflowuser2010 Nov 20 '12 at 18:15
  • 1
    This is going to be a fairly weak model as described---there are no correlation-like features (depending on your regression model, the method may include these), and nothing except the identity of the dish is being used. I'd want to look for commonalities between dishes as features, and I think most interestingly features which express how well a set of dishes constitute a satisfying meal. This is the kind of thing sentiment detection has considered. – Ben Allison Nov 21 '12 at 11:02
  • 1
    Some example features: prices, calorific content, presence of 5 main "tastes" (sweet, salty, sour, bitter, umami), ratio of calories in starter to main, ratio of calories in main to desert, number of shared core ingredients, etc etc. Features like this will allow you to make inferences about dishes you've never before seen, judge the meal as more (or less!) than the sum of its parts, and move beyond simple identity features. – Ben Allison Nov 21 '12 at 11:08
  • @BenAllison: You have a good point. My original assumption is that if the dishes will never change and if no new dishes come up, then taking features as the current dish identifiers would be ok. However, if new dishes are expected, then features about the characteristics of the dishes would be better (e.g. type of vegetables, sweetness, calories, etc.) to gain more predictive power. – stackoverflowuser2010 Nov 22 '12 at 00:32
2

What you're asking is basically sentiment detection, which has become very popular for doing things like predicting a user's attitude towards a product. Here's a seminal paper, depending on how academically inclined you are.

You could look at this as a regression problem, but a lot of the time people ignore the fact that there are ordinal relations between the classes. If you have no more information on the items in the meal than their names, I'm not sure I'd expect you to do very well at it. You should look for a feature-representation of the courses if at all possible, to improve your ability to predict values.

Ben Allison
  • 7,244
  • 1
  • 15
  • 24
  • Sentiment detection seems right on. Not sure why I haven't found it before. That paper looks useful. I just read the abstract. Thanks. – ono Nov 20 '12 at 15:30
  • Sentiment recognition is just an application of machine learning classification; in the end, the core problem is extracting relevant features. Regarding ordinal relationships, you can take the approach of n-grams in computation linguistics where you extract features that contain n subsequences. Your feature can be something like "cake_wine" indicating that the user had cake and then wine. But in a restaurant scenario with a known ordering like appetizer then entree then dessert, the ordering may already be known. – stackoverflowuser2010 Nov 20 '12 at 18:08
  • By ordinal relations between the classes, I mean that the classes have an order to them, i.e. 1 < 2 < 3 < 4 < 5, so regression models fit most naturally. You can more naively treat 1, 2, 3, 4, 5 as separate, independent classes (ignore the fact that their labels are numeric), which is what a lot of sentiment detection methods have done. – Ben Allison Nov 21 '12 at 11:05
1

I would look into operation research because usually it's a minimize or maximize problem.

Micromega
  • 12,486
  • 7
  • 35
  • 72
1

As you have a classification column which is the priority column, you can try for decision tree.

Ahmed Tanvir
  • 187
  • 7
1

To pick the best classifier, there are several additional characteristics of your problem you should estimate, such as the approximate number of attribute values (i.e., how many entrees, desserts, and drinks are there from which to choose) and approximately how many training examples would you want to provide prior to making predictions. Not all classifiers are good at dealing with sparse data.

If you have a large number of training examples (relative to the number of attribute values), a decision tree classifier is a good place to start. One of the benefits of a decision tree is that the structure of the learned tree is intuitive and provides a simple interpretation of what are the important attributes (and combinations of attributes).

bogatron
  • 18,639
  • 6
  • 53
  • 47
  • I have 7 features and around 5 attributes for each. I was using the dinner as a example of what I'm trying to do. My original thought was the decision tree. I will look into it more. – ono Nov 20 '12 at 15:25
  • Also, usually when a decision tree is constructed it measures a boolean result; for example whether an event will occur or not based on several features. In my case, the result is 1 through 5. Would the same principles apply when constructing it? – ono Nov 20 '12 at 15:42
  • Decision tree classifiers are applicable to arbitrary numbers of classes (i.e., not just binary classification). You can also build regression trees, which have real-valued outputs (something you may also want to consider for your application if you don't want to limit yourself to integer-valued outputs). – bogatron Nov 20 '12 at 18:00
1

There are many algorithms that can fit in your problem, some of them can be decision trees, neural nets or support vector machines.

However, when you are working with user opinions, maybe in some cases you don't get the user opinion in all your products (they can skip). I don't know if this is your case, maybe you force them to rank all the products. However, if you give the user the option to skip, you will end up with some of your products that haven't been labelled. In that situation you could use collaborative filtering. This method predicts the estimated selection of a new user even in the situation I explained.

You can find a good tutorial in Ng's course.

hoaphumanoid
  • 977
  • 1
  • 9
  • 25
0

If you would like to create a model from the similarities of the users(same user same food) then create a model with collaborative filtering. (Vectors For every user ) Libraries such as keras, scikit learn and pandas are very useful and easy. If you would like to write your own model then Matrix factorization may be helpful.

boozy
  • 315
  • 1
  • 8