vastorbit.machine_learning.model_selection.hp_tuning.plot_acf_pacf¶
- vastorbit.machine_learning.model_selection.hp_tuning.plot_acf_pacf(vdf: VastFrame, column: str, ts: str, by: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, p: int | list = 15, show: bool = True, **style_kwargs) TableSample¶
Draws the ACF and PACF Charts.
- Parameters:
vdf (VastFrame) – Input VastFrame.
column (str) – Response column.
ts (str) – VastColumn used as timeline to order the data. It can be a numerical or date-like type (date, datetime, timestamp…) VastColumn.
by (list, optional) – VastColumns used in the partition.
p (int | list, optional) – Integer equal to the maximum number of lags to consider during the computation or a list of the different lags to include during the computation. p must be positive or a list of positive integers.
show (bool, optional) – If set to True, the Plotting object is returned.
**style_kwargs – Any optional parameter to pass to the Plotting functions.
- Returns:
acf, pacf, confidence- Return type:
Examples
We import
vastorbit:import vastorbit as vo
Hint
By assigning an alias to
vastorbit, we mitigate the risk of code collisions with other libraries. This precaution is necessary because vastorbit uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions fromvastorbitare used as intended without interfering with functions from other libraries.For this example, we will use the
amazondataset.import vastorbit.datasets as vod amazon = vod.load_amazon()
📅dateDateAbcstateVarchar(32)123numberInteger1 2016-01-01 PARAÍBA 18 2 2016-02-01 PARAÍBA 4 3 2016-03-01 PARAÍBA 1 4 2016-04-01 PARAÍBA 1 5 2016-05-01 PARAÍBA 1 6 2016-06-01 PARAÍBA 4 7 2016-07-01 PARAÍBA 22 8 2016-08-01 PARAÍBA 50 9 2016-09-01 PARAÍBA 131 10 2016-10-01 PARAÍBA 304 11 2016-11-01 PARAÍBA 132 12 2016-12-01 PARAÍBA 8 13 2016-01-01 PARÁ 1322 14 2016-02-01 PARÁ 430 15 2016-03-01 PARÁ 81 16 2016-04-01 PARÁ 66 17 2016-05-01 PARÁ 154 18 2016-06-01 PARÁ 502 19 2016-07-01 PARÁ 1579 20 2016-08-01 PARÁ 4863 21 2016-09-01 PARÁ 3953 22 2016-10-01 PARÁ 5281 23 2016-11-01 PARÁ 7879 24 2016-12-01 PARÁ 3300 25 2016-01-01 PERNAMBUCO 24 26 2016-02-01 PERNAMBUCO 19 27 2016-03-01 PERNAMBUCO 4 28 2016-04-01 PERNAMBUCO 8 29 2016-05-01 PERNAMBUCO 6 30 2016-06-01 PERNAMBUCO 4 31 2016-07-01 PERNAMBUCO 17 32 2016-08-01 PERNAMBUCO 42 33 2016-09-01 PERNAMBUCO 171 34 2016-10-01 PERNAMBUCO 319 35 2016-11-01 PERNAMBUCO 191 36 2016-12-01 PERNAMBUCO 161 37 2016-01-01 PIAUÍ 94 38 2016-02-01 PIAUÍ 97 39 2016-03-01 PIAUÍ 53 40 2016-04-01 PIAUÍ 35 41 2016-05-01 PIAUÍ 60 42 2016-06-01 PIAUÍ 153 43 2016-07-01 PIAUÍ 754 44 2016-08-01 PIAUÍ 1647 45 2016-09-01 PIAUÍ 1394 46 2016-10-01 PIAUÍ 2598 47 2016-11-01 PIAUÍ 1126 48 2016-12-01 PIAUÍ 374 49 2016-01-01 RIO DE JANEIRO 9 50 2016-02-01 RIO DE JANEIRO 16 51 2016-03-01 RIO DE JANEIRO 16 52 2016-04-01 RIO DE JANEIRO 45 53 2016-05-01 RIO DE JANEIRO 30 54 2016-06-01 RIO DE JANEIRO 37 55 2016-07-01 RIO DE JANEIRO 131 56 2016-08-01 RIO DE JANEIRO 241 57 2016-09-01 RIO DE JANEIRO 195 58 2016-10-01 RIO DE JANEIRO 30 59 2016-11-01 RIO DE JANEIRO 19 60 2016-12-01 RIO DE JANEIRO 5 61 2016-01-01 RIO GRANDE DO NORTE 15 62 2016-02-01 RIO GRANDE DO NORTE 2 63 2016-03-01 RIO GRANDE DO NORTE 1 64 2016-04-01 RIO GRANDE DO NORTE 0 65 2016-05-01 RIO GRANDE DO NORTE 1 66 2016-06-01 RIO GRANDE DO NORTE 4 67 2016-07-01 RIO GRANDE DO NORTE 13 68 2016-08-01 RIO GRANDE DO NORTE 24 69 2016-09-01 RIO GRANDE DO NORTE 44 70 2016-10-01 RIO GRANDE DO NORTE 129 71 2016-11-01 RIO GRANDE DO NORTE 93 72 2016-12-01 RIO GRANDE DO NORTE 75 73 2016-01-01 RIO GRANDE DO SUL 68 74 2016-02-01 RIO GRANDE DO SUL 55 75 2016-03-01 RIO GRANDE DO SUL 30 76 2016-04-01 RIO GRANDE DO SUL 32 77 2016-05-01 RIO GRANDE DO SUL 37 78 2016-06-01 RIO GRANDE DO SUL 261 79 2016-07-01 RIO GRANDE DO SUL 865 80 2016-08-01 RIO GRANDE DO SUL 1111 81 2016-09-01 RIO GRANDE DO SUL 628 82 2016-10-01 RIO GRANDE DO SUL 93 83 2016-11-01 RIO GRANDE DO SUL 105 84 2016-12-01 RIO GRANDE DO SUL 79 85 2016-01-01 RONDÔNIA 93 86 2016-02-01 RONDÔNIA 88 87 2016-03-01 RONDÔNIA 25 88 2016-04-01 RONDÔNIA 59 89 2016-05-01 RONDÔNIA 44 90 2016-06-01 RONDÔNIA 170 91 2016-07-01 RONDÔNIA 969 92 2016-08-01 RONDÔNIA 3675 93 2016-09-01 RONDÔNIA 4208 94 2016-10-01 RONDÔNIA 1844 95 2016-11-01 RONDÔNIA 401 96 2016-12-01 RONDÔNIA 148 97 2016-01-01 RORAIMA 1754 98 2016-02-01 RORAIMA 171 99 2016-03-01 RORAIMA 1081 100 2016-04-01 RORAIMA 126 Rows: 1-100 | Columns: 3Note
vastorbit offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the vastorbit environment.
Let’s select only one state to get a refined plot.
amazon = amazon[amazon["state"] == "ACRE"]
We can have a look at the time-series plot using the
VastFrame.plot():amazon["number"].plot(ts = "date")
Now we can plot the ACF and PACF plots together:
from vastorbit.machine_learning.model_selection import plot_acf_pacf plot_acf_pacf( amazon, column = "number", ts = "date", p = 40, )
acf pacf confidence 0 1.0 1.0 0.1267795309147783 1 0.4956793 0.4956793 0.15515153986757108 2 -0.009024917 -0.34152162 0.1671963987248046 3 -0.1394474 0.048560776 0.16777918973880393 4 -0.15902446 -0.13965213 0.17002132416812135 5 -0.16210829 -0.06440762 0.17078345455817712 6 -0.1638135 -0.112456046 0.17236347752969797 7 -0.16318145 -0.10358186 0.17375998863807843 8 -0.16027784 -0.12407207 0.17559962464166412 9 -0.14143026 -0.11157317 0.17715847810361873 10 -0.027029358 0.015773509 0.17756837174087073 11 0.36248946 0.4247969 0.19429236850351983 12 0.7616921 0.5787253 0.22192665765986883 13 0.3767513 -0.3712005 0.23270917856856066 14 -0.033830985 0.17376284 0.2354256601429028 15 -0.14322689 -0.12781657 0.2371350177977126 16 -0.16005029 0.03214064 0.23774097849119158 17 -0.16268563 -0.0519363 0.23847163588598974 18 -0.16413334 -0.010122564047751402 0.23901800732330247 19 -0.16434976 -0.035838462 0.23965421333321657 20 -0.16219983 -0.025498755 0.24024822173657268 21 -0.14461099 -0.033821065 0.24088231146275282 22 -0.026370613 0.025450256 0.24148418886869322 23 0.39679897 0.37185577 0.2519979398680095 24 0.78092813 0.21977735 0.2559772942029684 25 0.36100402 -0.171947 0.2586349142576604 26 -0.0573861 0.05623083 0.25946120323013666 27 -0.15295441 -0.04372787 0.2602056100597141 28 -0.1612245 0.009935601 0.2608283727222244 29 -0.16341664 -0.020661898 0.2614785230996206 30 -0.16503948 -0.004855762 0.2621049767776744 31 -0.16516642 -0.016216233 0.2627527655543581 32 -0.16308495 -0.0045497674 0.2633881279176183 33 -0.14744943 -0.030628238 0.26409289321972557 34 -0.05059044 -0.04169793 0.26485928164119005 35 0.29349113 -0.07382781427147896 0.2658939426901845 36 0.64792967 0.08633088 0.26707664858197155 37 0.29542336 -0.079678796 0.2681874775795322 38 -0.060731966 0.0741258 0.2692440910587496 39 -0.15466514 -0.09541516 0.2705634323233808 40 -0.16325635 0.050803825 0.27142601287474954 Rows: 1-41 | Columns: 4See also
acf(): ACF plot from aVastFrame.pacf(): PACF plot from aVastFrame.