3
$\begingroup$

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

enter image description here

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)?

$\endgroup$
  • $\begingroup$ What are categories in here? $\endgroup$ – David Masip May 23 '18 at 13:41
1
$\begingroup$

Short answer : yes.

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.

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

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.