1
$\begingroup$

I want to predict the income for small business from 1/1/2018 to 1/1/2020 for a dataset from historical data(all my variables are numeric except for date) the start date of my data is 1/1/2012. The income is updated each 3 months (so on 1/1/2018 I have x income and on 30/3/2015 I have new income) I'm not sure how to handle the date in this situation.

I did the following:

1- read the data

2- analysis the data

3- convert date column to type date 4- sort date

5- split the data (training data from 1/1/2012 to30/12/2017 and test data from 1/1/2018 to 1/1/2020)

6- convert date back to numeric

7- normalize all my columns except for the date columns

8- perform RF

9- predict using test dataset

In this scenario I didn't change the date format but I feel like this might not be the best way to handle date format.

$\endgroup$

1 Answer 1

2
$\begingroup$

Random Forest needs to handle dates as numeric data, that's why you can use the day, the weekday, the month, the trimester and the year as separated fields.

In addition to that, if your data has a cyclic behavior, you can align your data to it.

For instance, if your data has a cycle of 3 months, you can have the following features: day of the trimester (from 1 to 90), weekday, trimester and year. This would help to find interesting patterns.

Note: after the random forest processing, you may want to convert the day of the trimester to yyyy-mm-dd for a better clarity.

$\endgroup$
2
  • $\begingroup$ So this mean that in step 6 I'll have to add more features and convert the date to day, month and year right. Then after applying my model I can plot or compare the results based on yearly or monthly correct? Can you refer me to a paper with similar task $\endgroup$
    – nullUser
    Commented Jun 14, 2022 at 13:40
  • 1
    $\begingroup$ That means that instead of a single date yyyy-mm-dd, you should have separated values: year (2012 to 2020), trimester (1 to 4), day of the trimester (1 to 90), and week day (1 to 7). You can even normalize them. $\endgroup$ Commented Jun 14, 2022 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.