# Inputs required for Random Forest Regressor and ways to improve performance

I am using Random Forest Regressor to predict inventory needs. The data I am using to train the model lists the total quantity picked for each product per date, but does not include rows where total quantity picked for a product on the specified date is 0. The model considers the features that allow it to take date into consideration. For details on the data being used see the example data below:

                 UPC  day_ID  month    day_of_year  day_of_week  quantity_picked
0      0000000002554  7500.0      5            141            1              4.0
1      0000000002554  7503.0      5            144            4              2.0
2      0000000002554  7512.0      6            153            6              2.0
3      0000000002554  7527.0      6            168            9              2.0
4      0000000003082  7494.0      5            135            2              2.0
5      0000000003082  7495.0      5            136            3              2.0
6      0000000003082  7496.0      5            137            4              8.0
7      0000000003082  7497.0      5            138            5              4.0
8      0000000003082  7498.0      5            139            6              4.0
9      0000000003082  7499.0      5            140            0              9.0
10     0000000003082  7500.0      5            141            1              3.0
11     0000000003082  7501.0      5            142            2              5.0
12     0000000003082  7502.0      5            143            3              3.0
13     0000000003082  7503.0      5            144            4              8.0
14     0000000003082  7505.0      5            146            6              2.0
15     0000000003082  7506.0      5            147            3              7.0


Will the model be less accurate at predicting inventory needs because it is missing dates for items where quantity picked is 0? I have tried running the same model with the rows where quantity picked = 0 but the total number of rows changes from approximately 50k to 5 million and my computer literally can't handle it, it just freezes. Without the rows where quantity picked = 0, the model reports mean squared log error level of .39448 and runs successfully within 4 minutes 37 seconds.

Any guidance on if that data is necessary or not would be very much appreciated and/or advice on how to improve performance/accuracy of such a model.

• Use as many 0-rows as your computer will deal with in a reasonable amount of time, but I'd probably start with 20-50k (to roughly match the number of other entries). In sklearn, the random forest's fit has an optional parameter sample_weight, an array-like of weights; probably easiest to define a Series based on the quantity_picked column of your dataframe, perhaps just a lambda, with weights 1 for positive-sold and 100 for none-sold (if you're taking about 1/100 of the original 0-rows). – Ben Reiniger Jul 10 '19 at 14:09