TimeSeriesAnalyzer 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +88 -18
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 981015ef45222f0f9e674f4b2fe73ba988f0c118eaaaad5ee53fe07b59cc0721
|
|
4
|
+
data.tar.gz: 8697be20bf0edf3a7acea9fbcc1471f1fed58a60a4d66900805920d3298af0e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18b3fa937f73beef940e540b3e75a851cb76ee7e536b0ce759c487ef20afd0bfea774a283ddc7a9e4120d1104d827cfb1bcfbe0acfa7e233cb7948ae0a109a66
|
|
7
|
+
data.tar.gz: 52fe905ca00a582a17a623d5008b01e34de3b6c5d97c1f5384fa0a82b705c4f51c7a5b8df6d55c3f0b2f9084d3107ab5f7d7eb3730fadc55ce796e3c327a37ef
|
data/README.md
CHANGED
|
@@ -2,36 +2,106 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/KuryataDanil/TimeSeriesAnalyzer/actions/workflows/main.yml)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
TODO: Delete this and the text below, and describe your gem
|
|
7
|
-
|
|
8
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/TimeSeriesAnalyzer`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
5
|
+
TimeSeriesAnalyzer is designed for solving and visualizing numerical series
|
|
9
6
|
|
|
10
7
|
## Installation
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
```shell
|
|
10
|
+
gem install TimeSeriesAnalyzer
|
|
11
|
+
```
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
The rmagick gem must be installed for it to work properly https://imagemagick.org/script/download.php#windows
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
<img width="75%" src="https://github.com/rmagick/rmagick/assets/199156/494e7963-cca5-4cb5-b28a-6c4d76adce5d" />
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
Then you need to go to the project terminal
|
|
18
|
+
```shell
|
|
19
|
+
set CPATH="C:\Program Files (x86)\ImageMagick-[VERSION]-Q16\include"
|
|
20
|
+
set LIBRARY_PATH="C:\Program Files (x86)\ImageMagick-[VERSION]-Q16\lib"
|
|
21
|
+
em install rmagick
|
|
22
|
+
```
|
|
21
23
|
|
|
22
24
|
## Usage
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
Uploading data from a CSV file:
|
|
27
|
+
```ruby
|
|
28
|
+
time_series = TimeSeriesAnalyzer::TimeSeries.load_from_csv(file_path)
|
|
29
|
+
# the second variable "period" determines the seasonality of the data
|
|
30
|
+
# by default -1, which means the seasonality is determined automatically
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Visualization of a time series:
|
|
34
|
+
```ruby
|
|
35
|
+
time_series.plot(file_name)
|
|
36
|
+
# the second variable "title" indicates the title of the graph
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Decomposition of a time series:
|
|
40
|
+
```ruby
|
|
41
|
+
decomposed = time_series.decompose
|
|
42
|
+
|
|
43
|
+
print(decomposed[:trend].data) # trend
|
|
44
|
+
puts ""
|
|
45
|
+
print(decomposed[:seasonal].data) # seasonal component
|
|
46
|
+
puts ""
|
|
47
|
+
print(decomposed[:residual].data) # remains
|
|
48
|
+
puts ""
|
|
49
|
+
|
|
50
|
+
decomposed[:trend].plot('trend.png')
|
|
51
|
+
decomposed[:seasonal].plot('seasonal.png')
|
|
52
|
+
decomposed[:residual].plot('residual.png')
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Application of the moving average:
|
|
56
|
+
```ruby
|
|
57
|
+
moving_average(window_size)
|
|
58
|
+
#Returns a numeric series representing the moving average of the original
|
|
59
|
+
#parameter window_size is the size
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
smoothed_series = time_series.moving_average(3)
|
|
63
|
+
print(smoothed_series.data)
|
|
64
|
+
puts ""
|
|
65
|
+
smoothed_series.plot('moving_average.png')
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Applying exponential smoothing:
|
|
69
|
+
```ruby
|
|
70
|
+
exponential_smoothing(alpha)
|
|
71
|
+
#Returns a numeric series representing the exponential smoothing of the original one
|
|
72
|
+
#The value of alpha represents the smoothing factor, which determines the weight of the current
|
|
73
|
+
#observation compared to the smoothed previous value.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
smoothed_series = time_series.exponential_smoothing(0.3)
|
|
77
|
+
print(smoothed_series.data)
|
|
78
|
+
puts ""
|
|
79
|
+
smoothed_series.plot('exponential_smoothing.png')
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Anomaly detection:
|
|
83
|
+
```ruby
|
|
84
|
+
detect_anomalies
|
|
85
|
+
#Function that returns detected anomalies in the numeric series
|
|
86
|
+
#Anomalies found are returned as dictionaries with timestamps and values.
|
|
87
|
+
|
|
88
|
+
anomalies = time_series.detect_anomalies
|
|
89
|
+
anomalies.each { |anomaly| puts "Anomaly detected at #{anomaly[:timestamp]}: #{anomaly[:value]}" }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Forecasting:
|
|
93
|
+
```ruby
|
|
94
|
+
forecast(steps)
|
|
95
|
+
#Function that predicts the following values (prediction based on the subsequent change of residues only)
|
|
96
|
+
#steps - number of steps for which it is necessary to forecast
|
|
97
|
+
|
|
98
|
+
forecasted_values = time_series.forecast(10)
|
|
99
|
+
puts "Forecasted values: #{forecasted_values}"
|
|
100
|
+
```
|
|
31
101
|
|
|
32
102
|
## Contributing
|
|
33
103
|
|
|
34
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
104
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/KuryataDanil/TimeSeriesAnalyzer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/KuryataDanil/TimeSeriesAnalyzer/blob/master/CODE_OF_CONDUCT.md).
|
|
35
105
|
|
|
36
106
|
## License
|
|
37
107
|
|