I have a question regarding how to setup a dataset for modeling.

Let’s say I have a dataset representing which car a person will buy depending on some characteristics:

The dependent variables are individual cars (Car 1, Car 2, … Car 100).

The independent variables are:

Budget (of the buyer)

Favorite Color (of buyer)



Color (of Car 1)

Color (of Car 2)


Color (of Car 100)

MPG (of Car 1)

MPG (of Car 2)


MPG (of Car 100)

Let’s assume this is a multi-class classification problem. So, only one of the cars can be chosen in each situation.

My question is: is it appropriate to have independent variables like that - that are specific to each of the dependent variables? (Color of Car X, MPG of Car X, …). Is it appropriate to just fit a row like that into a model? How does the model know to understand that each of the Colors are discussing the same feature? Color

Lastly, is there a name for this type of data/problem? I'm not sure how to look for it on Google.

  • $\begingroup$ I think you need to clarify what you are trying to predict. Are you trying to predict buy or not buy? Then your target variable is simply a binary representation either being 0 or 1. Then your features can include car color and MPG. $\endgroup$ – Wes Feb 13 '19 at 19:56
  • $\begingroup$ Sorry, yes it would be to buy or not to buy for only 1 of the 100 possible cars. So, only one of the 100 possible cars would have a value of 1 whereas the others are all 0s. So, my features would then be able to include the color and MPG for each of the 100 cars? I don't need to modify the data in any special way? $\endgroup$ – dooder Feb 13 '19 at 20:06
  • $\begingroup$ I think it's still a little conflated. You could have all of your car features as part of your feature vector as well as your buyer features. Then you would only have one target variable - did they buy the car with those features or not? But it depends on the goal of your predictions. Alternatively, if you couch it as a multiclass problem (100 cars that could be predicted), and you include features of the car in your feature vector, how useful will it be for your use case? I think that becomes a question you have to think about. $\endgroup$ – Wes Feb 13 '19 at 21:28

Color is a categorical feature.

One of the most common methods to encode categorical features is one-hot encoding. Color could be encoded as an indicator vector. The color of the current car would have a 1 at the appropriate index. For example, [1, 0, 0, …, 0] for a red car and [0, 1, 0, …, 0] for a blue car.

There are other options for encoding categorical features such as binary, count, hash, or label encoding.


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.