0
$\begingroup$

I am new to machine learning and i am building a model to predict number of customers for the model branch at specific hour/season/other feature.

I know it will be bad idea to pit id(branch_id in my case) into model but customer count in this case hugely depend on which branch it is so i cannot exclude it.

I can think of two solutions, i am not sure which one is right and what is the best practice.

  1. Create dummy variable(one hot encoding to avoid wieghing one id more than other) for all branch ids,but since i have 600 unique branch ids my features will go up-to 600+rest_of_features.
  2. Learn a separate model for each of the branch(600 models), i am not sure if it is right approach and also i am not very familiar with this approach and it will be very time consuming.

Looking for the suggestion

Example of the data is below

    +-----------+------+-----------+-----------+-------------------+
    | branch_id | hour | feature_2 | feature_3 | Count of customer |
    +-----------+------+-----------+-----------+-------------------+
    |         1 |   12 |        .. |        .. |                19 |
    |         1 |   01 |        .. |        .. |                25 |
    |         2 |   23 |        .. |        .. |                14 |
    |         2 |   01 |        .. |        .. |                 5 |
    +-----------+------+-----------+-----------+-------------------+
$\endgroup$
0
$\begingroup$

In my opinion including id as a feature will not make sense at all, because the model will treat the id as a numeric value which will decrease the model performance, because there should be no connection how big the id is and how many customers there are for that id.

Option 2 can make sense if you have enough data for every branch.

My suggestion will be to look deep into your features and try to find a feature which will replace the branch id. Let's say the number of supporting desks in a branch or the location of a branch as a categorical value. If you find enough features that can describe the specifics of branches, then no need to include ids or to do it separately.

| improve this answer | |
$\endgroup$
  • $\begingroup$ thanks for answering, what about "Create dummy variable(one hot encoding) for all branch ids,but since i have 600 unique branch ids my features will go up-to 600+rest_of_features." ? $\endgroup$ – mashraf Mar 16 '19 at 18:29
  • $\begingroup$ Regarding 600 dummy variables: it can practically work with some regressors if you have large enough number of observations. Probably except from decision tree regressors. The typical rule of thumb for the multiple linear regression is usually that the number of observations should be at least 5 times more than the number of variables, otherwise you will have completely insignificant estimates. For your case, I think if you have quite large dataset, then you can try it out, also try different ML algorithms to see which one goes well. $\endgroup$ – Karen Danielyan Mar 17 '19 at 19:32
0
$\begingroup$

branch_id in this case is a categorical variable, and you can treat is just like you would other categoricals (like city: "Seattle", "San Diego", "Austin"). You just need to be sure you use an algorithm that can treat it as categorical. LightGBM uses a method that sorts and optimally splits the histogram of the categorical integers, which is faster than OHE. CatBoost can leverage a few different methods.

In addition to regression, you can similarly convert the customer counts into ranges or histogram bins and use a classification algorithm to predict the bin.

| improve this answer | |
$\endgroup$

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.