Skip to main content

PSF: Pattern Sequence-based Forecasting (PSF) algorithm

Project description

PSF_Py

Version: 0.3
Date: 9/4/2019
Author: Mayur Shende, Neeraj Bokde
Maintainer: Mayur Shende mayur.k.shende@gmail.com, Neeraj Bokde neerajdhanraj@gmail.com
License: GPL (>= 3)
Packaged: 2019-04-13 17:15:59 UTC\

Introduction to Pattern Sequence based Forecasting (PSF) algorithm

Pattern Sequence Based Forecasting (PSF) takes univariate time series data as input and assist to forecast its future values. This algorithm forecasts the behavior of time series based on similarity of pattern sequences. Initially, clustering is done with the labeling of samples from database. The labels associated with samples are then used for forecasting the future behaviour of time series data.

The Algorithm Pattern Sequence based Forecasting (PSF) was first proposed by Martinez Alvarez, et al., 2008 and then modified and suggested improvement by Martinez Alvarez, et al., 2011. The technical detailes are mentioned in referenced articles. PSF algorithm consists of various statistical operations like:

  • Data Normalization/ Denormalization
  • Calculation of optimum Window size (W)
  • Calculation of optimum cluster size (k)
  • Pattern Sequence based Forecasting
  • RMSE/MAE Calculation, etc..

Example 1:

from PSF_Py import Psf, get_ts
import pandas as pd

ts = get_ts('nottem')

# Creating PSF model for prediction.
a = Psf(data = ts, cycle = 12)

# Use predict to predict the values
a.predict(n_ahead = 12)

# Print the model
a.model_print()

# Plot the time series
a.psf_plot(ts, a.preds)

Output :

Original time-series : 
0      40.6
1      40.8
2      44.4
3      46.7
4      54.1
5      58.5
6      57.7
7      56.4
8      54.3
9      50.5
10     42.9
11     39.8
12     44.2
13     39.8
14     45.1
15     47.0
16     54.1
17     58.7
18     66.3
19     59.9
20     57.0
21     54.2
22     39.7
23     42.8
24     37.5
25     38.7
26     39.5
27     42.1
28     55.7
29     57.8
       ... 
210    61.4
211    61.8
212    56.3
213    50.9
214    41.4
215    37.1
216    42.1
217    41.2
218    47.3
219    46.6
220    52.4
221    59.0
222    59.6
223    60.4
224    57.0
225    50.7
226    47.8
227    39.2
228    39.4
229    40.9
230    42.4
231    47.8
232    52.4
233    58.0
234    60.7
235    61.8
236    58.2
237    46.7
238    46.6
239    37.8
Name: nottem, Length: 240, dtype: float64

Predicted Values : 
 [39.4 40.9 42.4 47.8 52.4 58.  60.7 61.8 58.2 46.7 46.6 37.8]

k =  3

w =  12

cycle =  12

Example 2:

from PSF_Py import Psf, get_ts
import pandas as pd

ts = get_ts('penguin')

# Creating PSF model for prediction.
a = Psf(data=ts, cycle=12)

# Use predict to predict the values
a.predict(n_ahead=12)

# Print the model
a.model_print()

# Plot the time series
a.psf_plot(ts, a.preds)

Output:

Original time-series : 
0      753
1      448
2      356
3      504
4      698
5      256
6      361
7      476
8      541
9      812
10     914
11     998
12     762
13     461
14     374
15     521
16     712
17     274
18     384
19     492
20     561
21     821
22     930
23    1014
24     779
25     478
26     391
27     543
28     910
29     287
      ... 
54     225
55     304
56     416
57     642
58     769
59     853
60     572
61     273
62     208
63     341
64     553
65     136
66     231
67     299
68     403
69     632
70     759
71     848
72     561
73     268
74     212
75     331
76     542
77     128
78     225
79     301
80     389
81     624
82     748
83     842
Name: Number, Length: 84, dtype: int64

Predicted Values : 
 [572. 273. 208. 341. 553. 136. 231. 299. 403. 632. 759. 848.]

k =  3

w =  14

cycle =  12

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PSF_Py-0.3.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

PSF_Py-0.3-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

Details for the file PSF_Py-0.3.tar.gz.

File metadata

  • Download URL: PSF_Py-0.3.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for PSF_Py-0.3.tar.gz
Algorithm Hash digest
SHA256 960997412edd5b49d53d6afbc66120a370dd72e7929304234ad98d0881927057
MD5 f22d149ff82bf9ce02a6f82716eb93ef
BLAKE2b-256 b03dfc74f9d294180e66825f33ab53e8caf487a83a88c96f991e60f0f7af5856

See more details on using hashes here.

File details

Details for the file PSF_Py-0.3-py3-none-any.whl.

File metadata

  • Download URL: PSF_Py-0.3-py3-none-any.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for PSF_Py-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dae39d109a42d4af43c783b160e770062d4453aff64d4ff79d7df20d7c5c69c3
MD5 4b97fd17782c173f7d1198fcdcef3f71
BLAKE2b-256 a8016fce068c73ceef5354e73f3dfac29680e71f3ef38bf1ff281d4c1731d4b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page