简体   繁体   中英

R Random Forest handling Posixct Values

I am using the randomForest package for a supervised learning. It is running fine, but I have a question regarding POSIXct values. Three of my 45 features are dates or dates with time. They are all considered important features according to the varImPlot. I tried to find out how randomForest uses POSIXct formats to make a prediction, but I couldnt find anything. Can anyone provide some insight?

Date-time is usually converted to numeric features (with start date as 1970-01-01). So what you are probably seeing is the effect of time index. A better approach would be to create separate features for day, month, year (in addition to time index) and then check for varImp

> as.numeric(as.Date("1970-01-03"))
[1] 2
> as.numeric(as.Date("2010-12-29"))
[1] 14972

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM