Loading...

verticapy.machine_learning.vertica.tsa.ARIMA.plot#

ARIMA.plot(vdf: str | vDataFrame | None = None, ts: str | None = None, y: str | None = None, start: int | None = None, npredictions: int = 10, method: Literal['auto', 'forecast'] = 'auto', chart: PlottingBase | TableSample | Axes | mFigure | Highchart | Highstock | Figure | None = None, **style_kwargs) PlottingBase | TableSample | Axes | mFigure | Highchart | Highstock | Figure#

Draws the model.

Parameters#

vdf: SQLRelation, optional

Object used to run the prediction. You can also specify a customized relation, but you must enclose it with an alias. For example, (SELECT 1) x is valid, whereas (SELECT 1) and SELECT 1 are invalid.

ts: str, optional

TS (Time Series) :py:class`vDataColumn` used to order the data. The :py:class`vDataColumn` type must be date (date, datetime, timestamp…) or numerical.

y: str, optional

Response column.

start: int, optional

The behavior of the start parameter and its range of accepted values depends on whether you provide a timeseries-column (ts):

  • No provided timeseries-column:

    start must be an integer greater or equal to 0, where zero indicates to start prediction at the end of the in-sample data. If start is a positive value, the function predicts the values between the end of the in-sample data and the start index, and then uses the predicted values as time series inputs for the subsequent npredictions.

  • timeseries-column provided:

    start must be an integer greater or equal to 1 and identifies the index (row) of the timeseries-column at which to begin prediction. If the start index is greater than the number of rows, N, in the input data, the function predicts the values between N and start and uses the predicted values as time series inputs for the subsequent npredictions.

Default:

  • No provided timeseries-column:

    prediction begins from the end of the in-sample data.

  • timeseries-column provided:

    prediction begins from the end of the provided input data.

npredictions: int, optional

integer greater or equal to 1, the number of predicted timesteps.

method: str, optional

Forecasting method. One of the following:

  • auto:

    the model initially utilizes the true values at each step for forecasting. However, when it reaches a point where it can no longer rely on true values, it transitions to using its own predictions for further forecasting. This method is often referred to as “one step ahead” forecasting.

  • forecast:

    the model initiates forecasting from an initial value and entirely disregards any subsequent true values. This approach involves forecasting based solely on the model’s own predictions and does not consider actual observations after the start point.

chart: PlottingObject, optional

The chart object to plot on.

**style_kwargs

Any optional parameter to pass to the Plotting functions.

Returns#

object

Plotting Object.

Examples#

We import verticapy:

import verticapy as vp

For this example, we will use the airline passengers dataset.

import verticapy.datasets as vpd

data = vpd.load_airline_passengers()
📅
date
Date
123
passengers
Integer
11949-01-01112
21949-02-01118
31949-03-01132
41949-04-01129
51949-05-01121
61949-06-01135
71949-07-01148
81949-08-01148
91949-09-01136
101949-10-01119
111949-11-01104
121949-12-01118
131950-01-01115
141950-02-01126
151950-03-01141
161950-04-01135
171950-05-01125
181950-06-01149
191950-07-01170
201950-08-01170
211950-09-01158
221950-10-01133
231950-11-01114
241950-12-01140
251951-01-01145
261951-02-01150
271951-03-01178
281951-04-01163
291951-05-01172
301951-06-01178
311951-07-01199
321951-08-01199
331951-09-01184
341951-10-01162
351951-11-01146
361951-12-01166
371952-01-01171
381952-02-01180
391952-03-01193
401952-04-01181
411952-05-01183
421952-06-01218
431952-07-01230
441952-08-01242
451952-09-01209
461952-10-01191
471952-11-01172
481952-12-01194
491953-01-01196
501953-02-01196
511953-03-01236
521953-04-01235
531953-05-01229
541953-06-01243
551953-07-01264
561953-08-01272
571953-09-01237
581953-10-01211
591953-11-01180
601953-12-01201
611954-01-01204
621954-02-01188
631954-03-01235
641954-04-01227
651954-05-01234
661954-06-01264
671954-07-01302
681954-08-01293
691954-09-01259
701954-10-01229
711954-11-01203
721954-12-01229
731955-01-01242
741955-02-01233
751955-03-01267
761955-04-01269
771955-05-01270
781955-06-01315
791955-07-01364
801955-08-01347
811955-09-01312
821955-10-01274
831955-11-01237
841955-12-01278
851956-01-01284
861956-02-01277
871956-03-01317
881956-04-01313
891956-05-01318
901956-06-01374
911956-07-01413
921956-08-01405
931956-09-01355
941956-10-01306
951956-11-01271
961956-12-01306
971957-01-01315
981957-02-01301
991957-03-01356
1001957-04-01348
Rows: 1-100 | Columns: 2

First we import the model:

from verticapy.machine_learning.vertica.tsa import ARIMA

Then we can create the model:

model = ARIMA(order = (12, 1, 2))

We can now fit the model:

model.fit(data, "date", "passengers")

We can conveniently plot the predictions on a line plot to observe the efficacy of our model:

model.plot(data, "date", "passengers", npredictions = 20, start = 140)

Important

For this example, a specific model is utilized, and it may not correspond exactly to the model you are working with. To see a comprehensive example specific to your class of interest, please refer to that particular class.

Examples: ARIMA; ARMA; AR; MA;