noshot 0.3.9__py3-none-any.whl → 0.4.1__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.
- noshot/data/ML TS XAI/TS/10. Seasonal ARIMA Forecasting.ipynb +928 -0
- noshot/data/ML TS XAI/TS/11. Multivariate ARIMA Forecasting.ipynb +1270 -0
- noshot/data/ML TS XAI/TS/6. ACF PACF.ipynb +175 -0
- noshot/data/ML TS XAI/TS/7. Differencing.ipynb +303 -0
- noshot/data/ML TS XAI/TS/8. ARMA Forecasting.ipynb +746 -0
- noshot/data/ML TS XAI/TS/9. ARIMA Forecasting.ipynb +579 -0
- noshot/main.py +18 -18
- noshot/utils/__init__.py +2 -2
- noshot/utils/shell_utils.py +56 -56
- {noshot-0.3.9.dist-info → noshot-0.4.1.dist-info}/METADATA +58 -55
- noshot-0.4.1.dist-info/RECORD +15 -0
- {noshot-0.3.9.dist-info → noshot-0.4.1.dist-info}/WHEEL +1 -1
- {noshot-0.3.9.dist-info → noshot-0.4.1.dist-info/licenses}/LICENSE.txt +20 -20
- noshot/data/ML TS XAI/ML/1. PCA - EDA.ipynb +0 -207
- noshot/data/ML TS XAI/ML/2. KNN Classifier.ipynb +0 -287
- noshot/data/ML TS XAI/ML/3. Linear Discriminant Analysis.ipynb +0 -83
- noshot/data/ML TS XAI/ML/4. Linear Regression.ipynb +0 -117
- noshot/data/ML TS XAI/ML/5. Logistic Regression.ipynb +0 -151
- noshot/data/ML TS XAI/ML/6. Bayesian Classifier.ipynb +0 -89
- noshot/data/ML TS XAI/ML/data/balance-scale.csv +0 -626
- noshot/data/ML TS XAI/ML/data/balance-scale.txt +0 -625
- noshot/data/ML TS XAI/ML/data/machine-data.csv +0 -210
- noshot/data/ML TS XAI/ML/data/wine-dataset.csv +0 -179
- noshot/data/ML TS XAI/ML Additional/Bank.ipynb +0 -74
- noshot/data/ML TS XAI/ML Additional/LR.ipynb +0 -69
- noshot/data/ML TS XAI/ML Additional/ObesityDataSet_raw_and_data_sinthetic.csv +0 -2112
- noshot/data/ML TS XAI/ML Additional/Q4 LR.csv +0 -206
- noshot/data/ML TS XAI/ML Additional/Q7 BANK DETAILS.csv +0 -41189
- noshot/data/ML TS XAI/ML Additional/airfoil.ipynb +0 -69
- noshot/data/ML TS XAI/ML Additional/airfoil_self_noise.dat +0 -1503
- noshot/data/ML TS XAI/ML Additional/obesity.ipynb +0 -78
- noshot/data/ML TS XAI/ML Additional/voronoicode.ipynb +0 -81
- noshot/data/ML TS XAI/ML Lab CIA/1/1.ipynb +0 -133
- noshot/data/ML TS XAI/ML Lab CIA/1/Question.txt +0 -12
- noshot/data/ML TS XAI/ML Lab CIA/1/airfoil_self_noise.dat +0 -1503
- noshot/data/ML TS XAI/ML Lab CIA/2/2.ipynb +0 -139
- noshot/data/ML TS XAI/ML Lab CIA/2/Question.txt +0 -12
- noshot/data/ML TS XAI/ML Lab CIA/2/pop_failures.dat +0 -143
- noshot/data/ML TS XAI/ML Lab CIA/3/3.ipynb +0 -130
- noshot/data/ML TS XAI/ML Lab CIA/3/Qu.txt +0 -1
- noshot/data/ML TS XAI/ML Lab CIA/3/go_track_tracks.csv +0 -164
- noshot/data/ML TS XAI/ML Lab CIA/4/4.ipynb +0 -141
- noshot/data/ML TS XAI/ML Lab CIA/4/Wilt.csv +0 -4340
- noshot/data/ML TS XAI/ML Lab CIA/4/qu.txt +0 -1
- noshot/data/ML TS XAI/TS/1. EDA - Handling Time Series Data.ipynb +0 -247
- noshot/data/ML TS XAI/TS/2. Feature Engineering.ipynb +0 -183
- noshot/data/ML TS XAI/TS/3. Temporal Relationships.ipynb +0 -172
- noshot/data/ML TS XAI/TS/4. Up-Down-Sampling and Interpolation.ipynb +0 -146
- noshot/data/ML TS XAI/TS/5. Stationarity - Trend - Seasonality.ipynb +0 -173
- noshot/data/ML TS XAI/TS/6. Autocorrelation - Partial Autocorrelation.ipynb +0 -77
- noshot/data/ML TS XAI/TS/AllinOne.ipynb +0 -1416
- noshot/data/ML TS XAI/TS/data/daily-min-temperatures.csv +0 -3651
- noshot/data/ML TS XAI/TS/data/daily-total-female-births.csv +0 -366
- noshot/data/ML TS XAI/TS/data/raw_sales.csv +0 -29581
- noshot/data/ML TS XAI/TS/data/shampoo_sales.csv +0 -37
- noshot/data/ML TS XAI/TS Lab CIA/1 - AirPassengers/1 - AirPassengers.ipynb +0 -198
- noshot/data/ML TS XAI/TS Lab CIA/1 - AirPassengers/AirPassengers.csv +0 -145
- noshot/data/ML TS XAI/TS Lab CIA/2 - Daily-total-female-births/2 - daily-total-female-births.ipynb +0 -209
- noshot/data/ML TS XAI/TS Lab CIA/2 - Daily-total-female-births/daily-total-female-births.csv +0 -366
- noshot/data/ML TS XAI/TS Lab CIA/3 - Bill Charge/3 - Bill Charge.ipynb +0 -169
- noshot/data/ML TS XAI/TS Lab CIA/3 - Bill Charge/bill charge.csv +0 -21
- noshot/data/ML TS XAI/TS Lab CIA/4 - Daily min temperatures/4 - daily-min-temperatures.ipynb +0 -181
- noshot/data/ML TS XAI/TS Lab CIA/4 - Daily min temperatures/daily-min-temperatures.csv +0 -3651
- noshot/data/ML TS XAI/TS Lab CIA/5 - shampoo sales/5 - Shampoo sales.ipynb +0 -213
- noshot/data/ML TS XAI/TS Lab CIA/5 - shampoo sales/shampoo_sales.csv +0 -37
- noshot/data/ML TS XAI/TS Lab CIA/Questions TMS 27 Feb 25.pdf +0 -0
- noshot-0.3.9.dist-info/RECORD +0 -62
- {noshot-0.3.9.dist-info → noshot-0.4.1.dist-info}/top_level.txt +0 -0
@@ -1,287 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "markdown",
|
5
|
-
"id": "def24f4a",
|
6
|
-
"metadata": {},
|
7
|
-
"source": [
|
8
|
-
"##### __Balance Scale Dataset__"
|
9
|
-
]
|
10
|
-
},
|
11
|
-
{
|
12
|
-
"cell_type": "code",
|
13
|
-
"execution_count": null,
|
14
|
-
"id": "b4a8b5dc",
|
15
|
-
"metadata": {},
|
16
|
-
"outputs": [],
|
17
|
-
"source": [
|
18
|
-
"from sklearn.neighbors import KNeighborsClassifier\n",
|
19
|
-
"from sklearn.datasets import load_iris\n",
|
20
|
-
"from sklearn.model_selection import train_test_split\n",
|
21
|
-
"from sklearn import metrics\n",
|
22
|
-
"from sklearn.preprocessing import StandardScaler\n",
|
23
|
-
"import sklearn\n",
|
24
|
-
"import pandas as pd\n",
|
25
|
-
"import numpy as np"
|
26
|
-
]
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"cell_type": "code",
|
30
|
-
"execution_count": null,
|
31
|
-
"id": "1c308767",
|
32
|
-
"metadata": {},
|
33
|
-
"outputs": [],
|
34
|
-
"source": [
|
35
|
-
"df = pd.read_csv('data/balance-scale.txt', delimiter = ',', names=['class name','left-weight','left-distance','right-weight','right-distance'])\n",
|
36
|
-
"#df = pd.read_csv('data/balance-scale.csv')\n",
|
37
|
-
"df.head()"
|
38
|
-
]
|
39
|
-
},
|
40
|
-
{
|
41
|
-
"cell_type": "code",
|
42
|
-
"execution_count": null,
|
43
|
-
"id": "23d0288e",
|
44
|
-
"metadata": {},
|
45
|
-
"outputs": [],
|
46
|
-
"source": [
|
47
|
-
"feature = ['left-weight','left-distance','right-weight','right-distance']\n",
|
48
|
-
"x = df.loc[:,feature]\n",
|
49
|
-
"y = df.loc[:,'class name']\n",
|
50
|
-
"x = StandardScaler().fit_transform(x)\n",
|
51
|
-
"X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.4,\n",
|
52
|
-
"random_state = 4)\n",
|
53
|
-
"print (X_train.shape)\n",
|
54
|
-
"print (X_test.shape)\n",
|
55
|
-
"knn = KNeighborsClassifier(n_neighbors = 15)\n",
|
56
|
-
"knn.fit(X_train, y_train) "
|
57
|
-
]
|
58
|
-
},
|
59
|
-
{
|
60
|
-
"cell_type": "code",
|
61
|
-
"execution_count": null,
|
62
|
-
"id": "366c003d",
|
63
|
-
"metadata": {},
|
64
|
-
"outputs": [],
|
65
|
-
"source": [
|
66
|
-
"y_pred = knn.predict(X_test)\n",
|
67
|
-
"print (metrics.accuracy_score(y_test, y_pred))"
|
68
|
-
]
|
69
|
-
},
|
70
|
-
{
|
71
|
-
"cell_type": "markdown",
|
72
|
-
"id": "6702687e",
|
73
|
-
"metadata": {},
|
74
|
-
"source": [
|
75
|
-
"##### __class for [1,1,1,1] = R (predicted)__"
|
76
|
-
]
|
77
|
-
},
|
78
|
-
{
|
79
|
-
"cell_type": "code",
|
80
|
-
"execution_count": null,
|
81
|
-
"id": "22e96c2a",
|
82
|
-
"metadata": {},
|
83
|
-
"outputs": [],
|
84
|
-
"source": [
|
85
|
-
"y_pred = knn.predict(np.array([1,1,1,1]).reshape(1, -1))[0]\n",
|
86
|
-
"print(\"Class Predicted:\", y_pred)"
|
87
|
-
]
|
88
|
-
},
|
89
|
-
{
|
90
|
-
"cell_type": "markdown",
|
91
|
-
"id": "13d70944",
|
92
|
-
"metadata": {},
|
93
|
-
"source": [
|
94
|
-
"##### __Iris Dataset__"
|
95
|
-
]
|
96
|
-
},
|
97
|
-
{
|
98
|
-
"cell_type": "code",
|
99
|
-
"execution_count": null,
|
100
|
-
"id": "3192e255",
|
101
|
-
"metadata": {},
|
102
|
-
"outputs": [],
|
103
|
-
"source": [
|
104
|
-
"def to_category(val):\n",
|
105
|
-
" match val:\n",
|
106
|
-
" case 0: return \"setosa\"\n",
|
107
|
-
" case 1: return \"versicolor\"\n",
|
108
|
-
" case 2: return \"virginica\"\n",
|
109
|
-
"iris = load_iris()\n",
|
110
|
-
"df2 = pd.DataFrame(data=iris.data, columns=iris.feature_names)\n",
|
111
|
-
"df2['class'] = iris.target\n",
|
112
|
-
"df2['class'] = df2['class'].apply(to_category)\n",
|
113
|
-
"print(df2.shape)\n",
|
114
|
-
"df2.head()"
|
115
|
-
]
|
116
|
-
},
|
117
|
-
{
|
118
|
-
"cell_type": "code",
|
119
|
-
"execution_count": null,
|
120
|
-
"id": "4115986d",
|
121
|
-
"metadata": {
|
122
|
-
"scrolled": true
|
123
|
-
},
|
124
|
-
"outputs": [],
|
125
|
-
"source": [
|
126
|
-
"feature = ['sepal length (cm)','sepal width (cm)','petal length (cm)','petal width (cm)']\n",
|
127
|
-
"x = df2.loc[:,feature]\n",
|
128
|
-
"y = df2.loc[:,'class']\n",
|
129
|
-
"x = StandardScaler().fit_transform(x)\n",
|
130
|
-
"X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.4,\n",
|
131
|
-
"random_state = 4)\n",
|
132
|
-
"print (X_train.shape)\n",
|
133
|
-
"print (X_test.shape)\n",
|
134
|
-
"knn = KNeighborsClassifier(n_neighbors = 15)\n",
|
135
|
-
"knn.fit(X_train, y_train) "
|
136
|
-
]
|
137
|
-
},
|
138
|
-
{
|
139
|
-
"cell_type": "code",
|
140
|
-
"execution_count": null,
|
141
|
-
"id": "8252b0f1",
|
142
|
-
"metadata": {},
|
143
|
-
"outputs": [],
|
144
|
-
"source": [
|
145
|
-
"y_pred = knn.predict(X_test)\n",
|
146
|
-
"print (metrics.accuracy_score(y_test, y_pred))"
|
147
|
-
]
|
148
|
-
},
|
149
|
-
{
|
150
|
-
"cell_type": "markdown",
|
151
|
-
"id": "06559281",
|
152
|
-
"metadata": {},
|
153
|
-
"source": [
|
154
|
-
"##### __class for [5.2,3.5,1.1,0.2] = virginica (predicted)__"
|
155
|
-
]
|
156
|
-
},
|
157
|
-
{
|
158
|
-
"cell_type": "code",
|
159
|
-
"execution_count": null,
|
160
|
-
"id": "085896ef",
|
161
|
-
"metadata": {},
|
162
|
-
"outputs": [],
|
163
|
-
"source": [
|
164
|
-
"y_pred = knn.predict(np.array([5.2, 3.5, 1.1, 0.2]).reshape(1, -1))[0]\n",
|
165
|
-
"print(\"Class Predicted:\", y_pred)"
|
166
|
-
]
|
167
|
-
},
|
168
|
-
{
|
169
|
-
"cell_type": "markdown",
|
170
|
-
"id": "cdd56944",
|
171
|
-
"metadata": {},
|
172
|
-
"source": [
|
173
|
-
"##### __Iris Dataset Visualization__"
|
174
|
-
]
|
175
|
-
},
|
176
|
-
{
|
177
|
-
"cell_type": "code",
|
178
|
-
"execution_count": null,
|
179
|
-
"id": "a549df51",
|
180
|
-
"metadata": {},
|
181
|
-
"outputs": [],
|
182
|
-
"source": [
|
183
|
-
"from sklearn.svm import SVC\n",
|
184
|
-
"import numpy as np\n",
|
185
|
-
"import matplotlib.pyplot as plt\n",
|
186
|
-
"from sklearn import svm, datasets\n",
|
187
|
-
"\n",
|
188
|
-
"iris = load_iris()\n",
|
189
|
-
"X = iris.data[:, :2]\n",
|
190
|
-
"y = iris.target\n",
|
191
|
-
"\n",
|
192
|
-
"def make_meshgrid(x, y, h=.02):\n",
|
193
|
-
" x_min, x_max = x.min() - 1, x.max() + 1\n",
|
194
|
-
" y_min, y_max = y.min() - 1, y.max() + 1\n",
|
195
|
-
" xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))\n",
|
196
|
-
" return xx, yy\n",
|
197
|
-
"\n",
|
198
|
-
"def plot_contours(ax, clf, xx, yy, **params):\n",
|
199
|
-
" Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])\n",
|
200
|
-
" Z = Z.reshape(xx.shape)\n",
|
201
|
-
" out = ax.contourf(xx, yy, Z, **params)\n",
|
202
|
-
" return out\n",
|
203
|
-
"\n",
|
204
|
-
"model = svm.SVC(kernel='linear')\n",
|
205
|
-
"clf = model.fit(X, y)\n",
|
206
|
-
"\n",
|
207
|
-
"fig, ax = plt.subplots()\n",
|
208
|
-
"# title for the plots\n",
|
209
|
-
"title = ('Decision surface of linear SVC ')\n",
|
210
|
-
"# Set-up grid for plotting.\n",
|
211
|
-
"X0, X1 = X[:, 0], X[:, 1]\n",
|
212
|
-
"xx, yy = make_meshgrid(X0, X1)\n",
|
213
|
-
"\n",
|
214
|
-
"plot_contours(ax, clf, xx, yy, cmap=plt.cm.coolwarm, alpha=0.8)\n",
|
215
|
-
"ax.scatter(X0, X1, c=y, cmap=plt.cm.coolwarm, s=20, edgecolors='k')\n",
|
216
|
-
"ax.set_ylabel('y label here')\n",
|
217
|
-
"ax.set_xlabel('x label here')\n",
|
218
|
-
"ax.set_xticks(())\n",
|
219
|
-
"ax.set_yticks(())\n",
|
220
|
-
"ax.set_title(title)\n",
|
221
|
-
"#ax.legend()\n",
|
222
|
-
"plt.show()"
|
223
|
-
]
|
224
|
-
},
|
225
|
-
{
|
226
|
-
"cell_type": "code",
|
227
|
-
"execution_count": null,
|
228
|
-
"id": "01719650",
|
229
|
-
"metadata": {},
|
230
|
-
"outputs": [],
|
231
|
-
"source": [
|
232
|
-
"from sklearn.svm import SVC\n",
|
233
|
-
"import numpy as np\n",
|
234
|
-
"import matplotlib.pyplot as plt\n",
|
235
|
-
"from sklearn import svm, datasets\n",
|
236
|
-
"from mpl_toolkits.mplot3d import Axes3D\n",
|
237
|
-
"\n",
|
238
|
-
"iris = datasets.load_iris()\n",
|
239
|
-
"X = iris.data[:, :3] # we only take the first three features.\n",
|
240
|
-
"Y = iris.target\n",
|
241
|
-
"\n",
|
242
|
-
"#make it binary classification problem\n",
|
243
|
-
"X = X[np.logical_or(Y==0,Y==1)]\n",
|
244
|
-
"Y = Y[np.logical_or(Y==0,Y==1)]\n",
|
245
|
-
"\n",
|
246
|
-
"model = svm.SVC(kernel='linear')\n",
|
247
|
-
"clf = model.fit(X, Y)\n",
|
248
|
-
"\n",
|
249
|
-
"# The equation of the separating plane is given by all x so that np.dot(svc.coef_[0], x) + b = 0.\n",
|
250
|
-
"# Solve for w3 (z)\n",
|
251
|
-
"z = lambda x,y: (-clf.intercept_[0]-clf.coef_[0][0]*x -clf.coef_[0][1]*y) / clf.coef_[0][2]\n",
|
252
|
-
"\n",
|
253
|
-
"tmp = np.linspace(-5,5,30)\n",
|
254
|
-
"x,y = np.meshgrid(tmp,tmp)\n",
|
255
|
-
"\n",
|
256
|
-
"fig = plt.figure()\n",
|
257
|
-
"ax = fig.add_subplot(111, projection='3d')\n",
|
258
|
-
"ax.plot3D(X[Y==0,0], X[Y==0,1], X[Y==0,2],'ob')\n",
|
259
|
-
"ax.plot3D(X[Y==1,0], X[Y==1,1], X[Y==1,2],'sr')\n",
|
260
|
-
"ax.plot_surface(x, y, z(x,y))\n",
|
261
|
-
"ax.view_init(30, 60)\n",
|
262
|
-
"plt.show()"
|
263
|
-
]
|
264
|
-
}
|
265
|
-
],
|
266
|
-
"metadata": {
|
267
|
-
"kernelspec": {
|
268
|
-
"display_name": "Python 3 (ipykernel)",
|
269
|
-
"language": "python",
|
270
|
-
"name": "python3"
|
271
|
-
},
|
272
|
-
"language_info": {
|
273
|
-
"codemirror_mode": {
|
274
|
-
"name": "ipython",
|
275
|
-
"version": 3
|
276
|
-
},
|
277
|
-
"file_extension": ".py",
|
278
|
-
"mimetype": "text/x-python",
|
279
|
-
"name": "python",
|
280
|
-
"nbconvert_exporter": "python",
|
281
|
-
"pygments_lexer": "ipython3",
|
282
|
-
"version": "3.12.4"
|
283
|
-
}
|
284
|
-
},
|
285
|
-
"nbformat": 4,
|
286
|
-
"nbformat_minor": 5
|
287
|
-
}
|
@@ -1,83 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "code",
|
5
|
-
"execution_count": null,
|
6
|
-
"id": "96ac04a5-6577-4da4-8454-3b10535351f8",
|
7
|
-
"metadata": {},
|
8
|
-
"outputs": [],
|
9
|
-
"source": [
|
10
|
-
"import matplotlib.pyplot as plt\n",
|
11
|
-
"from sklearn import datasets\n",
|
12
|
-
"from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA\n",
|
13
|
-
"import pandas as pd\n",
|
14
|
-
"import matplotlib.pyplot as plt\n",
|
15
|
-
"from sklearn.preprocessing import StandardScaler"
|
16
|
-
]
|
17
|
-
},
|
18
|
-
{
|
19
|
-
"cell_type": "code",
|
20
|
-
"execution_count": null,
|
21
|
-
"id": "b1ffa4dc-488f-4238-877b-5cbd6fb48e4e",
|
22
|
-
"metadata": {},
|
23
|
-
"outputs": [],
|
24
|
-
"source": [
|
25
|
-
"df = pd.read_table('data/balance-scale.txt', delimiter = \",\", names=['class name','left-weight','left-distance','right-weight','right-distance'])\n",
|
26
|
-
"#df = pd.read_csv('data/balance-scale.csv')\n",
|
27
|
-
"df.head()"
|
28
|
-
]
|
29
|
-
},
|
30
|
-
{
|
31
|
-
"cell_type": "markdown",
|
32
|
-
"id": "ac328950-540f-4a27-b9d4-0880058064f5",
|
33
|
-
"metadata": {},
|
34
|
-
"source": [
|
35
|
-
"##### __LDA__"
|
36
|
-
]
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"cell_type": "code",
|
40
|
-
"execution_count": null,
|
41
|
-
"id": "7a947959-791f-4ffe-95f0-e300d97cf179",
|
42
|
-
"metadata": {},
|
43
|
-
"outputs": [],
|
44
|
-
"source": [
|
45
|
-
"feature = ['left-weight','left-distance','right-weight','right-distance']\n",
|
46
|
-
"x = df.loc[:,feature]\n",
|
47
|
-
"y = df.loc[:,'class name']\n",
|
48
|
-
"lda = LDA(n_components=2)\n",
|
49
|
-
"lda_X = lda.fit(x,y).transform(x)\n",
|
50
|
-
"plt.scatter(lda_X[y == 'L', 0], lda_X[y == 'L', 1], s =50, c = 'orange',\n",
|
51
|
-
"label = 'L')\n",
|
52
|
-
"plt.scatter(lda_X[y == 'B', 0], lda_X[y == 'B', 1], s =50, c = 'blue',\n",
|
53
|
-
"label = 'B')\n",
|
54
|
-
"\n",
|
55
|
-
"16\n",
|
56
|
-
"plt.scatter(lda_X[y == 'R', 0], lda_X[y == 'R', 1], s =50, c = 'green',\n",
|
57
|
-
"label = 'R')\n",
|
58
|
-
"plt.title('LDA plot for cmc DataSet')"
|
59
|
-
]
|
60
|
-
}
|
61
|
-
],
|
62
|
-
"metadata": {
|
63
|
-
"kernelspec": {
|
64
|
-
"display_name": "Python 3 (ipykernel)",
|
65
|
-
"language": "python",
|
66
|
-
"name": "python3"
|
67
|
-
},
|
68
|
-
"language_info": {
|
69
|
-
"codemirror_mode": {
|
70
|
-
"name": "ipython",
|
71
|
-
"version": 3
|
72
|
-
},
|
73
|
-
"file_extension": ".py",
|
74
|
-
"mimetype": "text/x-python",
|
75
|
-
"name": "python",
|
76
|
-
"nbconvert_exporter": "python",
|
77
|
-
"pygments_lexer": "ipython3",
|
78
|
-
"version": "3.12.4"
|
79
|
-
}
|
80
|
-
},
|
81
|
-
"nbformat": 4,
|
82
|
-
"nbformat_minor": 5
|
83
|
-
}
|
@@ -1,117 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "code",
|
5
|
-
"execution_count": null,
|
6
|
-
"id": "2d42ca1a-531d-4d5b-aee4-a489d5033d1b",
|
7
|
-
"metadata": {},
|
8
|
-
"outputs": [],
|
9
|
-
"source": [
|
10
|
-
"import pandas as pd\n",
|
11
|
-
"import matplotlib.pyplot as plt\n",
|
12
|
-
"from sklearn.model_selection import train_test_split\n",
|
13
|
-
"from sklearn.linear_model import LinearRegression\n",
|
14
|
-
"from sklearn.metrics import r2_score"
|
15
|
-
]
|
16
|
-
},
|
17
|
-
{
|
18
|
-
"cell_type": "code",
|
19
|
-
"execution_count": null,
|
20
|
-
"id": "f81220bc-5415-4b02-b2fd-fd5a8ff8c97a",
|
21
|
-
"metadata": {},
|
22
|
-
"outputs": [],
|
23
|
-
"source": [
|
24
|
-
"df = pd.read_csv('data/machine-data.csv')\n",
|
25
|
-
"df.head()"
|
26
|
-
]
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"cell_type": "code",
|
30
|
-
"execution_count": null,
|
31
|
-
"id": "958f3a04-3ae7-442b-a6e7-9134b9c5aeb3",
|
32
|
-
"metadata": {},
|
33
|
-
"outputs": [],
|
34
|
-
"source": [
|
35
|
-
"x=df.iloc[:,3:4].values\n",
|
36
|
-
"y=df.iloc[:,8].values\n",
|
37
|
-
"\n",
|
38
|
-
"X_train, X_test, y_train, y_test = train_test_split(x, y, test_size = 0.2, random_state = 0)\n",
|
39
|
-
"regressor = LinearRegression()\n",
|
40
|
-
"regressor.fit(X_train, y_train)\n",
|
41
|
-
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None)"
|
42
|
-
]
|
43
|
-
},
|
44
|
-
{
|
45
|
-
"cell_type": "code",
|
46
|
-
"execution_count": null,
|
47
|
-
"id": "5b15fa5c-5c78-436b-8f33-4f431c797788",
|
48
|
-
"metadata": {},
|
49
|
-
"outputs": [],
|
50
|
-
"source": [
|
51
|
-
"y_pred = regressor.predict(X_test)\n",
|
52
|
-
"y_pred_train = regressor.predict(X_train)\n",
|
53
|
-
"print(\"Model Score: \", regressor.score(X_test, y_test))\n",
|
54
|
-
"print(\"R_square score: \", r2_score(y_test,y_pred))"
|
55
|
-
]
|
56
|
-
},
|
57
|
-
{
|
58
|
-
"cell_type": "code",
|
59
|
-
"execution_count": null,
|
60
|
-
"id": "b044ea95-014e-466b-b036-8ba9f96e3910",
|
61
|
-
"metadata": {},
|
62
|
-
"outputs": [],
|
63
|
-
"source": [
|
64
|
-
"plt.scatter(X_train, y_train, color = 'red')\n",
|
65
|
-
"plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
|
66
|
-
"plt.title('Y vs X (Training set)')\n",
|
67
|
-
"plt.xlabel('X')\n",
|
68
|
-
"plt.ylabel('Y')\n",
|
69
|
-
"plt.show()\n",
|
70
|
-
"plt.scatter(X_test, y_test, color = 'red')\n",
|
71
|
-
"plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
|
72
|
-
"plt.title('Y vs X (Test set)')\n",
|
73
|
-
"plt.xlabel('X')"
|
74
|
-
]
|
75
|
-
},
|
76
|
-
{
|
77
|
-
"cell_type": "code",
|
78
|
-
"execution_count": null,
|
79
|
-
"id": "33c64414-d432-439e-a976-d28a9b4c3f2a",
|
80
|
-
"metadata": {},
|
81
|
-
"outputs": [],
|
82
|
-
"source": [
|
83
|
-
"plt.ylabel('Y')\n",
|
84
|
-
"X_future_expereince = [[2],[4]]\n",
|
85
|
-
"print (\"Prediction :\", regressor.predict(X_future_expereince))\n",
|
86
|
-
"plt.scatter(X_future_expereince, regressor.predict(X_future_expereince),\n",
|
87
|
-
"color = 'red')\n",
|
88
|
-
"plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
|
89
|
-
"plt.title('Y vs X (Test set)')\n",
|
90
|
-
"plt.xlabel('X')\n",
|
91
|
-
"plt.ylabel('Y')\n",
|
92
|
-
"plt.show()"
|
93
|
-
]
|
94
|
-
}
|
95
|
-
],
|
96
|
-
"metadata": {
|
97
|
-
"kernelspec": {
|
98
|
-
"display_name": "Python 3 (ipykernel)",
|
99
|
-
"language": "python",
|
100
|
-
"name": "python3"
|
101
|
-
},
|
102
|
-
"language_info": {
|
103
|
-
"codemirror_mode": {
|
104
|
-
"name": "ipython",
|
105
|
-
"version": 3
|
106
|
-
},
|
107
|
-
"file_extension": ".py",
|
108
|
-
"mimetype": "text/x-python",
|
109
|
-
"name": "python",
|
110
|
-
"nbconvert_exporter": "python",
|
111
|
-
"pygments_lexer": "ipython3",
|
112
|
-
"version": "3.12.4"
|
113
|
-
}
|
114
|
-
},
|
115
|
-
"nbformat": 4,
|
116
|
-
"nbformat_minor": 5
|
117
|
-
}
|
@@ -1,151 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "code",
|
5
|
-
"execution_count": null,
|
6
|
-
"id": "0fcc8bb7-4d22-4d3b-b58a-302bb24f8f2e",
|
7
|
-
"metadata": {},
|
8
|
-
"outputs": [],
|
9
|
-
"source": [
|
10
|
-
"import itertools\n",
|
11
|
-
"import numpy as np\n",
|
12
|
-
"import pandas as pd\n",
|
13
|
-
"import matplotlib.pyplot as plt\n",
|
14
|
-
"from sklearn import linear_model,datasets\n",
|
15
|
-
"from sklearn.model_selection import train_test_split\n",
|
16
|
-
"from sklearn.metrics import confusion_matrix\n",
|
17
|
-
"import warnings\n",
|
18
|
-
"warnings.filterwarnings('ignore')"
|
19
|
-
]
|
20
|
-
},
|
21
|
-
{
|
22
|
-
"cell_type": "code",
|
23
|
-
"execution_count": null,
|
24
|
-
"id": "d28e507b-fb15-4058-a161-656859a27c65",
|
25
|
-
"metadata": {},
|
26
|
-
"outputs": [],
|
27
|
-
"source": [
|
28
|
-
"wine = pd.read_csv('data/wine-dataset.csv')\n",
|
29
|
-
"print(wine.shape)"
|
30
|
-
]
|
31
|
-
},
|
32
|
-
{
|
33
|
-
"cell_type": "code",
|
34
|
-
"execution_count": null,
|
35
|
-
"id": "c4e953da-6941-43f2-a9ce-aab907876d45",
|
36
|
-
"metadata": {},
|
37
|
-
"outputs": [],
|
38
|
-
"source": [
|
39
|
-
"wine.columns"
|
40
|
-
]
|
41
|
-
},
|
42
|
-
{
|
43
|
-
"cell_type": "code",
|
44
|
-
"execution_count": null,
|
45
|
-
"id": "9ee44a66-dc4a-4c79-9dab-eec60669dd8b",
|
46
|
-
"metadata": {},
|
47
|
-
"outputs": [],
|
48
|
-
"source": [
|
49
|
-
"X = wine.iloc[:, :13]\n",
|
50
|
-
"X.head()"
|
51
|
-
]
|
52
|
-
},
|
53
|
-
{
|
54
|
-
"cell_type": "code",
|
55
|
-
"execution_count": null,
|
56
|
-
"id": "5cfd2fe6-3825-4d95-b606-3b3e2ef685b2",
|
57
|
-
"metadata": {},
|
58
|
-
"outputs": [],
|
59
|
-
"source": [
|
60
|
-
"y = wine.iloc[:, 13]\n",
|
61
|
-
"y"
|
62
|
-
]
|
63
|
-
},
|
64
|
-
{
|
65
|
-
"cell_type": "code",
|
66
|
-
"execution_count": null,
|
67
|
-
"id": "bd9d60dd-8272-46b4-8335-69d9751ed0c7",
|
68
|
-
"metadata": {},
|
69
|
-
"outputs": [],
|
70
|
-
"source": [
|
71
|
-
"X_train,X_test,y_train,y_test = train_test_split(X, y, test_size=0.30, random_state=7)\n",
|
72
|
-
"\n",
|
73
|
-
"log_reg_model = linear_model.LogisticRegression()\n",
|
74
|
-
"log_reg_model.fit(X_train,y_train)"
|
75
|
-
]
|
76
|
-
},
|
77
|
-
{
|
78
|
-
"cell_type": "code",
|
79
|
-
"execution_count": null,
|
80
|
-
"id": "7c8fca42-c8d8-4334-9cc4-da4f5e1b0a1e",
|
81
|
-
"metadata": {},
|
82
|
-
"outputs": [],
|
83
|
-
"source": [
|
84
|
-
"log_reg_base_score = log_reg_model.score(X_test,y_test)\n",
|
85
|
-
"print(\"The score for the Logistic Regression Model is : \", log_reg_base_score)"
|
86
|
-
]
|
87
|
-
},
|
88
|
-
{
|
89
|
-
"cell_type": "code",
|
90
|
-
"execution_count": null,
|
91
|
-
"id": "61bbb23e-cb29-41ae-9ea3-82e8d465c7f2",
|
92
|
-
"metadata": {},
|
93
|
-
"outputs": [],
|
94
|
-
"source": [
|
95
|
-
"cm = confusion_matrix(y_test, log_reg_model.predict(X_test))\n",
|
96
|
-
"print(cm)"
|
97
|
-
]
|
98
|
-
},
|
99
|
-
{
|
100
|
-
"cell_type": "code",
|
101
|
-
"execution_count": null,
|
102
|
-
"id": "600ec8f2-34e1-4be7-8ef5-fe53ff673f41",
|
103
|
-
"metadata": {
|
104
|
-
"scrolled": true
|
105
|
-
},
|
106
|
-
"outputs": [],
|
107
|
-
"source": [
|
108
|
-
"X = X.iloc[:, :2]\n",
|
109
|
-
"Y = y\n",
|
110
|
-
"\n",
|
111
|
-
"log_reg_model.fit(X,Y)\n",
|
112
|
-
"x_min, x_max = X.iloc[:, 0].min() - .5, X.iloc[:, 0].max() + .5\n",
|
113
|
-
"y_min, y_max = X.iloc[:, 1].min() - .5, X.iloc[:, 1].max() + .5\n",
|
114
|
-
"xx, yy = np.meshgrid(np.arange(x_min, x_max, .01), np.arange(y_min, y_max, .01))\n",
|
115
|
-
"Z = log_reg_model.predict(np.c_[xx.ravel(), yy.ravel()])\n",
|
116
|
-
"Z = Z.reshape(xx.shape)\n",
|
117
|
-
"plt.figure(1, figsize = (4, 3))\n",
|
118
|
-
"plt.pcolormesh(xx, yy, Z, cmap = plt.cm.Paired)\n",
|
119
|
-
"plt.scatter(X.iloc[:, 0], X.iloc[:, 1], c = Y, edgecolors = 'k', cmap = plt.cm.Paired)\n",
|
120
|
-
"plt.xlabel('X')\n",
|
121
|
-
"plt.ylabel('Y')\n",
|
122
|
-
"plt.xlim(xx.min(), xx.max())\n",
|
123
|
-
"plt.ylim(yy.min(), yy.max())\n",
|
124
|
-
"plt.xticks(())\n",
|
125
|
-
"plt.yticks(())\n",
|
126
|
-
"plt.show()"
|
127
|
-
]
|
128
|
-
}
|
129
|
-
],
|
130
|
-
"metadata": {
|
131
|
-
"kernelspec": {
|
132
|
-
"display_name": "Python 3 (ipykernel)",
|
133
|
-
"language": "python",
|
134
|
-
"name": "python3"
|
135
|
-
},
|
136
|
-
"language_info": {
|
137
|
-
"codemirror_mode": {
|
138
|
-
"name": "ipython",
|
139
|
-
"version": 3
|
140
|
-
},
|
141
|
-
"file_extension": ".py",
|
142
|
-
"mimetype": "text/x-python",
|
143
|
-
"name": "python",
|
144
|
-
"nbconvert_exporter": "python",
|
145
|
-
"pygments_lexer": "ipython3",
|
146
|
-
"version": "3.12.4"
|
147
|
-
}
|
148
|
-
},
|
149
|
-
"nbformat": 4,
|
150
|
-
"nbformat_minor": 5
|
151
|
-
}
|