# how to decide categorical variables for prediction

I have a dataset that contains weekly sales for stores and categories. It looks like this:

I would like to apply gradient boosting method to predict weekly sales. My question is: Should I create dummy variables for categories(1 to 7 which indicates product type) and stores(1 to 11)?

• What are categories in here? – David Masip May 23 '18 at 13:41

Gradient boosting relies on decision trees. The leaves of your decision trees are built in a fashion to discriminate optimally your features. For numeric features, this means finding the best separation value to decline your dataset into two subsets. One contains observations with a value above or equal to this separation value, while the other presents values that are below this separation value.

It would not make any sense to have a leaf splitting your data on a criterion such as $Store >= 5$. However, it would make sense to have a separator such as $Store_5 = 1$ (vs $Store_5 = 0$). This is precisely why dummy variables are created for categorical values in ensemble methods, such as gradient boosting.

• Creating dummy variables is only one way of handling categorical data. Another option may be impact (mean) encoding. – bradS May 24 '18 at 11:21
• Also don't forget to add some features to your dataset as it will improve further and do check out the Yandex's CatBoost – Aditya May 24 '18 at 11:53