Comments (5)
Hey @young-hun-jo,
The Vector Auto-Regression (VAR) model is designed to take multiple inputs and produce multiple outputs.
It follows the traditional Auto-Regression (AR) model's formula while replacing the individual weights and lags with matrices instead.
You can read more about the math itself here on wikipedia.
As for other models in KATS that can perform multi-variate regression with a singular output, luckily some can. However, it may not be in a format that you are used to (I know it wasn't for me the first time I saw it).
For some models KATS supports you can use the endogenous and exogenous variables.
Where endogenous (endog) is the historical data from the time series you are trying to predict.
And the exogenous (exog) is a second independent variable that has some effect on the endogenous variable.
A better explanation of endog and exog variables
Here's an example of using the ARIMA model with an exogenous variable as well.
df = pd.read_csv("../data/air_passengers.csv", parse_dates=True, infer_datetime_format=True, index_col='ds')
# Setting the exogenous variable to be the month of the year.
exog = df.index.month.values
# Creating the ts
air_ts = TimeSeriesData(time=df.index, value=df.y)
# Setting the exogneous variable in the model params
params = ARIMAParams(2, 1, 1, exog=exog, freq='MS')
model = ARIMAModel(air_ts, params)
model.fit()
# Note that exogenous variables are required to make the forecast so we have to calculate the exog again for forecasting
steps = 5
start = exog[-1]
# Generating the next months for the forecast, starting from the last month
fcst_exog = np.array([(i % 12 + 1) for i in range(start, start+steps)])
model.predict(5, exog=fcst_exog)
from kats.
You absolutely can have multiple variables in your exog argument!
I modified the example to include multiple arguments here
df = pd.read_csv("../data/air_passengers.csv", parse_dates=True, infer_datetime_format=True, index_col='ds')
exog = pd.DataFrame({
"month": df.index.month,
"year": df.index.year
}).values
# Creating the ts
air_ts = TimeSeriesData(time=df.index, value=df.y)
# Setting the exogneous variable in the model params
params = ARIMAParams(2, 1, 1, exog=exog, freq='MS')
model = ARIMAModel(air_ts, params)
model.fit()
# Note that exogenous variables are required to make the forecast so we have to calculate the exog again for the forecasting steps
steps = 5
start = exog[-1]
fcst_exog = pd.DataFrame({
"month": [(i % 12 + 1) for i in range(start[0], start[0]+steps)],
"year": list(range(start[1], start[1]+steps))
}).values
model.predict(5, exog=fcst_exog)
from kats.
The key is to make sure that the exog variable is a numpy array with the shape (length_of_data, number_of_variables).
In this example the length of the training data is 144 and the number of exog variables is 2 so the shape for exog needs to be (144, 2)
from kats.
Thanks for your awesome explanation and example! I could do this due to you! I will close this issue 😆
from kats.
Thanks for explaining this! You provided me the example with one exogenous variable. But my data has two more than exogenous variables. Can I input more exogenous variables into exog
argument? If I can do this, how can I set a type of more exogenous variable? (e.g list -> exog=[exog1, exog2, exog3, ... ]
)
from kats.
Related Issues (20)
- stream data
- stream data
- Ax-Platform Issue HOT 1
- metalearner metadata error
- Hyper Parameter Tuning Explanation
- pip install kats fail HOT 22
- After installation on Databricks Error object.__init__() takes exactly one argument HOT 3
- Is it possible to "conda install kats"? HOT 1
- Anomaly detection in multivariate time series documentation benchmark
- Can't install Kats in Python 3.11, 3.10, 3.9
- Kats installation failure HOT 5
- KeyError: 'overall_anomaly_score' HOT 1
- kats 0.2.0 ax-platform dependency
- Tutorial 202 detection BOCPDetector parameter error HOT 1
- Issues on first use HOT 1
- Implementation of online/real time inference for detection of change point by bocpd
- pip install error for kats 0.2.0
- kats installation error HOT 13
- How can I set custom model parameters in GetMetaData?
- Kats installation failure due to Cython and numpy HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kats.