[Solved] Predicting the future events using machine learning [closed]


First, you must to define exactly your time-space. If you want a daily model you must to use “date” as your variable time. For this case, I think waht you need is a time series forecasting model.

Linear Regression is an option but there are more sofisticated and useful models for this case. I leave you some of them.

The next step is choose the best model, so you must to take the model with the minimum MSE for example (there are other measures). I give you a “loop” for this toop.

if (!require("forecast")){install.packages("forecast"); library(forecast)} 

train<-ts(your_data_train,frequency=24)
test<-ts(your_data_test,frequency=24)


fit1<-tslm(train ~ trend + season) #linear regression
fcast1 <- forecast(fit1,h=npred ,level = 0)

fit2<-ets(train,ic="aic") #exponencial smoothing without Box-Cox
fcast2 <- forecast(fit2,h=npred ,level = 0)

fit3<-HoltWinters(train) #Clasic Holtwinter (similar to exponencial smoothing)
fcast3 <-forecast(fit3,h=npred ,level = 0)

fit4<-HoltWinters(train,seasonal = "mult") #Holtwinter mult
fcast4 <-forecast(fit4,h=npred ,level = 0)

fit5 <- tbats(train) #Model TBATS
fcast5 <- forecast(fit5, h=npred ,level = 0)

lam <- BoxCox.lambda(train)
fit6 <- ets(train, additive=TRUE, lambda=lam) #Model exponencial smoothing with de Box.Cox
fcast6 <-forecast(fit6,h=npred,level = 0)

pred<-c(fcast1$mean,fcast2$mean,fcast3$mean,fcast4$mean,fcast5$mean,fcast6$mean)

error<-0
for(i in 1:length(pred)){
  error[i]<-mean((pred[i]-test)^2)
}

2

solved Predicting the future events using machine learning [closed]