noshot 0.4.0__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.
Files changed (54) hide show
  1. noshot/data/ML TS XAI/TS/10. Seasonal ARIMA Forecasting.ipynb +928 -0
  2. noshot/data/ML TS XAI/TS/11. Multivariate ARIMA Forecasting.ipynb +1270 -0
  3. noshot/data/ML TS XAI/TS/6. ACF PACF.ipynb +175 -0
  4. noshot/data/ML TS XAI/TS/7. Differencing.ipynb +303 -0
  5. noshot/data/ML TS XAI/TS/8. ARMA Forecasting.ipynb +746 -0
  6. noshot/data/ML TS XAI/TS/9. ARIMA Forecasting.ipynb +579 -0
  7. noshot/main.py +18 -18
  8. noshot/utils/__init__.py +2 -2
  9. noshot/utils/shell_utils.py +56 -56
  10. {noshot-0.4.0.dist-info → noshot-0.4.1.dist-info}/METADATA +58 -55
  11. noshot-0.4.1.dist-info/RECORD +15 -0
  12. {noshot-0.4.0.dist-info → noshot-0.4.1.dist-info}/WHEEL +1 -1
  13. {noshot-0.4.0.dist-info → noshot-0.4.1.dist-info/licenses}/LICENSE.txt +20 -20
  14. noshot/data/ML TS XAI/CIA-1-Delhi Boy.ipynb +0 -535
  15. noshot/data/ML TS XAI/Football Player/4.ipynb +0 -395
  16. noshot/data/ML TS XAI/ML/1. PCA - EDA.ipynb +0 -207
  17. noshot/data/ML TS XAI/ML/2. KNN Classifier.ipynb +0 -287
  18. noshot/data/ML TS XAI/ML/3. Linear Discriminant Analysis.ipynb +0 -83
  19. noshot/data/ML TS XAI/ML/4. Linear Regression.ipynb +0 -117
  20. noshot/data/ML TS XAI/ML/5. Logistic Regression.ipynb +0 -151
  21. noshot/data/ML TS XAI/ML/6. Bayesian Classifier.ipynb +0 -89
  22. noshot/data/ML TS XAI/ML/data/balance-scale.csv +0 -626
  23. noshot/data/ML TS XAI/ML/data/balance-scale.txt +0 -625
  24. noshot/data/ML TS XAI/ML/data/machine-data.csv +0 -210
  25. noshot/data/ML TS XAI/ML/data/wine-dataset.csv +0 -179
  26. noshot/data/ML TS XAI/ML Additional/Bank.ipynb +0 -74
  27. noshot/data/ML TS XAI/ML Additional/LR.ipynb +0 -69
  28. noshot/data/ML TS XAI/ML Additional/ObesityDataSet_raw_and_data_sinthetic.csv +0 -2112
  29. noshot/data/ML TS XAI/ML Additional/Q4 LR.csv +0 -206
  30. noshot/data/ML TS XAI/ML Additional/Q7 BANK DETAILS.csv +0 -41189
  31. noshot/data/ML TS XAI/ML Additional/airfoil.ipynb +0 -69
  32. noshot/data/ML TS XAI/ML Additional/airfoil_self_noise.dat +0 -1503
  33. noshot/data/ML TS XAI/ML Additional/obesity.ipynb +0 -78
  34. noshot/data/ML TS XAI/ML Additional/voronoicode.ipynb +0 -81
  35. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/1/1.ipynb +0 -133
  36. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/1/Question.txt +0 -12
  37. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/1/airfoil_self_noise.dat +0 -1503
  38. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/2/2.ipynb +0 -139
  39. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/2/Question.txt +0 -12
  40. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/2/pop_failures.dat +0 -143
  41. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/3/3.ipynb +0 -130
  42. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/3/Qu.txt +0 -1
  43. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/3/go_track_tracks.csv +0 -164
  44. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/4/4.ipynb +0 -141
  45. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/4/Wilt.csv +0 -4340
  46. noshot/data/ML TS XAI/ML Lab CIA - Healthy Class/4/qu.txt +0 -1
  47. noshot/data/ML TS XAI/ML Lab CIA - Our Class/AllinOne.ipynb +0 -1
  48. noshot/data/ML TS XAI/ML Lab CIA - Our Class/Heart-Disease-UCI-0.ipynb +0 -886
  49. noshot/data/ML TS XAI/ML Lab CIA - Our Class/Housing-0.ipynb +0 -292
  50. noshot/data/ML TS XAI/ML Lab CIA - Our Class/Lab Code Ex 1-4.ipynb +0 -1
  51. noshot/data/ML TS XAI/ML Lab CIA - Our Class/data/Housing.csv +0 -546
  52. noshot/data/ML TS XAI/ML Lab CIA - Our Class/data/heart_disease_uci.csv +0 -921
  53. noshot-0.4.0.dist-info/RECORD +0 -48
  54. {noshot-0.4.0.dist-info → noshot-0.4.1.dist-info}/top_level.txt +0 -0
