noshot 10.0.0__py3-none-any.whl → 12.0.0__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 (74) hide show
  1. noshot/data/DLE FSD BDA/DLE/1. DNN (Image Classification).ipynb +389 -0
  2. noshot/data/DLE FSD BDA/DLE/2. DNN vs CNN.ipynb +516 -0
  3. noshot/data/DLE FSD BDA/DLE/3. CNN (Object Detecrion).ipynb +259 -0
  4. noshot/data/DLE FSD BDA/DLE/4. FCN (Image Segmentaion).ipynb +274 -0
  5. noshot/main.py +3 -3
  6. {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/METADATA +1 -1
  7. noshot-12.0.0.dist-info/RECORD +13 -0
  8. {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/WHEEL +1 -1
  9. noshot/data/ML TS XAI/ML/CNN(Image_for_Folders_5).ipynb +0 -201
  10. noshot/data/ML TS XAI/ML/CNN(Image_form_Folder_2).ipynb +0 -201
  11. noshot/data/ML TS XAI/ML/Json Codes/ML LAB CIA 2.ipynb +0 -409
  12. noshot/data/ML TS XAI/ML/ML 1/1. EDA-PCA (Balance Scale Dataset).ipynb +0 -147
  13. noshot/data/ML TS XAI/ML/ML 1/1. EDA-PCA (Rice Dataset).ipynb +0 -181
  14. noshot/data/ML TS XAI/ML/ML 1/10. HMM Veterbi.ipynb +0 -152
  15. noshot/data/ML TS XAI/ML/ML 1/2. KNN (Balance Scale Dataset).ipynb +0 -117
  16. noshot/data/ML TS XAI/ML/ML 1/2. KNN (Iris Dataset).ipynb +0 -156
  17. noshot/data/ML TS XAI/ML/ML 1/2. KNN (Sobar-72 Dataset).ipynb +0 -215
  18. noshot/data/ML TS XAI/ML/ML 1/3. LDA (Balance Scale Dataset).ipynb +0 -78
  19. noshot/data/ML TS XAI/ML/ML 1/3. LDA (NPHA Doctor Visits Dataset).ipynb +0 -114
  20. noshot/data/ML TS XAI/ML/ML 1/4. Linear Regression (Machine Dataset).ipynb +0 -115
  21. noshot/data/ML TS XAI/ML/ML 1/4. Linear Regression (Real Estate Dataset).ipynb +0 -146
  22. noshot/data/ML TS XAI/ML/ML 1/5. Logistic Regression (Magic04 Dataset).ipynb +0 -130
  23. noshot/data/ML TS XAI/ML/ML 1/5. Logistic Regression (Wine Dataset).ipynb +0 -112
  24. noshot/data/ML TS XAI/ML/ML 1/6. Naive Bayes Classifier (Agaricus Lepiota Dataset).ipynb +0 -118
  25. noshot/data/ML TS XAI/ML/ML 1/6. Naive Bayes Classifier (Wine Dataset).ipynb +0 -89
  26. noshot/data/ML TS XAI/ML/ML 1/7. SVM (Rice Dataset).ipynb +0 -120
  27. noshot/data/ML TS XAI/ML/ML 1/8. FeedForward NN (Sobar72 Dataset).ipynb +0 -262
  28. noshot/data/ML TS XAI/ML/ML 1/9. CNN (Cifar10 Dataset).ipynb +0 -156
  29. noshot/data/ML TS XAI/ML/ML 2/1. PCA.ipynb +0 -162
  30. noshot/data/ML TS XAI/ML/ML 2/10. CNN.ipynb +0 -100
  31. noshot/data/ML TS XAI/ML/ML 2/11. HMM.ipynb +0 -336
  32. noshot/data/ML TS XAI/ML/ML 2/2. KNN.ipynb +0 -149
  33. noshot/data/ML TS XAI/ML/ML 2/3. LDA.ipynb +0 -132
  34. noshot/data/ML TS XAI/ML/ML 2/4. Linear Regression.ipynb +0 -86
  35. noshot/data/ML TS XAI/ML/ML 2/5. Logistic Regression.ipynb +0 -115
  36. noshot/data/ML TS XAI/ML/ML 2/6. Naive Bayes (Titanic).ipynb +0 -196
  37. noshot/data/ML TS XAI/ML/ML 2/6. Naive Bayes (Wine).ipynb +0 -98
  38. noshot/data/ML TS XAI/ML/ML 2/7. SVM Linear.ipynb +0 -109
  39. noshot/data/ML TS XAI/ML/ML 2/8. SVM Non-Linear.ipynb +0 -195
  40. noshot/data/ML TS XAI/ML/ML 2/9. FNN With Regularization.ipynb +0 -189
  41. noshot/data/ML TS XAI/ML/ML 2/9. FNN Without Regularization.ipynb +0 -197
  42. noshot/data/ML TS XAI/ML/ML 2/All in One Lab CIA 1 Q.ipynb +0 -1087
  43. noshot/data/ML TS XAI/ML/ML 3 (Latest)/1. PCA EDA.ipynb +0 -274
  44. noshot/data/ML TS XAI/ML/ML 3 (Latest)/10. CNN.ipynb +0 -170
  45. noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 2.ipynb +0 -1087
  46. noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 3.ipynb +0 -178
  47. noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 4.ipynb +0 -185
  48. noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM.ipynb +0 -106
  49. noshot/data/ML TS XAI/ML/ML 3 (Latest)/2. KNN.ipynb +0 -177
  50. noshot/data/ML TS XAI/ML/ML 3 (Latest)/3. LDA.ipynb +0 -195
  51. noshot/data/ML TS XAI/ML/ML 3 (Latest)/4. Linear Regression.ipynb +0 -267
  52. noshot/data/ML TS XAI/ML/ML 3 (Latest)/5. Logistic Regression.ipynb +0 -104
  53. noshot/data/ML TS XAI/ML/ML 3 (Latest)/6. Bayesian Classifier.ipynb +0 -109
  54. noshot/data/ML TS XAI/ML/ML 3 (Latest)/7. SVM.ipynb +0 -220
  55. noshot/data/ML TS XAI/ML/ML 3 (Latest)/8. MLP.ipynb +0 -99
  56. noshot/data/ML TS XAI/ML/ML 3 (Latest)/9. Ridge - Lasso.ipynb +0 -211
  57. noshot/data/ML TS XAI/ML/ML 3 (Latest)/9. Ridge Lasso 2.ipynb +0 -99
  58. noshot/data/ML TS XAI/ML/ML 3 (Latest)/Image Load Example.ipynb +0 -118
  59. noshot/data/ML TS XAI/ML/ML 3 (Latest)/Updated_Untitled.ipynb +0 -603
  60. noshot/data/ML TS XAI/ML/ML Lab AllinOne.ipynb +0 -961
  61. noshot/data/ML TS XAI/ML/ML Lab H Sec/1. Iris Dataset (Softmax vs Sigmoid).ipynb +0 -231
  62. noshot/data/ML TS XAI/ML/ML Lab H Sec/2. Student Dataset (Overfit vs Regularized).ipynb +0 -269
  63. noshot/data/ML TS XAI/ML/ML Lab H Sec/3. Insurance Target Categorical (Overfit vs Regularized).ipynb +0 -274
  64. noshot/data/ML TS XAI/ML/ML Lab H Sec/3. Insurance Target Numerical (Overfit vs Regularized).ipynb +0 -263
  65. noshot/data/ML TS XAI/ML/ML Lab H Sec/4. Smart House System HMM.ipynb +0 -198
  66. noshot/data/ML TS XAI/ML/ML Lab H Sec/5. Fraud Detection System HMM.ipynb +0 -201
  67. noshot/data/ML TS XAI/ML/ML Lab H Sec/insurance.csv +0 -1339
  68. noshot/data/ML TS XAI/ML/ML Lab H Sec/iris1.data +0 -151
  69. noshot/data/ML TS XAI/ML/ML Lab H Sec/student-mat.csv +0 -396
  70. noshot/data/ML TS XAI/ML/ML Lab H Sec/student-por.csv +0 -650
  71. noshot/data/ML TS XAI/ML/Rolls Royce AllinOne.ipynb +0 -691
  72. noshot-10.0.0.dist-info/RECORD +0 -72
  73. {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  74. {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/top_level.txt +0 -0
@@ -1,195 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "4cb19356",
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\n",
16
- "import seaborn as sns\n",
17
- "from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay"
18
- ]
19
- },
20
- {
21
- "cell_type": "code",
22
- "execution_count": null,
23
- "id": "4bfb20c1",
24
- "metadata": {},
25
- "outputs": [],
26
- "source": [
27
- "url = \"https://archive.ics.uci.edu/ml/machine-learning-databases/balance-scale/balance-scale.data\"\n",
28
- "df = pd.read_csv(url, names=['class name','left-weight','left-distance','right-weight','right-distance'])"
29
- ]
30
- },
31
- {
32
- "cell_type": "code",
33
- "execution_count": null,
34
- "id": "c52d5405-9da9-40a9-9116-afe433e93046",
35
- "metadata": {},
36
- "outputs": [],
37
- "source": [
38
- "df"
39
- ]
40
- },
41
- {
42
- "cell_type": "code",
43
- "execution_count": null,
44
- "id": "1eaf20bd",
45
- "metadata": {},
46
- "outputs": [],
47
- "source": [
48
- "feature = ['left-weight','left-distance','right-weight','right-distance']\n",
49
- "x = df.loc[:,feature]\n",
50
- "y = df.loc[:,'class name']"
51
- ]
52
- },
53
- {
54
- "cell_type": "code",
55
- "execution_count": null,
56
- "id": "73208c45",
57
- "metadata": {},
58
- "outputs": [],
59
- "source": [
60
- "x = StandardScaler().fit_transform(x)"
61
- ]
62
- },
63
- {
64
- "cell_type": "code",
65
- "execution_count": null,
66
- "id": "0d5df04c",
67
- "metadata": {},
68
- "outputs": [],
69
- "source": [
70
- "lda = LDA(n_components=2)\n",
71
- "x_lda = lda.fit_transform(x, y)"
72
- ]
73
- },
74
- {
75
- "cell_type": "code",
76
- "execution_count": null,
77
- "id": "e262379f",
78
- "metadata": {},
79
- "outputs": [],
80
- "source": [
81
- "df_lda = pd.DataFrame(data = x_lda, columns = ['LDA1', 'LDA2'])\n",
82
- "df_lda['class name'] = y"
83
- ]
84
- },
85
- {
86
- "cell_type": "code",
87
- "execution_count": null,
88
- "id": "7e14b628",
89
- "metadata": {},
90
- "outputs": [],
91
- "source": [
92
- "plt.figure(figsize=(12, 6))\n",
93
- "plt.subplot(1, 2, 1)\n",
94
- "\n",
95
- "for target, color, marker in zip(df['class name'].unique(), ['r', 'g', 'b'], ['o', 's', '^']):\n",
96
- " plt.scatter(x[y == target, 0], x[y == target, 1], c=color, marker=marker, label=target)\n",
97
- "\n",
98
- "plt.xlabel('Feature 1')\n",
99
- "plt.ylabel('Feature 2')\n",
100
- "plt.title('Before LDA')\n",
101
- "plt.legend()\n",
102
- "\n",
103
- "plt.subplot(1, 2, 2)\n",
104
- "\n",
105
- "for target, color, marker in zip(df_lda['class name'].unique(), ['r', 'g', 'b'], ['o', 's', '^']):\n",
106
- " plt.scatter(df_lda[df_lda['class name'] == target]['LDA1'], \n",
107
- " df_lda[df_lda['class name'] == target]['LDA2'], \n",
108
- " c=color, marker=marker, label=target)\n",
109
- "\n",
110
- "plt.xlabel('LDA1')\n",
111
- "plt.ylabel('LDA2')\n",
112
- "plt.title('After LDA')\n",
113
- "plt.legend()\n",
114
- "\n",
115
- "plt.show()"
116
- ]
117
- },
118
- {
119
- "cell_type": "code",
120
- "execution_count": null,
121
- "id": "79b009f7",
122
- "metadata": {},
123
- "outputs": [],
124
- "source": [
125
- "plt.figure(figsize=(12, 6))\n",
126
- "plt.subplot(1, 2, 1)\n",
127
- "sns.heatmap(df.corr(numeric_only=True), annot=True, cmap='viridis')\n",
128
- "plt.title('Before LDA')\n",
129
- "\n",
130
- "df_lda = pd.DataFrame(data=x_lda, columns=['LDA1', 'LDA2'])\n",
131
- "#df_lda['class name'] = y\n",
132
- "plt.subplot(1, 2, 2)\n",
133
- "sns.heatmap(df_lda.corr(numeric_only=True), annot=True, cmap='viridis')\n",
134
- "plt.title('After LDA')\n",
135
- "\n",
136
- "plt.show()"
137
- ]
138
- },
139
- {
140
- "cell_type": "code",
141
- "execution_count": null,
142
- "id": "82622933",
143
- "metadata": {},
144
- "outputs": [],
145
- "source": [
146
- "y_pred = lda.predict(x) \n",
147
- "\n",
148
- "cm = confusion_matrix(y, y_pred)\n",
149
- "\n",
150
- "disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=lda.classes_)\n",
151
- "disp.plot()\n",
152
- "plt.show()"
153
- ]
154
- },
155
- {
156
- "cell_type": "code",
157
- "execution_count": null,
158
- "id": "c5bbcdd2-9bbd-4bb2-91c8-62ed34f225cc",
159
- "metadata": {},
160
- "outputs": [],
161
- "source": [
162
- "sns.heatmap(cm,annot=True)"
163
- ]
164
- },
165
- {
166
- "cell_type": "code",
167
- "execution_count": null,
168
- "id": "a0135321-d81c-48bc-9c83-8430a3662a0a",
169
- "metadata": {},
170
- "outputs": [],
171
- "source": []
172
- }
173
- ],
174
- "metadata": {
175
- "kernelspec": {
176
- "display_name": "Python 3 (ipykernel)",
177
- "language": "python",
178
- "name": "python3"
179
- },
180
- "language_info": {
181
- "codemirror_mode": {
182
- "name": "ipython",
183
- "version": 3
184
- },
185
- "file_extension": ".py",
186
- "mimetype": "text/x-python",
187
- "name": "python",
188
- "nbconvert_exporter": "python",
189
- "pygments_lexer": "ipython3",
190
- "version": "3.12.4"
191
- }
192
- },
193
- "nbformat": 4,
194
- "nbformat_minor": 5
195
- }
@@ -1,267 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "id": "db8a58e5",
6
- "metadata": {},
7
- "source": [
8
- "<h1>Linear Regression</h1>"
9
- ]
10
- },
11
- {
12
- "cell_type": "code",
13
- "execution_count": null,
14
- "id": "de374599",
15
- "metadata": {},
16
- "outputs": [],
17
- "source": [
18
- "import pandas as pd\n",
19
- "import matplotlib.pyplot as plt\n",
20
- "import seaborn as sns\n",
21
- "from sklearn.linear_model import LinearRegression\n",
22
- "from sklearn.model_selection import train_test_split\n",
23
- "import numpy as np"
24
- ]
25
- },
26
- {
27
- "cell_type": "code",
28
- "execution_count": null,
29
- "id": "4dc9e310",
30
- "metadata": {},
31
- "outputs": [],
32
- "source": [
33
- "df = pd.read_csv('insurance.csv')\n",
34
- "df = df[df['charges'] <= 12000]"
35
- ]
36
- },
37
- {
38
- "cell_type": "code",
39
- "execution_count": null,
40
- "id": "7a7f33cd",
41
- "metadata": {},
42
- "outputs": [],
43
- "source": [
44
- "df"
45
- ]
46
- },
47
- {
48
- "cell_type": "markdown",
49
- "id": "a19e236b",
50
- "metadata": {},
51
- "source": [
52
- "<h2>Linear Data</h2>"
53
- ]
54
- },
55
- {
56
- "cell_type": "code",
57
- "execution_count": null,
58
- "id": "aef9d295",
59
- "metadata": {},
60
- "outputs": [],
61
- "source": [
62
- "X = np.array(df['age'].iloc[:200])\n",
63
- "y = np.array(df['charges'].iloc[:200])"
64
- ]
65
- },
66
- {
67
- "cell_type": "code",
68
- "execution_count": null,
69
- "id": "65c46210",
70
- "metadata": {},
71
- "outputs": [],
72
- "source": [
73
- "plt.figure(figsize = (12,6))\n",
74
- "plt.title(\"Age vs Charges Scatterplot\")\n",
75
- "plt.xlabel(\"Age\")\n",
76
- "plt.ylabel(\"Charges\")\n",
77
- "sns.scatterplot(x=X,y=y)"
78
- ]
79
- },
80
- {
81
- "cell_type": "code",
82
- "execution_count": null,
83
- "id": "5be82cb7",
84
- "metadata": {},
85
- "outputs": [],
86
- "source": [
87
- "X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.2, random_state = 0)"
88
- ]
89
- },
90
- {
91
- "cell_type": "code",
92
- "execution_count": null,
93
- "id": "5d670ad4",
94
- "metadata": {},
95
- "outputs": [],
96
- "source": [
97
- "model = LinearRegression()"
98
- ]
99
- },
100
- {
101
- "cell_type": "code",
102
- "execution_count": null,
103
- "id": "82ece089",
104
- "metadata": {},
105
- "outputs": [],
106
- "source": [
107
- "model.fit(X_train.reshape(-1,1),y_train)"
108
- ]
109
- },
110
- {
111
- "cell_type": "code",
112
- "execution_count": null,
113
- "id": "ca34672b",
114
- "metadata": {},
115
- "outputs": [],
116
- "source": [
117
- "y_pred_train = model.predict(X_train.reshape(-1,1))\n",
118
- "plt.figure(figsize=(12,6))\n",
119
- "plt.title(\"Train Set\")\n",
120
- "plt.xlabel(\"Age\")\n",
121
- "plt.ylabel(\"Charges\")\n",
122
- "sns.scatterplot(x=X_train,y=y_train)\n",
123
- "sns.lineplot(x=X_train,y=y_pred_train)"
124
- ]
125
- },
126
- {
127
- "cell_type": "code",
128
- "execution_count": null,
129
- "id": "b86971e5",
130
- "metadata": {},
131
- "outputs": [],
132
- "source": [
133
- "y_pred = model.predict(X_test.reshape(-1,1))\n",
134
- "plt.figure(figsize=(12,6))\n",
135
- "plt.title(\"Test Set\")\n",
136
- "plt.xlabel(\"Age\")\n",
137
- "plt.ylabel(\"Charges\")\n",
138
- "sns.scatterplot(x=X_test,y=y_test)\n",
139
- "sns.lineplot(x=X_test,y=y_pred)"
140
- ]
141
- },
142
- {
143
- "cell_type": "markdown",
144
- "id": "07b0706a",
145
- "metadata": {},
146
- "source": [
147
- "<h2>Non Linear Data</h2>"
148
- ]
149
- },
150
- {
151
- "cell_type": "code",
152
- "execution_count": null,
153
- "id": "ea4698f7",
154
- "metadata": {},
155
- "outputs": [],
156
- "source": [
157
- "X=np.array(df['bmi'].iloc[100:300])\n",
158
- "y=np.array(df['charges'].iloc[100:300])"
159
- ]
160
- },
161
- {
162
- "cell_type": "code",
163
- "execution_count": null,
164
- "id": "1e8db443",
165
- "metadata": {},
166
- "outputs": [],
167
- "source": [
168
- "plt.figure(figsize = (12,6))\n",
169
- "plt.title('BMI vs Charges Scatterplot')\n",
170
- "plt.xlabel(\"BMI\")\n",
171
- "plt.ylabel(\"Charges\")\n",
172
- "sns.scatterplot(x=X,y=y)"
173
- ]
174
- },
175
- {
176
- "cell_type": "code",
177
- "execution_count": null,
178
- "id": "6b7bf657",
179
- "metadata": {},
180
- "outputs": [],
181
- "source": [
182
- "X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.2, random_state = 0)"
183
- ]
184
- },
185
- {
186
- "cell_type": "code",
187
- "execution_count": null,
188
- "id": "e2e4f730",
189
- "metadata": {},
190
- "outputs": [],
191
- "source": [
192
- "model = LinearRegression()"
193
- ]
194
- },
195
- {
196
- "cell_type": "code",
197
- "execution_count": null,
198
- "id": "09b3f252",
199
- "metadata": {},
200
- "outputs": [],
201
- "source": [
202
- "model.fit(X_train.reshape(-1,1),y_train)"
203
- ]
204
- },
205
- {
206
- "cell_type": "code",
207
- "execution_count": null,
208
- "id": "4d56b6ab",
209
- "metadata": {},
210
- "outputs": [],
211
- "source": [
212
- "y_pred_train = model.predict(X_train.reshape(-1,1))\n",
213
- "plt.figure(figsize=(12,6))\n",
214
- "plt.title(\"Train Set\")\n",
215
- "plt.xlabel(\"BMI\")\n",
216
- "plt.ylabel(\"Charges\")\n",
217
- "sns.scatterplot(x=X_train,y=y_train)\n",
218
- "sns.lineplot(x=X_train,y=y_pred_train)"
219
- ]
220
- },
221
- {
222
- "cell_type": "code",
223
- "execution_count": null,
224
- "id": "9bff294b",
225
- "metadata": {},
226
- "outputs": [],
227
- "source": [
228
- "y_pred = model.predict(X_test.reshape(-1,1))\n",
229
- "plt.figure(figsize=(12,6))\n",
230
- "plt.title(\"Test Set\")\n",
231
- "plt.xlabel(\"BMI\")\n",
232
- "plt.ylabel(\"Charges\")\n",
233
- "sns.scatterplot(x=X_test,y=y_test)\n",
234
- "sns.lineplot(x=X_test,y=y_pred)"
235
- ]
236
- },
237
- {
238
- "cell_type": "code",
239
- "execution_count": null,
240
- "id": "235253ca-31cb-4ecd-89a5-2f0d71f50d1f",
241
- "metadata": {},
242
- "outputs": [],
243
- "source": []
244
- }
245
- ],
246
- "metadata": {
247
- "kernelspec": {
248
- "display_name": "Python 3 (ipykernel)",
249
- "language": "python",
250
- "name": "python3"
251
- },
252
- "language_info": {
253
- "codemirror_mode": {
254
- "name": "ipython",
255
- "version": 3
256
- },
257
- "file_extension": ".py",
258
- "mimetype": "text/x-python",
259
- "name": "python",
260
- "nbconvert_exporter": "python",
261
- "pygments_lexer": "ipython3",
262
- "version": "3.12.4"
263
- }
264
- },
265
- "nbformat": 4,
266
- "nbformat_minor": 5
267
- }
@@ -1,104 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "cef03733-f76d-4c75-9570-43d8b4d946d8",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import numpy as np\n",
11
- "import matplotlib.pyplot as plt\n",
12
- "from sklearn import linear_model, datasets\n",
13
- "from sklearn.model_selection import train_test_split\n",
14
- "from sklearn.metrics import confusion_matrix\n",
15
- "\n",
16
- "# Load the wine dataset\n",
17
- "wine = datasets.load_wine()\n",
18
- "\n",
19
- "# Features and target\n",
20
- "X = wine.data\n",
21
- "Y = wine.target\n",
22
- "\n",
23
- "# Split the dataset\n",
24
- "X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.30, random_state=7)\n",
25
- "\n",
26
- "# Initialize and train Logistic Regression model\n",
27
- "log_reg_model = linear_model.LogisticRegression(max_iter=5000) # Increase max_iter to avoid convergence warning\n",
28
- "log_reg_model.fit(X_train, y_train)\n",
29
- "\n",
30
- "# Model evaluation\n",
31
- "score = log_reg_model.score(X_test, y_test)\n",
32
- "print(\"The score for the Logistic Regression Model is:\", score)\n",
33
- "\n",
34
- "# Confusion Matrix\n",
35
- "cm = confusion_matrix(y_test, log_reg_model.predict(X_test))\n",
36
- "print(\"Confusion Matrix:\\n\", cm)\n",
37
- "\n",
38
- "# ------------------------------\n",
39
- "# Visualization with only 2 features\n",
40
- "# ------------------------------\n",
41
- "\n",
42
- "# Use only the first two features for visualization\n",
43
- "X_vis = X[:, :2]\n",
44
- "\n",
45
- "# Train again on 2 features\n",
46
- "log_reg_model.fit(X_vis, Y)\n",
47
- "\n",
48
- "# Set mesh grid limits\n",
49
- "x_min, x_max = X_vis[:, 0].min() - 0.5, X_vis[:, 0].max() + 0.5\n",
50
- "y_min, y_max = X_vis[:, 1].min() - 0.5, X_vis[:, 1].max() + 0.5\n",
51
- "xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.01),\n",
52
- " np.arange(y_min, y_max, 0.01))\n",
53
- "\n",
54
- "# Predict over mesh\n",
55
- "Z = log_reg_model.predict(np.c_[xx.ravel(), yy.ravel()])\n",
56
- "Z = Z.reshape(xx.shape)\n",
57
- "\n",
58
- "# Plot\n",
59
- "plt.figure(figsize=(8, 6))\n",
60
- "plt.pcolormesh(xx, yy, Z, cmap=plt.cm.Paired, shading='auto')\n",
61
- "\n",
62
- "# Scatter plot\n",
63
- "plt.scatter(X_vis[:, 0], X_vis[:, 1], c=Y, edgecolors='k', cmap=plt.cm.Paired)\n",
64
- "plt.xlabel(wine.feature_names[0])\n",
65
- "plt.ylabel(wine.feature_names[1])\n",
66
- "plt.title('Logistic Regression Decision Boundary (Wine Dataset)')\n",
67
- "plt.xlim(xx.min(), xx.max())\n",
68
- "plt.ylim(yy.min(), yy.max())\n",
69
- "plt.xticks(())\n",
70
- "plt.yticks(())\n",
71
- "plt.show()\n"
72
- ]
73
- },
74
- {
75
- "cell_type": "code",
76
- "execution_count": null,
77
- "id": "9b026574-d96c-455d-af8f-8fa02e942a85",
78
- "metadata": {},
79
- "outputs": [],
80
- "source": []
81
- }
82
- ],
83
- "metadata": {
84
- "kernelspec": {
85
- "display_name": "Python 3 (ipykernel)",
86
- "language": "python",
87
- "name": "python3"
88
- },
89
- "language_info": {
90
- "codemirror_mode": {
91
- "name": "ipython",
92
- "version": 3
93
- },
94
- "file_extension": ".py",
95
- "mimetype": "text/x-python",
96
- "name": "python",
97
- "nbconvert_exporter": "python",
98
- "pygments_lexer": "ipython3",
99
- "version": "3.12.4"
100
- }
101
- },
102
- "nbformat": 4,
103
- "nbformat_minor": 5
104
- }
@@ -1,109 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "f7327c24-ed64-4b50-9eb9-42f1ca544cd6",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import matplotlib.pyplot as plt\n",
11
- "import seaborn as sns\n",
12
- "from sklearn import datasets\n",
13
- "from sklearn.metrics import confusion_matrix\n",
14
- "from sklearn.model_selection import train_test_split\n",
15
- "from sklearn.naive_bayes import GaussianNB\n",
16
- "\n",
17
- "# Load dataset\n",
18
- "win = datasets.load_wine()\n",
19
- "X = win.data\n",
20
- "y = win.target\n",
21
- "\n",
22
- "# Train-test split\n",
23
- "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)\n",
24
- "\n",
25
- "# Train model\n",
26
- "gnb = GaussianNB().fit(X_train, y_train)\n",
27
- "gnb_predictions = gnb.predict(X_test)\n",
28
- "\n",
29
- "# Confusion matrix\n",
30
- "cm = confusion_matrix(y_test, gnb_predictions)\n",
31
- "#labels = win.target_names\n",
32
- "\n",
33
- "# Plot\n",
34
- "plt.figure(figsize=(8, 6))\n",
35
- "sns.heatmap(cm, annot=True, fmt=\"d\", cmap=\"Blues\",\n",
36
- " xticklabels=[0,1,2], yticklabels=[0,1,2])\n",
37
- "plt.xlabel(\"Predicted Label\")\n",
38
- "plt.ylabel(\"True Label\")\n",
39
- "plt.title(\"Confusion Matrix for Gaussian Naive Bayes (Wine Dataset)\")\n",
40
- "plt.tight_layout()\n",
41
- "plt.show()\n"
42
- ]
43
- },
44
- {
45
- "cell_type": "code",
46
- "execution_count": null,
47
- "id": "219554ad-622f-4428-aa10-35f5b6bbafcb",
48
- "metadata": {
49
- "scrolled": true
50
- },
51
- "outputs": [],
52
- "source": [
53
- "import sklearn.naive_bayes\n",
54
- "help(sklearn.naive_bayes)"
55
- ]
56
- },
57
- {
58
- "cell_type": "code",
59
- "execution_count": null,
60
- "id": "abdd3ed0-02f1-4d10-b280-563984c82cab",
61
- "metadata": {},
62
- "outputs": [],
63
- "source": [
64
- "import sklearn.naive_bayes\n",
65
- "print(dir(sklearn.naive_bayes))\n"
66
- ]
67
- },
68
- {
69
- "cell_type": "code",
70
- "execution_count": null,
71
- "id": "f5f672f9-a0f5-4fe0-8a79-c6368858311a",
72
- "metadata": {},
73
- "outputs": [],
74
- "source": [
75
- "import inspect\n",
76
- "inspect.getmembers(sklearn.naive_bayes, inspect.isclass) "
77
- ]
78
- },
79
- {
80
- "cell_type": "code",
81
- "execution_count": null,
82
- "id": "28f73c18-b901-405e-88c7-9a7c606b6633",
83
- "metadata": {},
84
- "outputs": [],
85
- "source": []
86
- }
87
- ],
88
- "metadata": {
89
- "kernelspec": {
90
- "display_name": "Python 3 (ipykernel)",
91
- "language": "python",
92
- "name": "python3"
93
- },
94
- "language_info": {
95
- "codemirror_mode": {
96
- "name": "ipython",
97
- "version": 3
98
- },
99
- "file_extension": ".py",
100
- "mimetype": "text/x-python",
101
- "name": "python",
102
- "nbconvert_exporter": "python",
103
- "pygments_lexer": "ipython3",
104
- "version": "3.12.4"
105
- }
106
- },
107
- "nbformat": 4,
108
- "nbformat_minor": 5
109
- }