noshot 2.0.0__py3-none-any.whl → 3.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 (41) hide show
  1. noshot/data/ML TS XAI/ML/Main/1. EDA-PCA (Balance Scale Dataset).ipynb +139 -0
  2. noshot/data/ML TS XAI/ML/Main/1. EDA-PCA (Rice Dataset).ipynb +181 -0
  3. noshot/data/ML TS XAI/ML/Main/10. HMM Veterbi.ipynb +228 -0
  4. noshot/data/ML TS XAI/ML/Main/2. KNN (Balance Scale Dataset).ipynb +117 -0
  5. noshot/data/ML TS XAI/ML/Main/2. KNN (Iris Dataset).ipynb +165 -0
  6. noshot/data/ML TS XAI/ML/Main/2. KNN (Sobar-72 Dataset).ipynb +251 -0
  7. noshot/data/ML TS XAI/ML/Main/3. LDA (Balance Scale Dataset).ipynb +78 -0
  8. noshot/data/ML TS XAI/ML/Main/3. LDA (NPHA Doctor Visits Dataset).ipynb +114 -0
  9. noshot/data/ML TS XAI/ML/Main/4. Linear Regression (Machine Dataset).ipynb +115 -0
  10. noshot/data/ML TS XAI/ML/Main/4. Linear Regression (Real Estate Dataset).ipynb +159 -0
  11. noshot/data/ML TS XAI/ML/Main/5. Logistic Regression (Magic04 Dataset).ipynb +200 -0
  12. noshot/data/ML TS XAI/ML/Main/5. Logistic Regression (Wine Dataset).ipynb +112 -0
  13. noshot/data/ML TS XAI/ML/Main/6. Naive Bayes Classifier (Agaricus Lepiota Dataset).ipynb +153 -0
  14. noshot/data/ML TS XAI/ML/Main/6. Naive Bayes Classifier (Wine Dataset).ipynb +89 -0
  15. noshot/data/ML TS XAI/ML/Main/7. SVM (Rice Dataset).ipynb +208 -0
  16. noshot/data/ML TS XAI/ML/Main/8. FeedForward NN (Sobar72 Dataset).ipynb +260 -0
  17. noshot/data/ML TS XAI/ML/Main/9. CNN (Cifar10 Dataset).ipynb +238 -0
  18. noshot/data/ML TS XAI/ML/Main/data/agaricus-lepiota.data +8124 -0
  19. noshot/data/ML TS XAI/ML/Main/data/balance-scale.txt +625 -0
  20. noshot/data/ML TS XAI/ML/Main/data/doctor-visits.csv +715 -0
  21. noshot/data/ML TS XAI/ML/Main/data/iris.csv +151 -0
  22. noshot/data/ML TS XAI/ML/Main/data/machine-data.csv +210 -0
  23. noshot/data/ML TS XAI/ML/Main/data/magic04.data +19020 -0
  24. noshot/data/ML TS XAI/ML/Main/data/real-estate.xlsx +0 -0
  25. noshot/data/ML TS XAI/ML/Main/data/rice.arff +3826 -0
  26. noshot/data/ML TS XAI/ML/Main/data/sobar-72.csv +73 -0
  27. noshot/data/ML TS XAI/ML/Main/data/wine-dataset.csv +179 -0
  28. noshot/data/ML TS XAI/ML/Other Codes.ipynb +158 -0
  29. noshot/data/ML TS XAI/ML/Rolls Royce AllinOne.ipynb +691 -0
  30. {noshot-2.0.0.dist-info → noshot-3.0.0.dist-info}/METADATA +1 -1
  31. noshot-3.0.0.dist-info/RECORD +38 -0
  32. {noshot-2.0.0.dist-info → noshot-3.0.0.dist-info}/WHEEL +1 -1
  33. noshot/data/ML TS XAI/TS/bill-charge.ipynb +0 -239
  34. noshot/data/ML TS XAI/TS/daily-min-temperatures.ipynb +0 -239
  35. noshot/data/ML TS XAI/TS/data/bill-data.csv +0 -21
  36. noshot/data/ML TS XAI/TS/data/daily-min-temperatures.csv +0 -3651
  37. noshot/data/ML TS XAI/TS/data/monthly-sunspots.csv +0 -2821
  38. noshot/data/ML TS XAI/TS/monthly-sunspots.ipynb +0 -241
  39. noshot-2.0.0.dist-info/RECORD +0 -15
  40. {noshot-2.0.0.dist-info → noshot-3.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  41. {noshot-2.0.0.dist-info → noshot-3.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,260 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {
7
+ "id": "aYlTWIqe5rL9"
8
+ },
9
+ "outputs": [],
10
+ "source": [
11
+ "import numpy as np\n",
12
+ "import pandas as pd\n",
13
+ "import seaborn as sns\n",
14
+ "import matplotlib.pyplot as plt\n",
15
+ "\n",
16
+ "import tensorflow as tf\n",
17
+ "from tensorflow.keras.models import Sequential\n",
18
+ "from tensorflow.keras.layers import Dense, Flatten\n",
19
+ "from tensorflow.keras.optimizers import Adam\n",
20
+ "from tensorflow.keras.losses import SparseCategoricalCrossentropy\n",
21
+ "from tensorflow.keras.metrics import SparseCategoricalAccuracy\n",
22
+ "\n",
23
+ "import warnings\n",
24
+ "warnings.filterwarnings('ignore')"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": null,
30
+ "metadata": {
31
+ "colab": {
32
+ "base_uri": "https://localhost:8080/",
33
+ "height": 226
34
+ },
35
+ "id": "ejG3Obse5smj",
36
+ "outputId": "85d8cf13-eb83-49f6-e98f-0893fabb1cff"
37
+ },
38
+ "outputs": [],
39
+ "source": [
40
+ "df = pd.read_csv(\"data/sobar-72.csv\")\n",
41
+ "df.head()"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": null,
47
+ "metadata": {
48
+ "id": "hLECDj5558Om"
49
+ },
50
+ "outputs": [],
51
+ "source": [
52
+ "X = df.drop(columns=['ca_cervix'])\n",
53
+ "y = df['ca_cervix']"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "execution_count": null,
59
+ "metadata": {
60
+ "id": "MhA_LTNA5-49"
61
+ },
62
+ "outputs": [],
63
+ "source": [
64
+ "import matplotlib.pyplot as plt\n",
65
+ "from sklearn.model_selection import train_test_split\n",
66
+ "from tensorflow.keras import regularizers\n",
67
+ "from tensorflow.keras.layers import Dropout"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "code",
72
+ "execution_count": null,
73
+ "metadata": {
74
+ "id": "rjH4KJqq5_7-"
75
+ },
76
+ "outputs": [],
77
+ "source": [
78
+ "x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
79
+ "\n",
80
+ "y_train = tf.keras.utils.to_categorical(y_train, num_classes=2)\n",
81
+ "y_test = tf.keras.utils.to_categorical(y_test, num_classes=2)"
82
+ ]
83
+ },
84
+ {
85
+ "cell_type": "code",
86
+ "execution_count": null,
87
+ "metadata": {
88
+ "id": "5lQVtYUC6A67"
89
+ },
90
+ "outputs": [],
91
+ "source": [
92
+ "model = tf.keras.models.Sequential([\n",
93
+ " tf.keras.layers.Dense(128, activation='relu', input_shape=(19,),\n",
94
+ " kernel_regularizer=regularizers.l2(0.001)),\n",
95
+ " Dropout(0.3),\n",
96
+ " tf.keras.layers.Dense(64, activation='relu',\n",
97
+ " kernel_regularizer=regularizers.l2(0.001)),\n",
98
+ " Dropout(0.3),\n",
99
+ " tf.keras.layers.Dense(units=2, activation='softmax')\n",
100
+ "])"
101
+ ]
102
+ },
103
+ {
104
+ "cell_type": "code",
105
+ "execution_count": null,
106
+ "metadata": {
107
+ "id": "cgxMgB8q6Cjg"
108
+ },
109
+ "outputs": [],
110
+ "source": [
111
+ "model.compile(optimizer='adam',\n",
112
+ " loss='categorical_crossentropy',\n",
113
+ " metrics=['accuracy'])"
114
+ ]
115
+ },
116
+ {
117
+ "cell_type": "code",
118
+ "execution_count": null,
119
+ "metadata": {
120
+ "id": "y71y0yDT6MnK"
121
+ },
122
+ "outputs": [],
123
+ "source": [
124
+ "early_stopping = tf.keras.callbacks.EarlyStopping(\n",
125
+ " monitor='val_loss',\n",
126
+ " patience=10,\n",
127
+ " restore_best_weights=True)"
128
+ ]
129
+ },
130
+ {
131
+ "cell_type": "code",
132
+ "execution_count": null,
133
+ "metadata": {
134
+ "colab": {
135
+ "base_uri": "https://localhost:8080/"
136
+ },
137
+ "id": "1PZHOQQp6NpP",
138
+ "outputId": "c1d34cfd-5b74-4f42-aef1-74bbfc6aec95"
139
+ },
140
+ "outputs": [],
141
+ "source": [
142
+ "history = model.fit(x_train, y_train,\n",
143
+ " epochs=50,\n",
144
+ " batch_size=32,\n",
145
+ " validation_split=0.2,\n",
146
+ " callbacks=[early_stopping],\n",
147
+ " verbose=1)"
148
+ ]
149
+ },
150
+ {
151
+ "cell_type": "code",
152
+ "execution_count": null,
153
+ "metadata": {
154
+ "colab": {
155
+ "base_uri": "https://localhost:8080/",
156
+ "height": 362
157
+ },
158
+ "id": "qjhgjajp6O3J",
159
+ "outputId": "b04cb0d7-bc3f-4991-e5f8-c51698856ab7"
160
+ },
161
+ "outputs": [],
162
+ "source": [
163
+ "def plot_history(history):\n",
164
+ " plt.figure(figsize=(12, 5))\n",
165
+ "\n",
166
+ " # Plot loss\n",
167
+ " plt.subplot(1, 2, 1)\n",
168
+ " plt.plot(history.history['loss'], label='Training Loss')\n",
169
+ " plt.plot(history.history['val_loss'], label='Validation Loss')\n",
170
+ " plt.title('Training and Validation Loss')\n",
171
+ " plt.xlabel('Epoch')\n",
172
+ " plt.ylabel('Loss')\n",
173
+ " plt.legend()\n",
174
+ "\n",
175
+ " # Plot accuracy\n",
176
+ " plt.subplot(1, 2, 2)\n",
177
+ " plt.plot(history.history['accuracy'], label='Training Accuracy')\n",
178
+ " plt.plot(history.history['val_accuracy'], label='Validation Accuracy')\n",
179
+ " plt.title('Training and Validation Accuracy')\n",
180
+ " plt.xlabel('Epoch')\n",
181
+ " plt.ylabel('Accuracy')\n",
182
+ " plt.legend()\n",
183
+ "\n",
184
+ " plt.tight_layout()\n",
185
+ " plt.show()\n",
186
+ "\n",
187
+ "plot_history(history)\n",
188
+ "\n",
189
+ "loss, accuracy = model.evaluate(x_test, y_test)\n",
190
+ "print(f'Test accuracy: {accuracy:.4f}')\n",
191
+ "print(f'Test loss: {loss:.4f}')\n",
192
+ "\n",
193
+ "print(f\"Actual: {y_test[1]}, Predicted: {model.predict(x_test[:1])}\")"
194
+ ]
195
+ },
196
+ {
197
+ "cell_type": "code",
198
+ "execution_count": null,
199
+ "metadata": {
200
+ "colab": {
201
+ "base_uri": "https://localhost:8080/",
202
+ "height": 1000
203
+ },
204
+ "id": "VaBGSYTs6Qeq",
205
+ "outputId": "39af0238-9045-412e-cd8b-258fdc133948"
206
+ },
207
+ "outputs": [],
208
+ "source": [
209
+ "from sklearn.metrics import classification_report,confusion_matrix,ConfusionMatrixDisplay,roc_curve, auc, accuracy_score\n",
210
+ "y_pred=model.predict(x_test)\n",
211
+ "y_test= [np.argmax(y, axis=None, out=None) for y in y_test]\n",
212
+ "y_pred= [np.argmax(y, axis=None, out=None) for y in y_pred]\n",
213
+ "print(\"Feed Forward Classification Report:\")\n",
214
+ "print(classification_report(y_test, y_pred))\n",
215
+ "print(f\"Accuracy: {accuracy_score(y_test, y_pred):.2f}\")\n",
216
+ "conf=confusion_matrix(y_test,y_pred)\n",
217
+ "ConfusionMatrixDisplay(conf,display_labels=[0,1]).plot(cmap='Blues')\n",
218
+ "plt.show()\n",
219
+ "y_pred_proba=model.predict(x_test)[:,1]\n",
220
+ "fpr, tpr, thresholds = roc_curve(y_test, y_pred_proba)\n",
221
+ "roc_auc = auc(fpr, tpr)\n",
222
+ "\n",
223
+ "plt.figure()\n",
224
+ "plt.plot(fpr, tpr, color='darkorange', lw=2, label='ROC curve (area = %0.2f)' % roc_auc)\n",
225
+ "plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')\n",
226
+ "plt.xlim([0.0, 1.0])\n",
227
+ "plt.ylim([0.0, 1.05])\n",
228
+ "plt.xlabel('False Positive Rate')\n",
229
+ "plt.ylabel('True Positive Rate')\n",
230
+ "plt.title('Receiver Operating Characteristic')\n",
231
+ "plt.legend(loc=\"lower right\")\n",
232
+ "plt.show()"
233
+ ]
234
+ }
235
+ ],
236
+ "metadata": {
237
+ "colab": {
238
+ "provenance": []
239
+ },
240
+ "kernelspec": {
241
+ "display_name": "Python 3 (ipykernel)",
242
+ "language": "python",
243
+ "name": "python3"
244
+ },
245
+ "language_info": {
246
+ "codemirror_mode": {
247
+ "name": "ipython",
248
+ "version": 3
249
+ },
250
+ "file_extension": ".py",
251
+ "mimetype": "text/x-python",
252
+ "name": "python",
253
+ "nbconvert_exporter": "python",
254
+ "pygments_lexer": "ipython3",
255
+ "version": "3.12.4"
256
+ }
257
+ },
258
+ "nbformat": 4,
259
+ "nbformat_minor": 4
260
+ }
@@ -0,0 +1,238 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {
7
+ "id": "wHmdCsrz61l7"
8
+ },
9
+ "outputs": [],
10
+ "source": [
11
+ "import tensorflow as tf\n",
12
+ "from tensorflow import keras\n",
13
+ "from tensorflow.keras import layers\n",
14
+ "import numpy as np\n",
15
+ "from keras.datasets import cifar10\n",
16
+ "import tensorflow as tf\n",
17
+ "from keras.preprocessing import image\n",
18
+ "from tensorflow.keras.preprocessing.image import ImageDataGenerator\n",
19
+ "from keras.models import Sequential\n",
20
+ "from keras.layers import Dense, Flatten, Conv2D, MaxPooling2D, Dropout, BatchNormalization\n",
21
+ "from keras.utils import to_categorical\n",
22
+ "from keras.applications.vgg19 import VGG19\n",
23
+ "from tensorflow.keras.optimizers import RMSprop\n",
24
+ "from keras.datasets import cifar10\n",
25
+ "from sklearn.metrics import classification_report, confusion_matrix\n",
26
+ "from keras.callbacks import EarlyStopping, ReduceLROnPlateau\n",
27
+ "import os\n",
28
+ "import warnings\n",
29
+ "warnings.filterwarnings('ignore')"
30
+ ]
31
+ },
32
+ {
33
+ "cell_type": "code",
34
+ "execution_count": null,
35
+ "metadata": {
36
+ "colab": {
37
+ "base_uri": "https://localhost:8080/"
38
+ },
39
+ "id": "dghWl91B66Ey",
40
+ "outputId": "a14fb7c3-44a7-4d93-805e-708ecc2157ef"
41
+ },
42
+ "outputs": [],
43
+ "source": [
44
+ "from tensorflow.keras.datasets import cifar10\n",
45
+ "from tensorflow.keras.utils import to_categorical\n",
46
+ "import tensorflow as tf\n",
47
+ "from tensorflow import keras\n",
48
+ "from tensorflow.keras import layers\n",
49
+ "import matplotlib.pyplot as plt"
50
+ ]
51
+ },
52
+ {
53
+ "cell_type": "code",
54
+ "execution_count": null,
55
+ "metadata": {
56
+ "colab": {
57
+ "base_uri": "https://localhost:8080/"
58
+ },
59
+ "id": "dghWl91B66Ey",
60
+ "outputId": "a14fb7c3-44a7-4d93-805e-708ecc2157ef"
61
+ },
62
+ "outputs": [],
63
+ "source": [
64
+ "(X_train, y_train), (X_test, y_test) = cifar10.load_data()"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": null,
70
+ "metadata": {
71
+ "colab": {
72
+ "base_uri": "https://localhost:8080/"
73
+ },
74
+ "id": "dghWl91B66Ey",
75
+ "outputId": "a14fb7c3-44a7-4d93-805e-708ecc2157ef"
76
+ },
77
+ "outputs": [],
78
+ "source": [
79
+ "def preprocess_data(X, y):\n",
80
+ " X = X.astype('float32') / 255.0 # Normalize to [0, 1]\n",
81
+ " y = to_categorical(y, num_classes=10) # One-hot encode labels\n",
82
+ " return X, y"
83
+ ]
84
+ },
85
+ {
86
+ "cell_type": "code",
87
+ "execution_count": null,
88
+ "metadata": {
89
+ "colab": {
90
+ "base_uri": "https://localhost:8080/"
91
+ },
92
+ "id": "dghWl91B66Ey",
93
+ "outputId": "a14fb7c3-44a7-4d93-805e-708ecc2157ef"
94
+ },
95
+ "outputs": [],
96
+ "source": [
97
+ " \n",
98
+ "x_train, y_train = preprocess_data(X_train, y_train)\n",
99
+ "x_test, y_test = preprocess_data(X_test, y_test)"
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "execution_count": null,
105
+ "metadata": {
106
+ "colab": {
107
+ "base_uri": "https://localhost:8080/"
108
+ },
109
+ "id": "dghWl91B66Ey",
110
+ "outputId": "a14fb7c3-44a7-4d93-805e-708ecc2157ef"
111
+ },
112
+ "outputs": [],
113
+ "source": [
114
+ "model = keras.Sequential(\n",
115
+ " [\n",
116
+ " keras.Input(shape=(32, 32, 3)),\n",
117
+ " layers.Conv2D(32, kernel_size=(3, 3), activation=\"relu\"),\n",
118
+ " layers.MaxPooling2D(pool_size=(2, 2)),\n",
119
+ " layers.Conv2D(64, kernel_size=(3, 3), activation=\"relu\"),\n",
120
+ " layers.MaxPooling2D(pool_size=(2, 2)),\n",
121
+ " layers.Flatten(),\n",
122
+ " layers.Dense(10, activation=\"softmax\"),\n",
123
+ " ]\n",
124
+ ")"
125
+ ]
126
+ },
127
+ {
128
+ "cell_type": "code",
129
+ "execution_count": null,
130
+ "metadata": {
131
+ "colab": {
132
+ "base_uri": "https://localhost:8080/"
133
+ },
134
+ "id": "dghWl91B66Ey",
135
+ "outputId": "a14fb7c3-44a7-4d93-805e-708ecc2157ef"
136
+ },
137
+ "outputs": [],
138
+ "source": [
139
+ "model.compile(loss=\"categorical_crossentropy\", optimizer=\"adam\", metrics=[\"accuracy\"])"
140
+ ]
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": null,
145
+ "metadata": {
146
+ "colab": {
147
+ "base_uri": "https://localhost:8080/"
148
+ },
149
+ "id": "dghWl91B66Ey",
150
+ "outputId": "a14fb7c3-44a7-4d93-805e-708ecc2157ef"
151
+ },
152
+ "outputs": [],
153
+ "source": [
154
+ "early_stopping = tf.keras.callbacks.EarlyStopping(\n",
155
+ " monitor='val_loss',\n",
156
+ " patience=10,\n",
157
+ " restore_best_weights=True)"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "code",
162
+ "execution_count": null,
163
+ "metadata": {
164
+ "colab": {
165
+ "base_uri": "https://localhost:8080/"
166
+ },
167
+ "id": "dghWl91B66Ey",
168
+ "outputId": "a14fb7c3-44a7-4d93-805e-708ecc2157ef"
169
+ },
170
+ "outputs": [],
171
+ "source": [
172
+ "history = model.fit(x_train, y_train,\n",
173
+ " epochs=5,\n",
174
+ " batch_size=32,\n",
175
+ " validation_split=0.2,\n",
176
+ " callbacks=[early_stopping],\n",
177
+ " verbose=1)"
178
+ ]
179
+ },
180
+ {
181
+ "cell_type": "code",
182
+ "execution_count": null,
183
+ "metadata": {
184
+ "colab": {
185
+ "base_uri": "https://localhost:8080/",
186
+ "height": 489
187
+ },
188
+ "id": "mU4ISHnR7BIW",
189
+ "outputId": "cbda13b8-4a96-4178-9ee4-f70e07d1bc64"
190
+ },
191
+ "outputs": [],
192
+ "source": [
193
+ "from sklearn.preprocessing import label_binarize\n",
194
+ "\n",
195
+ "y_test_bin = label_binarize(y_test, classes=list(range(10)))\n",
196
+ "y_pred_proba = model.predict(x_test)\n",
197
+ "\n",
198
+ "fpr, tpr, _ = roc_curve(y_test_bin[:, 0], y_pred_proba[:, 0])\n",
199
+ "roc_auc = auc(fpr, tpr)\n",
200
+ "\n",
201
+ "plt.figure()\n",
202
+ "plt.plot(fpr, tpr, color='darkorange', lw=2, label='Class 0 ROC curve (area = %0.2f)' % roc_auc)\n",
203
+ "plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')\n",
204
+ "plt.xlim([0.0, 1.0])\n",
205
+ "plt.ylim([0.0, 1.05])\n",
206
+ "plt.xlabel('False Positive Rate')\n",
207
+ "plt.ylabel('True Positive Rate')\n",
208
+ "plt.title('ROC Curve for Class 0')\n",
209
+ "plt.legend(loc=\"lower right\")\n",
210
+ "plt.show()"
211
+ ]
212
+ }
213
+ ],
214
+ "metadata": {
215
+ "colab": {
216
+ "provenance": []
217
+ },
218
+ "kernelspec": {
219
+ "display_name": "Python 3 (ipykernel)",
220
+ "language": "python",
221
+ "name": "python3"
222
+ },
223
+ "language_info": {
224
+ "codemirror_mode": {
225
+ "name": "ipython",
226
+ "version": 3
227
+ },
228
+ "file_extension": ".py",
229
+ "mimetype": "text/x-python",
230
+ "name": "python",
231
+ "nbconvert_exporter": "python",
232
+ "pygments_lexer": "ipython3",
233
+ "version": "3.12.4"
234
+ }
235
+ },
236
+ "nbformat": 4,
237
+ "nbformat_minor": 4
238
+ }