/** * @param numForecastSteps * amount of to calculate FC steps * @return ForecastResult */ @Override public final IForecastResult forecast(final int numForecastSteps) { final ITimeSeries<Double> history = this.getTsOriginal(); IForecastResult forecast = null; if (this.satisfiesInputTSRequirements(history)) { try { forecast = this.forecastWithR(numForecastSteps); } catch (final InvalidREvaluationResultException exception) { LOGGER.warn("Exception occured when forecast with R", exception); } } if (forecast == null) { LOGGER.warn("Null result for forecast. Falling back to Double.NaN result."); forecast = this.createNaNForecast(history, numForecastSteps); } return forecast; }
protected IForecastResult createNaNForecast(final ITimeSeries<Double> timeseries, final int numForecastSteps) { final ITimeSeries<Double> tsForecast = this.prepareForecastTS(); final ITimeSeries<Double> tsLower = this.prepareForecastTS(); final ITimeSeries<Double> tsUpper = this.prepareForecastTS(); final Double fcQuality = Double.NaN; final Double[] nanArray = new Double[numForecastSteps]; Arrays.fill(nanArray, Double.NaN); tsForecast.appendAll(nanArray); tsLower.appendAll(nanArray); tsUpper.appendAll(nanArray); return new ForecastResult(tsForecast, this.getTsOriginal(), this.getConfidenceLevel(), fcQuality, tsLower, tsUpper, this.strategy); }
protected IForecastResult createNaNForecast(final ITimeSeries<Double> timeseries, final int numForecastSteps) { final ITimeSeries<Double> tsForecast = this.prepareForecastTS(); final ITimeSeries<Double> tsLower = this.prepareForecastTS(); final ITimeSeries<Double> tsUpper = this.prepareForecastTS(); final Double fcQuality = Double.NaN; final Double[] nanArray = new Double[numForecastSteps]; Arrays.fill(nanArray, Double.NaN); tsForecast.appendAll(nanArray); tsLower.appendAll(nanArray); tsUpper.appendAll(nanArray); return new ForecastResult(tsForecast, this.getTsOriginal(), this.getConfidenceLevel(), fcQuality, tsLower, tsUpper, this.strategy); }
/** * @param numForecastSteps * amount of to calculate FC steps * @return ForecastResult */ @Override public final IForecastResult forecast(final int numForecastSteps) { final ITimeSeries<Double> history = this.getTsOriginal(); IForecastResult forecast = null; if (this.satisfiesInputTSRequirements(history)) { try { forecast = this.forecastWithR(numForecastSteps); } catch (final InvalidREvaluationResultException exception) { LOG.warn("Exception occured when forecast with R", exception); } } if (forecast == null) { LOG.warn("Null result for forecast. Falling back to Double.NaN result."); forecast = this.createNaNForecast(history, numForecastSteps); } return forecast; }
private ForecastResult forecastWithR(final int numForecastSteps) throws InvalidREvaluationResultException { final ITimeSeries<Double> history = this.getTsOriginal(); final ITimeSeries<Double> tsForecast = this.prepareForecastTS(); AbstractRForecaster.RBRIDGE.evalWithR(String.format("rm(%s)", varNameForecast)); return new ForecastResult(tsForecast, this.getTsOriginal(), this.getConfidenceLevel(), fcQuality, tsLower, tsUpper, this.strategy);
private ForecastResult forecastWithR(final int numForecastSteps) throws InvalidREvaluationResultException { final ITimeSeries<Double> history = this.getTsOriginal(); final ITimeSeries<Double> tsForecast = this.prepareForecastTS(); AbstractRForecaster.RBRIDGE.evalWithR(String.format("rm(%s)", varNameForecast)); return new ForecastResult(tsForecast, this.getTsOriginal(), this.getConfidenceLevel(), fcQuality, tsLower, tsUpper, this.strategy);