robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.13k stars 342 forks source link

Unable to terminate the auto.arima process on timeout #536

Open pranavbahl2308 opened 7 years ago

pranavbahl2308 commented 7 years ago

I am trying to timeout the auto.arima algorithm if it exceeds certain time limit but it keeps on running until it finishes. Is there any way I can timeout the auto.arima. Following is the code snippet I am executing ` require(R.utils) library(forecast) freq <- 52 forecast_freq <- 13

start.time <- Sys.time()
tryCatch(
    {
        res <- evalWithTimeout({
        profileddf <- ts(data,frequency = freq)
        arima_fit_prof<-auto.arima(profileddf)
        forecastoutput_prof_arima <-forecast(arima_fit_prof,h=forecast_freq,level=c(95))
        forecast_df <- c()
        forecast_df <- cbind.data.frame(forecastoutput_prof_arima$mean[1:13],forecastoutput_prof_arima$lower,
                                        forecastoutput_prof_arima$upper,account_id)
        colnames(forecast_df) <- c("back_Forecast","back_lower_95_pi","back_upper_95_pi","account_id")

        end.time <- Sys.time()

        sink()

        return(list(forecast_df,as.numeric(end.time-start.time,units="secs"),"success"))
        }, timeout=30);
        return(res)
    },
    error = function(err) {
        return(list("",as.numeric(Sys.time()-start.time,units="secs"),str(err)))
    }
)

`

robjhyndman commented 7 years ago

I've no idea. Perhaps ask on stackoverflow.com. If you find an answer, please share it here. It may require some changes to auto.arima