noshot 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl

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.
Files changed (36) hide show
  1. noshot/data/ML TS XAI/ML/1. PCA - EDA/PCA-EDA.ipynb +207 -0
  2. noshot/data/ML TS XAI/ML/1. PCA - EDA/balance-scale.csv +626 -0
  3. noshot/data/ML TS XAI/ML/1. PCA - EDA/input.txt +625 -0
  4. noshot/data/ML TS XAI/ML/2. KNN Classifier/KNN.ipynb +287 -0
  5. noshot/data/ML TS XAI/ML/2. KNN Classifier/balance-scale.csv +626 -0
  6. noshot/data/ML TS XAI/ML/2. KNN Classifier/input.txt +625 -0
  7. noshot/data/ML TS XAI/ML/3. Linear Discriminant Analysis/LDA.ipynb +83 -0
  8. noshot/data/ML TS XAI/ML/3. Linear Discriminant Analysis/balance-scale.csv +626 -0
  9. noshot/data/ML TS XAI/ML/3. Linear Discriminant Analysis/input.txt +625 -0
  10. noshot/data/ML TS XAI/ML/4. Linear Regression/Linear-Regression.ipynb +117 -0
  11. noshot/data/ML TS XAI/ML/4. Linear Regression/machine-data.csv +210 -0
  12. noshot/data/ML TS XAI/ML/5. Logistic Regression/Logistic-Regression.ipynb +137 -0
  13. noshot/data/ML TS XAI/ML/5. Logistic Regression/wine-dataset.csv +179 -0
  14. noshot/data/ML TS XAI/ML/6. Bayesian Classifier/Bayesian.ipynb +87 -0
  15. noshot/data/ML TS XAI/ML/6. Bayesian Classifier/wine-dataset.csv +179 -0
  16. noshot/data/ML TS XAI/TS/1. EDA - Handling Time Series Data/Handling TS Data.ipynb +247 -0
  17. noshot/data/ML TS XAI/TS/1. EDA - Handling Time Series Data/raw_sales.csv +29581 -0
  18. noshot/data/ML TS XAI/TS/2. Feature Engineering/Feature Engineering-.ipynb +183 -0
  19. noshot/data/ML TS XAI/TS/3. Temporal Relationships/Exploring Temporal Relationships.ipynb +172 -0
  20. noshot/data/ML TS XAI/TS/4. Up-Down-Sampling and Interploation/Up-Down-Sampling.ipynb +146 -0
  21. noshot/data/ML TS XAI/TS/4. Up-Down-Sampling and Interploation/shampoo_sales.csv +37 -0
  22. noshot/data/ML TS XAI/TS/5. Stationarity - Trend - Seasonality/Stationarity-Trend-Seasonality.ipynb +173 -0
  23. noshot/data/ML TS XAI/TS/5. Stationarity - Trend - Seasonality/daily-min-temperatures.csv +3651 -0
  24. noshot/data/ML TS XAI/TS/5. Stationarity - Trend - Seasonality/daily-total-female-births.csv +366 -0
  25. noshot/data/ML TS XAI/TS/6. Autocorrelation - Partial Autocorrelation/ACF-PACF.ipynb +77 -0
  26. noshot/data/ML TS XAI/TS/6. Autocorrelation - Partial Autocorrelation/daily-min-temperatures.csv +3651 -0
  27. noshot/data/ML TS XAI/TS/AllinOne.ipynb +12676 -0
  28. noshot/main.py +18 -18
  29. noshot/utils/__init__.py +2 -2
  30. noshot/utils/shell_utils.py +56 -56
  31. {noshot-0.3.1.dist-info → noshot-0.3.2.dist-info}/LICENSE.txt +20 -20
  32. {noshot-0.3.1.dist-info → noshot-0.3.2.dist-info}/METADATA +55 -55
  33. noshot-0.3.2.dist-info/RECORD +36 -0
  34. noshot-0.3.1.dist-info/RECORD +0 -9
  35. {noshot-0.3.1.dist-info → noshot-0.3.2.dist-info}/WHEEL +0 -0
  36. {noshot-0.3.1.dist-info → noshot-0.3.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,183 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "ac978750-0ac5-4371-a0fb-a54f8503fc64",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import numpy as np\n",
11
+ "import pandas as pd\n",
12
+ "import matplotlib.pyplot as plt"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": null,
18
+ "id": "1bc21b2b-ccd4-4ed9-888b-b022bd800d26",
19
+ "metadata": {},
20
+ "outputs": [],
21
+ "source": [
22
+ "np.random.seed(42)\n",
23
+ "values = np.random.randn(100)\n",
24
+ "values[:10]"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": null,
30
+ "id": "b23f68f1-98f8-4d36-8fc8-d92eb82240ae",
31
+ "metadata": {},
32
+ "outputs": [],
33
+ "source": [
34
+ "dates = pd.date_range(start='2023-01-01',end='2023-04-10',freq='D')\n",
35
+ "dates[:10]"
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": null,
41
+ "id": "7c763c06-37fc-4070-b8ee-2241563a6ea4",
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "df = pd.DataFrame(values,index=dates,columns=['value'])\n",
46
+ "df.head()"
47
+ ]
48
+ },
49
+ {
50
+ "cell_type": "code",
51
+ "execution_count": null,
52
+ "id": "3a3555e2-1925-4a94-85a2-5ca3909a4c72",
53
+ "metadata": {},
54
+ "outputs": [],
55
+ "source": [
56
+ "df['value'].plot(kind='hist',bins=20,title='value')\n",
57
+ "plt.show()"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": null,
63
+ "id": "d6188560-d5ed-4093-b3b0-7da64bfa99b1",
64
+ "metadata": {},
65
+ "outputs": [],
66
+ "source": [
67
+ "df['value'].plot(kind='hist',bins=20,title='value')\n",
68
+ "plt.show()"
69
+ ]
70
+ },
71
+ {
72
+ "cell_type": "code",
73
+ "execution_count": null,
74
+ "id": "42b76b42-0f4e-4f90-904e-ef286fa92464",
75
+ "metadata": {},
76
+ "outputs": [],
77
+ "source": [
78
+ "df['value'].plot(kind='line',figsize=(8,4),title='value')\n",
79
+ "plt.show()"
80
+ ]
81
+ },
82
+ {
83
+ "cell_type": "code",
84
+ "execution_count": null,
85
+ "id": "e1975c05-f04e-445f-8ddb-30ea29f3e231",
86
+ "metadata": {},
87
+ "outputs": [],
88
+ "source": [
89
+ "plt.figure(figsize=(10,6))\n",
90
+ "plt.plot(df['value'])\n",
91
+ "plt.xlabel('Date')\n",
92
+ "plt.ylabel('value')\n",
93
+ "plt.title('Synthetic time series Dataset')\n",
94
+ "plt.show()"
95
+ ]
96
+ },
97
+ {
98
+ "cell_type": "code",
99
+ "execution_count": null,
100
+ "id": "6c46e388-cba3-43ca-b5ef-b5dfd55d4418",
101
+ "metadata": {},
102
+ "outputs": [],
103
+ "source": [
104
+ "df['year'] = df.index.year\n",
105
+ "df['month'] = df.index.month\n",
106
+ "df['day'] = df.index.day\n",
107
+ "df['weekday'] = df.index.weekday\n",
108
+ "df.head()"
109
+ ]
110
+ },
111
+ {
112
+ "cell_type": "code",
113
+ "execution_count": null,
114
+ "id": "a09ab128-c1a1-40da-aa23-23862def187f",
115
+ "metadata": {},
116
+ "outputs": [],
117
+ "source": [
118
+ "df['lag_1']=df['value'].shift(1)\n",
119
+ "df.head()"
120
+ ]
121
+ },
122
+ {
123
+ "cell_type": "code",
124
+ "execution_count": null,
125
+ "id": "30c06285-7362-48e2-80cb-89302f8a29e0",
126
+ "metadata": {},
127
+ "outputs": [],
128
+ "source": [
129
+ "df['lag_2']=df['value'].shift(2)\n",
130
+ "df.head()"
131
+ ]
132
+ },
133
+ {
134
+ "cell_type": "code",
135
+ "execution_count": null,
136
+ "id": "9734d51b-898b-4c6b-a1cd-a30a5cdab71b",
137
+ "metadata": {},
138
+ "outputs": [],
139
+ "source": [
140
+ "df['rollling_mean_5'] = df['value'].rolling(5).mean()\n",
141
+ "df['rollling_std_5'] = df['value'].rolling(5).std()\n",
142
+ "df['rollling_min_5'] = df['value'].rolling(5).min()\n",
143
+ "df['rollling_max_5'] = df['value'].rolling(5).max()\n",
144
+ "df.head()"
145
+ ]
146
+ },
147
+ {
148
+ "cell_type": "code",
149
+ "execution_count": null,
150
+ "id": "44564c15-d51e-4dd8-bed9-0d5d3e340fac",
151
+ "metadata": {},
152
+ "outputs": [],
153
+ "source": [
154
+ "df['expanding_mean_5'] = df['value'].expanding(5).mean()\n",
155
+ "df['expanding_std_5'] = df['value'].expanding(5).std()\n",
156
+ "df['expanding_min_5'] = df['value'].expanding(5).min()\n",
157
+ "df['expanding_max_5'] = df['value'].expanding(5).max()\n",
158
+ "df.head()"
159
+ ]
160
+ }
161
+ ],
162
+ "metadata": {
163
+ "kernelspec": {
164
+ "display_name": "Python 3 (ipykernel)",
165
+ "language": "python",
166
+ "name": "python3"
167
+ },
168
+ "language_info": {
169
+ "codemirror_mode": {
170
+ "name": "ipython",
171
+ "version": 3
172
+ },
173
+ "file_extension": ".py",
174
+ "mimetype": "text/x-python",
175
+ "name": "python",
176
+ "nbconvert_exporter": "python",
177
+ "pygments_lexer": "ipython3",
178
+ "version": "3.12.4"
179
+ }
180
+ },
181
+ "nbformat": 4,
182
+ "nbformat_minor": 5
183
+ }
@@ -0,0 +1,172 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "8fba5290-f2d4-4a0e-8ee6-54eea00d0684",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import numpy as np\n",
11
+ "import pandas as pd\n",
12
+ "import matplotlib.pyplot as plt\n",
13
+ "import seaborn as sns"
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "code",
18
+ "execution_count": null,
19
+ "id": "2d6192e1-b823-40b9-bb03-0fcc1bc0ab07",
20
+ "metadata": {},
21
+ "outputs": [],
22
+ "source": [
23
+ "np.random.seed(42)\n",
24
+ "dates = pd.date_range(start='2024-01-01',end='2024-04-09',freq='D')\n",
25
+ "values = np.random.normal(loc=78,scale=16,size=len(dates)) #loc-Mean of Distribution, scale-Standard Deviation"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "code",
30
+ "execution_count": null,
31
+ "id": "db65f62d-4477-4f0f-bc49-852a55f4003a",
32
+ "metadata": {},
33
+ "outputs": [],
34
+ "source": [
35
+ "df = pd.DataFrame(index=dates,data=values,columns=['Temperature'])\n",
36
+ "df.head()"
37
+ ]
38
+ },
39
+ {
40
+ "cell_type": "code",
41
+ "execution_count": null,
42
+ "id": "a0a6c6ab-e310-465c-93d4-4c0cd4f4be7c",
43
+ "metadata": {},
44
+ "outputs": [],
45
+ "source": [
46
+ "df.isnull().sum()"
47
+ ]
48
+ },
49
+ {
50
+ "cell_type": "code",
51
+ "execution_count": null,
52
+ "id": "ddb04850-cfc2-4b3a-b52c-e6adca900e9d",
53
+ "metadata": {},
54
+ "outputs": [],
55
+ "source": [
56
+ "df.describe().T"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": null,
62
+ "id": "c25aee71-9dcd-478a-b3df-2423395b948c",
63
+ "metadata": {},
64
+ "outputs": [],
65
+ "source": [
66
+ "df.plot(kind='hist',bins=20,figsize=(8,4))\n",
67
+ "plt.show()"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "code",
72
+ "execution_count": null,
73
+ "id": "5b14dc33-237b-4e11-886b-4294ded57d6c",
74
+ "metadata": {},
75
+ "outputs": [],
76
+ "source": [
77
+ "df.plot(kind='kde',figsize=(8,4))\n",
78
+ "plt.show()"
79
+ ]
80
+ },
81
+ {
82
+ "cell_type": "code",
83
+ "execution_count": null,
84
+ "id": "50b9c442-24ba-4afd-a41d-4449957ab056",
85
+ "metadata": {},
86
+ "outputs": [],
87
+ "source": [
88
+ "df.plot(kind='box',figsize=(4,4))\n",
89
+ "plt.show()"
90
+ ]
91
+ },
92
+ {
93
+ "cell_type": "code",
94
+ "execution_count": null,
95
+ "id": "8b9f0eaa-7d81-4e43-a12f-22da8992390a",
96
+ "metadata": {},
97
+ "outputs": [],
98
+ "source": [
99
+ "df.plot(kind='line',figsize=(8,4))\n",
100
+ "plt.show()"
101
+ ]
102
+ },
103
+ {
104
+ "cell_type": "code",
105
+ "execution_count": null,
106
+ "id": "ae4b74a2-ad44-4624-bd87-98f6feef4f17",
107
+ "metadata": {},
108
+ "outputs": [],
109
+ "source": [
110
+ "plt.figure(figsize=(8,4))\n",
111
+ "plt.scatter(x=df.index,y=df['Temperature'])\n",
112
+ "plt.xticks(rotation=45)\n",
113
+ "plt.show()"
114
+ ]
115
+ },
116
+ {
117
+ "cell_type": "code",
118
+ "execution_count": null,
119
+ "id": "b3e047ce-c749-44e7-b250-9749649e3c1c",
120
+ "metadata": {},
121
+ "outputs": [],
122
+ "source": [
123
+ "plt.figure(figsize=(8,4))\n",
124
+ "pd.plotting.autocorrelation_plot(df['Temperature'])\n",
125
+ "plt.show()"
126
+ ]
127
+ },
128
+ {
129
+ "cell_type": "code",
130
+ "execution_count": null,
131
+ "id": "dac6bf07-c177-46cc-9206-043b77abc8d3",
132
+ "metadata": {},
133
+ "outputs": [],
134
+ "source": [
135
+ "df.corr()"
136
+ ]
137
+ },
138
+ {
139
+ "cell_type": "code",
140
+ "execution_count": null,
141
+ "id": "25daff75-977a-49ab-b642-f7d74dc481fb",
142
+ "metadata": {},
143
+ "outputs": [],
144
+ "source": [
145
+ "plt.figure(figsize=(3,3))\n",
146
+ "sns.heatmap(df)\n",
147
+ "plt.show()"
148
+ ]
149
+ }
150
+ ],
151
+ "metadata": {
152
+ "kernelspec": {
153
+ "display_name": "Python 3 (ipykernel)",
154
+ "language": "python",
155
+ "name": "python3"
156
+ },
157
+ "language_info": {
158
+ "codemirror_mode": {
159
+ "name": "ipython",
160
+ "version": 3
161
+ },
162
+ "file_extension": ".py",
163
+ "mimetype": "text/x-python",
164
+ "name": "python",
165
+ "nbconvert_exporter": "python",
166
+ "pygments_lexer": "ipython3",
167
+ "version": "3.12.4"
168
+ }
169
+ },
170
+ "nbformat": 4,
171
+ "nbformat_minor": 5
172
+ }
@@ -0,0 +1,146 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "6bb9403b-263b-48e3-a516-a436a771ab3d",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import pandas as pd\n",
11
+ "import numpy as np\n",
12
+ "import matplotlib.pyplot as plt\n",
13
+ "import seaborn as sns\n",
14
+ "import random"
15
+ ]
16
+ },
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": null,
20
+ "id": "e62e553d-9abb-4f4a-bf47-48df2618e1ba",
21
+ "metadata": {},
22
+ "outputs": [],
23
+ "source": [
24
+ "np.random.seed(42)\n",
25
+ "dates=pd.date_range('2024-01-01','2024-12-31',freq='ME')\n",
26
+ "data=pd.DataFrame(data=[random.randint(0,1000) for i in range(len(dates))], index=dates,columns=['Values'])\n",
27
+ "data.head()"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": null,
33
+ "id": "00fc7ac6-e20b-4203-8e76-02fb6d7cc435",
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "data.plot(kind='line')\n",
38
+ "plt.show()"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "markdown",
43
+ "id": "90d4394d-e513-49d1-9f0c-17540946e676",
44
+ "metadata": {},
45
+ "source": [
46
+ "**Up Sampling and Interpolation**"
47
+ ]
48
+ },
49
+ {
50
+ "cell_type": "code",
51
+ "execution_count": null,
52
+ "id": "a5b59623-5abc-4f47-86de-f5992dd95d4b",
53
+ "metadata": {},
54
+ "outputs": [],
55
+ "source": [
56
+ "upsample=data.resample('h')\n",
57
+ "interpolated=upsample.interpolate(method='linear')\n",
58
+ "interpolated"
59
+ ]
60
+ },
61
+ {
62
+ "cell_type": "code",
63
+ "execution_count": null,
64
+ "id": "b5fd4bf6-b5fd-4144-8efa-3d42d52abc72",
65
+ "metadata": {},
66
+ "outputs": [],
67
+ "source": [
68
+ "interpolated.plot(kind='line')"
69
+ ]
70
+ },
71
+ {
72
+ "cell_type": "code",
73
+ "execution_count": null,
74
+ "id": "fd729d40-2b9f-4cfa-8fcb-8ab950d5051a",
75
+ "metadata": {},
76
+ "outputs": [],
77
+ "source": [
78
+ "upsample=data.resample('h')\n",
79
+ "interpolated=upsample.interpolate(method='spline',order=3)\n",
80
+ "interpolated"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": null,
86
+ "id": "453062ab-4042-4bcd-a465-ecc4375e9cbf",
87
+ "metadata": {},
88
+ "outputs": [],
89
+ "source": [
90
+ "interpolated.plot(kind='line')\n",
91
+ "plt.show()"
92
+ ]
93
+ },
94
+ {
95
+ "cell_type": "markdown",
96
+ "id": "6f6e70bf-15c7-4dfb-b9b1-3deae9a4226e",
97
+ "metadata": {},
98
+ "source": [
99
+ "**Down Sampling and Interpolation**"
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "execution_count": null,
105
+ "id": "bd57a941-82c1-40c8-911c-6cca58ea549b",
106
+ "metadata": {},
107
+ "outputs": [],
108
+ "source": [
109
+ "downsample=interpolated.resample('QE')\n",
110
+ "interpolated=downsample.mean()\n",
111
+ "interpolated"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "code",
116
+ "execution_count": null,
117
+ "id": "f3427633-7ca0-4377-98d1-95099c064159",
118
+ "metadata": {},
119
+ "outputs": [],
120
+ "source": [
121
+ "interpolated.plot(kind='line')"
122
+ ]
123
+ }
124
+ ],
125
+ "metadata": {
126
+ "kernelspec": {
127
+ "display_name": "Python 3 (ipykernel)",
128
+ "language": "python",
129
+ "name": "python3"
130
+ },
131
+ "language_info": {
132
+ "codemirror_mode": {
133
+ "name": "ipython",
134
+ "version": 3
135
+ },
136
+ "file_extension": ".py",
137
+ "mimetype": "text/x-python",
138
+ "name": "python",
139
+ "nbconvert_exporter": "python",
140
+ "pygments_lexer": "ipython3",
141
+ "version": "3.12.4"
142
+ }
143
+ },
144
+ "nbformat": 4,
145
+ "nbformat_minor": 5
146
+ }
@@ -0,0 +1,37 @@
1
+ Month,Sales
2
+ 01-01,266
3
+ 01-02,145.9
4
+ 01-03,183.1
5
+ 01-04,119.3
6
+ 01-05,180.3
7
+ 01-06,168.5
8
+ 01-07,231.8
9
+ 01-08,224.5
10
+ 01-09,192.8
11
+ 1-10,122.9
12
+ 1-11,336.5
13
+ 1-12,185.9
14
+ 02-01,194.3
15
+ 02-02,149.5
16
+ 02-03,210.1
17
+ 02-04,273.3
18
+ 02-05,191.4
19
+ 02-06,287
20
+ 02-07,226
21
+ 02-08,303.6
22
+ 02-09,289.9
23
+ 2-10,421.6
24
+ 2-11,264.5
25
+ 2-12,342.3
26
+ 03-01,339.7
27
+ 03-02,440.4
28
+ 03-03,315.9
29
+ 03-04,439.3
30
+ 03-05,401.3
31
+ 03-06,437.4
32
+ 03-07,575.5
33
+ 03-08,407.6
34
+ 03-09,682
35
+ 3-10,475.3
36
+ 3-11,581.3
37
+ 3-12,646.9
@@ -0,0 +1,173 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "f01bfd82-b491-4e4c-ab74-0eb7709b20b1",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import pandas as pd\n",
11
+ "import numpy as np\n",
12
+ "import matplotlib.pyplot as plt\n",
13
+ "from statsmodels.tsa.stattools import kpss\n",
14
+ "from statsmodels.tsa.seasonal import seasonal_decompose\n",
15
+ "import warnings\n",
16
+ "warnings.filterwarnings(\"ignore\")"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "id": "04a57fe7-20ae-4202-b5fd-7d4f60161871",
23
+ "metadata": {},
24
+ "outputs": [],
25
+ "source": [
26
+ "df = pd.read_csv(\"daily-total-female-births.csv\", parse_dates = ['Date'], index_col='Date')\n",
27
+ "print(f\"Shape: {df.shape}\")\n",
28
+ "df.head()"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": null,
34
+ "id": "8ae68a42-dc21-4fdc-a69d-3c28ae65f146",
35
+ "metadata": {},
36
+ "outputs": [],
37
+ "source": [
38
+ "df.plot()\n",
39
+ "plt.show()"
40
+ ]
41
+ },
42
+ {
43
+ "cell_type": "code",
44
+ "execution_count": null,
45
+ "id": "99bc55d6-f608-4ab3-84f0-f0b9b6e39aa8",
46
+ "metadata": {},
47
+ "outputs": [],
48
+ "source": [
49
+ "x = np.linspace(0, 12, num=200)\n",
50
+ "seasonality = 1.2 * np.sin(2 * np.pi * x / 4)\n",
51
+ "\n",
52
+ "plt.figure(figsize=(10,6))\n",
53
+ "plt.plot(x, seasonality, label = \"Seasonal Component\", color = \"g\")\n",
54
+ "plt.xlabel(\"Time\")\n",
55
+ "plt.ylabel(\"Value\")\n",
56
+ "plt.title(\"Seasonal Signal\")\n",
57
+ "plt.legend()\n",
58
+ "plt.show()"
59
+ ]
60
+ },
61
+ {
62
+ "cell_type": "code",
63
+ "execution_count": null,
64
+ "id": "ea5377ec-67f4-4fc3-b20b-7792b937eb72",
65
+ "metadata": {},
66
+ "outputs": [],
67
+ "source": [
68
+ "df2 = pd.read_csv(\"daily-min-temperatures.csv\", parse_dates = ['Date'], index_col='Date')\n",
69
+ "df2.head()"
70
+ ]
71
+ },
72
+ {
73
+ "cell_type": "code",
74
+ "execution_count": null,
75
+ "id": "a0d10a57-006c-4a59-b7c7-ff0c63bb6e99",
76
+ "metadata": {},
77
+ "outputs": [],
78
+ "source": [
79
+ "df2.plot(title = \"Daily Minimun Temperature\", figsize = (14, 8), legend = None)\n",
80
+ "plt.xlabel(\"Date\")\n",
81
+ "plt.ylabel(\"Temperature in °C\")\n",
82
+ "plt.show()"
83
+ ]
84
+ },
85
+ {
86
+ "cell_type": "code",
87
+ "execution_count": null,
88
+ "id": "1c99e75f-5e45-4485-b54c-3b848fd428ca",
89
+ "metadata": {},
90
+ "outputs": [],
91
+ "source": [
92
+ "def kpss_test(series):\n",
93
+ " statistic, p_value, n_lags, critical_values = kpss(series)\n",
94
+ " print(f\"KPSS Statistic: {statistic:.4f}\")\n",
95
+ " print(f\"p-value: {p_value:.4f}\")\n",
96
+ " print(f\"Number of Lags: {n_lags}\")\n",
97
+ " print(\"Critical Values:\")\n",
98
+ " print(\"\\n\".join([f\"{key} : {value:.4f}\" for key, value in critical_values.items()]))\n",
99
+ " print(f\"Result: The Series is {'not' if p_value < 0.05 else ''} Stationary\")"
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "execution_count": null,
105
+ "id": "67290889-aaf5-464c-8748-7f2e3f797d0c",
106
+ "metadata": {},
107
+ "outputs": [],
108
+ "source": [
109
+ "kpss_test(df)"
110
+ ]
111
+ },
112
+ {
113
+ "cell_type": "code",
114
+ "execution_count": null,
115
+ "id": "421d972b-3f8a-4c54-884b-4b270bf2adfb",
116
+ "metadata": {},
117
+ "outputs": [],
118
+ "source": [
119
+ "kpss_test(df2)"
120
+ ]
121
+ },
122
+ {
123
+ "cell_type": "code",
124
+ "execution_count": null,
125
+ "id": "dd286b94-3867-4045-b3ff-0b5693b0feab",
126
+ "metadata": {},
127
+ "outputs": [],
128
+ "source": [
129
+ "decomposition = seasonal_decompose(df2['Temp'], model = 'additive', period = 365)\n",
130
+ "\n",
131
+ "trend = decomposition.trend\n",
132
+ "seasonal = decomposition.seasonal\n",
133
+ "residual = decomposition.resid\n",
134
+ "\n",
135
+ "plt.figure(figsize = (14,8))\n",
136
+ "plt.subplot(411)\n",
137
+ "plt.plot(df2['Temp'], label = \"Original\", color =\"g\")\n",
138
+ "plt.legend(loc = \"upper left\")\n",
139
+ "plt.subplot(412)\n",
140
+ "plt.plot(trend, label=\"Trend\", color =\"r\")\n",
141
+ "plt.legend(loc=\"upper left\")\n",
142
+ "plt.subplot(413)\n",
143
+ "plt.plot(seasonal, label = \"Seasonal\", color =\"y\")\n",
144
+ "plt.legend(loc = \"upper left\")\n",
145
+ "plt.subplot(414)\n",
146
+ "plt.plot(residual, label=\"Residual\", color =\"lightblue\")\n",
147
+ "plt.legend(loc=\"upper left\")\n",
148
+ "plt.show()"
149
+ ]
150
+ }
151
+ ],
152
+ "metadata": {
153
+ "kernelspec": {
154
+ "display_name": "Python 3 (ipykernel)",
155
+ "language": "python",
156
+ "name": "python3"
157
+ },
158
+ "language_info": {
159
+ "codemirror_mode": {
160
+ "name": "ipython",
161
+ "version": 3
162
+ },
163
+ "file_extension": ".py",
164
+ "mimetype": "text/x-python",
165
+ "name": "python",
166
+ "nbconvert_exporter": "python",
167
+ "pygments_lexer": "ipython3",
168
+ "version": "3.12.4"
169
+ }
170
+ },
171
+ "nbformat": 4,
172
+ "nbformat_minor": 5
173
+ }