I have a data set from which I need to train a model and use it for prediction. Let's say I want to predict what people say about food items produced by a cake shop. Let's assume people have stated the taste of the food items as good, average and bad in different years, by different methods. So the columns will be:

  • Food item
  • No. of people saying Good
  • Year it was said Good
  • Method of stating Good (By tasting or by rumours)
  • No. of people saying Bad
  • Year it was said Bad
  • Method of stating Bad (By tasting or by rumours)
  • No. of people saying OK
  • Year it was said OK
  • Method of stating OK (By tasting or by rumours)

In this case, there will be food items which people have stated as Good but no mention whether it is Bad or Ok. In such cases, the respective columns will have to be kept empty. For "the no. of people ...." columns, zero can be added but not for "year ..." column and "method...." column.

If I use Logistic Regression to train this data set, will it be valid since there will be no.of empty cells in the training data set? Or else, if Logistic Regression is not good in this scenario, what supervised machine learning method can be used?

  • 1
    $\begingroup$ You should definitely be considering ordinal/ordered logistic regression with the response levels Good > Average > Bad. You will also probably want to recenter your year column for ease of interpretation. Zero cells aren't the end of the world for logistic regression. Edit: just to be clear, you need to change columns to: Reponse (good/average/bad), Number giving response, other factors (year, method, ...). $\endgroup$ – tristan Oct 11 '15 at 11:09
  • $\begingroup$ If the column Response is used, how will I enter data in a scenario where one food item was stated as Good in 2014, but it was also stated as Bad in year 2013? $\endgroup$ – Dakshila Kamalsooriya Oct 11 '15 at 11:22
  • $\begingroup$ Use separate rows. Do the same even if it's the same year. $\endgroup$ – tristan Oct 11 '15 at 11:24
  • $\begingroup$ I'm not taking the 'Food item' column to train the model. If so, is it possible to add several columns for the same food item? The example I have given regarding food items is not my scenario. But my scenario is very similar to what I have given in the example. (Same kind of columns). If I'm not taking the 'food item' column to train the model, is it still possible to go for separate columns? I f not, what is the best thing to do? $\endgroup$ – Dakshila Kamalsooriya Oct 11 '15 at 11:48
  • $\begingroup$ I'm having some difficulty understanding your problem... What is your dependent variable in this case, I.e. What are you trying to predict? $\endgroup$ – tristan Oct 11 '15 at 12:05

If I understand correctly what you are aiming for, you might want to rearrange your data a little. You have for each year set of explaining variables in your example:

  1. Number of people who said it was good based on rumours
  2. Number of people who said it was ok based on rumours
  3. Number of people who said it was bad based on rumours

And the same for those where it was based on tasting. Which makes six columns for each year and if there were none saying something the value is zero. So you would have six times the years as input in this case and what you are predicting is 1,0 for profit/no-profit.

What it means is that "year" as such is not a predictor, but "number of people who did A in year X" is.

  • $\begingroup$ This looks right to me. Obviously make sure the regression makes sense, so don't include ratings which come after the sales period. Also, make sure it makes sense to group by year - is this how reviews are presented? And one would expect more recent reviews to have a stronger effect on sales. $\endgroup$ – tristan Oct 18 '15 at 8:17

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.