Git Product home page Git Product logo

timeseries-forecast's Introduction

Timeseries-Forecast

This is a Java open source library which provides a time series forecasting functionality. It is an implementation of the Hannan-Rissanen algorithm for additive ARIMA models. This library is published by the Workday's Syman team, and is used to support basic timeseries forecasting functionalities in some of the Workday products.

Build Status

How to Use

In order to use this library, you need to provide input timeseries data as well as ARIMA parameters. The ARIMA parameters consist of a) non-seasonal parameters p,d,q and b) seasonal parameters P,D,Q,m. If D or m is less than 1, then the model is understood to be non-seasonal and the seasonal parameters P,D,Q,m will have no effect.

import com.workday.insights.timeseries.arima.Arima;
import com.workday.insights.timeseries.arima.struct.ForecastResult;

// Prepare input timeseries data.
double[] dataArray = new double[] {2, 1, 2, 5, 2, 1, 2, 5, 2, 1, 2, 5, 2, 1, 2, 5};

// Set ARIMA model parameters.
int p = 3;
int d = 0;
int q = 3;
int P = 1;
int D = 1;
int Q = 0;
int m = 0;
int forecastSize = 1;

// Obtain forecast result. The structure contains forecasted values and performance metric etc.
ForecastResult forecastResult = Arima.forecast_arima(dataArray, forecastSize, p, d, q, P, D, Q, m);

// Read forecast values
double[] forecastData = forecastResult.getForecast(); // in this example, it will return { 2 }

// You can obtain upper- and lower-bounds of confidence intervals on forecast values.
// By default, it computes at 95%-confidence level. This value can be adjusted in ForecastUtil.java
double[] uppers = forecastResult.getForecastUpperConf();
double[] lowers = forecastResult.getForecastLowerConf();

// You can also obtain the root mean-square error as validation metric.
double rmse = forecastResult.getRMSE();

// It also provides the maximum normalized variance of the forecast values and their confidence interval.
double maxNormalizedVariance = forecastResult.getMaxNormalizedVariance();

// Finally you can read log messages.
String log = forecastResult.getLog();

How to Build

This library uses Maven as its build tool.

// Compile the source code of the project.
mvn compile

// To generate javadocs
mvn javadoc:javadoc

// To generate a site for the current project
mvn site

// Take the compiled code and package it
mvn package

// Install the package into the local repository, which can be used as a dependency in other projects locally.
mvn install

Dependencies

The library has the following dependencies:

JUnit 4.12

Authors

Here is the Contributors List for the timeseries-forecast library. Please note that the project was developed and ported from an internal repository. Therefore, the commit record does not reflect the full history of the project.

License

Copyright 2017 Workday, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

timeseries-forecast's People

Contributors

aceforecast avatar jtschult avatar yonseokim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

timeseries-forecast's Issues

d parameter does not work well

For this dataset:
2674.8060304978917, 3371.1788109723193, 2657.161969121835, 2814.5583226655367, 3290.855749923403, 3103.622791045206, 3403.2011487950185, 2841.438925235243, 2995.312700153925, 3256.4042898633224, 2609.8702933486843, 3214.6409110870877, 2952.1736018157644, 3468.7045537306344, 3260.9227206904898, 2645.5024256492215, 3137.857549381811, 3311.3526531674556, 2929.7762119375716, 2846.05991810631, 2606.47822546165, 3174.9770937667918, 3140.910443979614, 2590.6601484185085, 3123.4299821259915, 2714.4060964141136, 3133.9561758319487, 2951.3288157912752, 2860.3114228342765, 2757.4279640677833

the next 6 data points in real life are:
3147.816496825682, 3418.2300802476093, 2856.905414401418, 3419.0312162705545, 3307.9803365878442, 3527.68377555284

Note that there is a slight trend up in the dataset. I would expect a little better result with d = 1.

predict the next 6 points:

  1. use p = 2, d = 0, all others = 0, confidence = 0.8:

RMSE: 199.8163163213122
3079.5652126415816, 3018.357601612911, 2972.5923804575086, 2995.670261137454, 2998.568039880799, 2993.4644978016477

if I use p =2, d =1, all others = 0, confidence = 0.8:

RMSE: 253.6211530852703
2886.970570844559, 2835.4065710542895, 2825.3444795390224, 2862.835372496484, 2843.664918178257, 2848.710910931624

So, with d =1, it is about 20% worse measured by RMSE.

  1. p =3, d = 0, confidence = 0.8:

RMSE: 215.41839087831758
3084.2187112556344, 3008.4402233252013, 2979.552888778218, 2995.6062055652237, 2996.5840132883823, 2994.1306487277516

p = 3, d = 1, confidence = 0.8:

RMSE: 290.36910432429397
2954.849845119037, 2867.9992817121565, 2862.9013638112624, 2878.2804776911416, 2896.2693454378027, 2880.143205617359

The result is about 40% worse with d = 1 measured by RMSE.

Failed to build ARIMA forecast: not enough data points: length=7, r=4

I want to generate forecast for next 3 months using last 6 months data.
I tried with 9 months data and following data but getting following error:
"Failed to build ARIMA forecast: not enough data points: length=7, r=4"

Data:

int p = 3;
int d = 0;
int q = 3;
int P = 1;
int D = 1;
int Q = 0;
int m = 0;
int forecastSize = 3;
	     
final ArimaParams paramsForecast = new ArimaParams(p, d, q, P, D, Q, m);
double[] inputData = {100.0, 50.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};

ForecastResult forecastResult = Arima.forecast_arima(inputData, forecastSize, paramsForecast);
double[] predictedData = forecastResult.getForecast(); 


Any solution for this?

YuleWalker not used?

HannanRissanen.estimateARMA() calculates "yuleWalkerParams", but these params are not used anywhere in the code.
is this a "TODO" item? or maybe YuleWalker not needed (dead code)?

Vulnerability in Library

Hello,

We came across this Security Vulnerability: https://nvd.nist.gov/vuln/detail/CVE-2019-12134

CSV Injection (aka Excel Macro Injection or Formula Injection) exists in the export feature in Workday through 32 via a value (provided by a low-privileged user in a contact form field) that is mishandled in a CSV export.

Wanted to understand if a fix has been made on this one or if it's really a valid issue?

Thank you
Rupesh

How does RMSE get calculated?

My understanding is that it should be get calculated on a validation set but this model forecasts values for the future (I don't provide a true 'future' values to calculated RMSE on), so how do we get that RMSE error?

Confidence intervals: Provide better mechanisms for customization

Hi!
First of all, great library, thanks for open-sourcing it!

In my project, I'd like to apply custom confidence intervals to the ARIMA predictions.
In the Readme file, you have stated that the confidence intervals can be changed in the ForecastUtil class, presumably through changing its confidence_constant_95pct constant. This, however, is not feasible if the project is used as a Maven dependency instead of using it as a local source dependency. It is, furthermore, not obvious to the layperson (or at least to me) how to calculate the constant for another confidence interval.

As far as I see it, the problem could be addressed in two ways ways:

  • Provide a public, static conversion method to get the constant for a custom percentile in ForecastUtil which can then be used with the setConfInterval method of the ForecastResult class. This would maybe be the simplest solution!
  • Extend the ArimaParams class with a confidence interval property, there could then maybe be another constructor with which custom percentiles can be set.

I'd be glad to contribute a solution to this if someone could give me some pointers on how to calculate the constant.

Have a great day!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.