@@ -1,207 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "id": "8c414eda",
6
- "metadata": {},
7
- "source": [
8
- "##### __Machine learnings Laboratory First Lab Basic EDA and Principle components analysis__"
9
- ]
10
- },
11
- {
12
- "cell_type": "code",
13
- "execution_count": null,
14
- "id": "1919dce4",
15
- "metadata": {},
16
- "outputs": [],
17
- "source": [
18
- "import pandas as pd\n",
19
- "import numpy as np\n",
20
- "import matplotlib.pyplot as plt\n",
21
- "from sklearn.preprocessing import StandardScaler\n",
22
- "from sklearn.decomposition import PCA\n",
23
- "import warnings\n",
24
- "warnings.filterwarnings('ignore')"
25
- ]
26
- },
27
- {
28
- "cell_type": "code",
29
- "execution_count": null,
30
- "id": "459c19c9",
31
- "metadata": {},
32
- "outputs": [],
33
- "source": [
34
- "df = pd.read_table('data/balance-scale.txt', delimiter = ',', names = ['class name', 'left-weight', 'left-distance', 'right-weight', 'right-distance'])\n",
35
- "#df = pd.read_csv('data/balance-scale.csv')\n",
36
- "df.head()"
37
- ]
38
- },
39
- {
40
- "cell_type": "code",
41
- "execution_count": null,
42
- "id": "4a1f3399",
43
- "metadata": {},
44
- "outputs": [],
45
- "source": [
46
- "print(\"Shape\\t Size\")\n",
47
- "print(df.shape, df.size)\n",
48
- "df.dtypes"
49
- ]
50
- },
51
- {
52
- "cell_type": "code",
53
- "execution_count": null,
54
- "id": "ceb17e01",
55
- "metadata": {},
56
- "outputs": [],
57
- "source": [
58
- "df.describe()"
59
- ]
60
- },
61
- {
62
- "cell_type": "code",
63
- "execution_count": null,
64
- "id": "c3950e04",
65
- "metadata": {},
66
- "outputs": [],
67
- "source": [
68
- "df.info()"
69
- ]
70
- },
71
- {
72
- "cell_type": "code",
73
- "execution_count": null,
74
- "id": "e242d2e1",
75
- "metadata": {},
76
- "outputs": [],
77
- "source": [
78
- "plt.hist(df['class name'], color = 'green', label = 'Frequency Distribution')\n",
79
- "plt.legend()\n",
80
- "plt.title(\"Class Wise Count ['L', 'B', 'R']\")\n",
81
- "plt.show()"
82
- ]
83
- },
84
- {
85
- "cell_type": "code",
86
- "execution_count": null,
87
- "id": "37654636",
88
- "metadata": {},
89
- "outputs": [],
90
- "source": [
91
- "fig, axs = plt.subplots(2,2)\n",
92
- "axs[0][0].hist(df['left-weight'], color = 'orange', label = 'Left-Weight')\n",
93
- "axs[0][1].hist(df['left-distance'], color = 'red', label = 'Lefft-distance')\n",
94
- "axs[1][0].hist(df['right-weight'], color = 'green',label = 'right-weight')\n",
95
- "axs[1][1].hist(df['right-distance'], color = 'indigo', label = 'right-distance')\n",
96
- "fig.legend(loc = 'upper left')\n",
97
- "fig.suptitle(\"Histogram For Features\")"
98
- ]
99
- },
100
- {
101
- "cell_type": "markdown",
102
- "id": "3b033918",
103
- "metadata": {},
104
- "source": [
105
- "##### __PCA__"
106
- ]
107
- },
108
- {
109
- "cell_type": "code",
110
- "execution_count": null,
111
- "id": "b9d4bb7e",
112
- "metadata": {},
113
- "outputs": [],
114
- "source": [
115
- "feature = ['left-weight','left-distance','right-weight','right-distance']\n",
116
- "x = df.loc[:, feature]\n",
117
- "y = df.loc[:, 'class name']"
118
- ]
119
- },
120
- {
121
- "cell_type": "code",
122
- "execution_count": null,
123
- "id": "de2b55cc",
124
- "metadata": {},
125
- "outputs": [],
126
- "source": [
127
- "x = StandardScaler().fit_transform(x)\n",
128
- "pca = PCA(n_components = 2)\n",
129
- "pct = pca.fit_transform(x)"
130
- ]
131
- },
132
- {
133
- "cell_type": "code",
134
- "execution_count": null,
135
- "id": "06bf0d31",
136
- "metadata": {},
137
- "outputs": [],
138
- "source": [
139
- "principal_df = pd.DataFrame(pct,columns=['pc1','pc2'])\n",
140
- "print(\"principal-df:\\n\",principal_df)"
141
- ]
142
- },
143
- {
144
- "cell_type": "code",
145
- "execution_count": null,
146
- "id": "7dab85de",
147
- "metadata": {},
148
- "outputs": [],
149
- "source": [
150
- "finaldf= pd.concat([principal_df,df[['class name']]],axis=1)\n",
151
- "print(\"finaldf:\\n\",finaldf)"
152
- ]
153
- },
154
- {
155
- "cell_type": "code",
156
- "execution_count": null,
157
- "id": "026ab3b1",
158
- "metadata": {},
159
- "outputs": [],
160
- "source": [
161
- "finaldf.head()"
162
- ]
163
- },
164
- {
165
- "cell_type": "code",
166
- "execution_count": null,
167
- "id": "53d0455b",
168
- "metadata": {},
169
- "outputs": [],
170
- "source": [
171
- "fig = plt.figure(figsize = (8, 8))\n",
172
- "ax = fig.add_subplot(1, 1, 1)\n",
173
- "ax.set_xlabel('Principal Component 1', fontsize = 15)\n",
174
- "ax.set_ylabel('Principal Component 2', fontsize = 15)\n",
175
- "ax.set_title('2 component PCA', fontsize = 20)\n",
176
- "targets = ['L','B','R']\n",
177
- "colors = ['r', 'g','b']\n",
178
- "for target, color in zip(targets, colors):\n",
179
- " indicesToKeep = finaldf['class name'] == target\n",
180
- " ax.scatter(finaldf.loc[indicesToKeep, 'pc1'], finaldf.loc[indicesToKeep, 'pc2'], c = color, s = 50)\n",
181
- "ax.legend(targets)\n",
182
- "ax.grid()"
183
- ]
184
- }
185
- ],
186
- "metadata": {
187
- "kernelspec": {
188
- "display_name": "Python 3 (ipykernel)",
189
- "language": "python",
190
- "name": "python3"
191
- },
192
- "language_info": {
193
- "codemirror_mode": {
194
- "name": "ipython",
195
- "version": 3
196
- },
197
- "file_extension": ".py",
198
- "mimetype": "text/x-python",
199
- "name": "python",
200
- "nbconvert_exporter": "python",
201
- "pygments_lexer": "ipython3",
202
- "version": "3.12.4"
203
- }
204
- },
205
- "nbformat": 4,
206
- "nbformat_minor": 5
207
- }
@@ -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
- }