noshot 4.0.0__py3-none-any.whl → 5.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 (42) hide show
  1. noshot/data/ML TS XAI/XAI/Q1.ipynb +535 -0
  2. noshot/data/ML TS XAI/XAI/Q2.ipynb +38129 -0
  3. noshot/data/ML TS XAI/XAI/Q3.ipynb +1340 -0
  4. noshot/data/ML TS XAI/XAI/Q4.ipynb +246 -0
  5. noshot/data/ML TS XAI/XAI/Q5.ipynb +2450 -0
  6. {noshot-4.0.0.dist-info → noshot-5.0.0.dist-info}/METADATA +1 -1
  7. noshot-5.0.0.dist-info/RECORD +14 -0
  8. noshot/data/ML TS XAI/ML/ML Lab CIA 2 (I Found Only This Check)/Copy_of_Pistachio_csv.ipynb +0 -269
  9. noshot/data/ML TS XAI/ML/ML Lab CIA 2 (I Found Only This Check)/weatherAUS.ipynb +0 -155
  10. noshot/data/ML TS XAI/ML/Main/1. EDA-PCA (Balance Scale Dataset).ipynb +0 -139
  11. noshot/data/ML TS XAI/ML/Main/1. EDA-PCA (Rice Dataset).ipynb +0 -181
  12. noshot/data/ML TS XAI/ML/Main/10. HMM Veterbi.ipynb +0 -228
  13. noshot/data/ML TS XAI/ML/Main/2. KNN (Balance Scale Dataset).ipynb +0 -117
  14. noshot/data/ML TS XAI/ML/Main/2. KNN (Iris Dataset).ipynb +0 -165
  15. noshot/data/ML TS XAI/ML/Main/2. KNN (Sobar-72 Dataset).ipynb +0 -251
  16. noshot/data/ML TS XAI/ML/Main/3. LDA (Balance Scale Dataset).ipynb +0 -78
  17. noshot/data/ML TS XAI/ML/Main/3. LDA (NPHA Doctor Visits Dataset).ipynb +0 -114
  18. noshot/data/ML TS XAI/ML/Main/4. Linear Regression (Machine Dataset).ipynb +0 -115
  19. noshot/data/ML TS XAI/ML/Main/4. Linear Regression (Real Estate Dataset).ipynb +0 -159
  20. noshot/data/ML TS XAI/ML/Main/5. Logistic Regression (Magic04 Dataset).ipynb +0 -200
  21. noshot/data/ML TS XAI/ML/Main/5. Logistic Regression (Wine Dataset).ipynb +0 -112
  22. noshot/data/ML TS XAI/ML/Main/6. Naive Bayes Classifier (Agaricus Lepiota Dataset).ipynb +0 -153
  23. noshot/data/ML TS XAI/ML/Main/6. Naive Bayes Classifier (Wine Dataset).ipynb +0 -89
  24. noshot/data/ML TS XAI/ML/Main/7. SVM (Rice Dataset).ipynb +0 -208
  25. noshot/data/ML TS XAI/ML/Main/8. FeedForward NN (Sobar72 Dataset).ipynb +0 -260
  26. noshot/data/ML TS XAI/ML/Main/9. CNN (Cifar10 Dataset).ipynb +0 -238
  27. noshot/data/ML TS XAI/ML/Main/data/agaricus-lepiota.data +0 -8124
  28. noshot/data/ML TS XAI/ML/Main/data/balance-scale.txt +0 -625
  29. noshot/data/ML TS XAI/ML/Main/data/doctor-visits.csv +0 -715
  30. noshot/data/ML TS XAI/ML/Main/data/iris.csv +0 -151
  31. noshot/data/ML TS XAI/ML/Main/data/machine-data.csv +0 -210
  32. noshot/data/ML TS XAI/ML/Main/data/magic04.data +0 -19020
  33. noshot/data/ML TS XAI/ML/Main/data/real-estate.xlsx +0 -0
  34. noshot/data/ML TS XAI/ML/Main/data/rice.arff +0 -3826
  35. noshot/data/ML TS XAI/ML/Main/data/sobar-72.csv +0 -73
  36. noshot/data/ML TS XAI/ML/Main/data/wine-dataset.csv +0 -179
  37. noshot/data/ML TS XAI/ML/Other Codes.ipynb +0 -158
  38. noshot/data/ML TS XAI/ML/Rolls Royce AllinOne.ipynb +0 -691
  39. noshot-4.0.0.dist-info/RECORD +0 -40
  40. {noshot-4.0.0.dist-info → noshot-5.0.0.dist-info}/WHEEL +0 -0
  41. {noshot-4.0.0.dist-info → noshot-5.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  42. {noshot-4.0.0.dist-info → noshot-5.0.0.dist-info}/top_level.txt +0 -0
@@ -1,155 +0,0 @@
1
- {
2
- "nbformat": 4,
3
- "nbformat_minor": 0,
4
- "metadata": {
5
- "colab": {
6
- "provenance": []
7
- },
8
- "kernelspec": {
9
- "name": "python3",
10
- "display_name": "Python 3"
11
- },
12
- "language_info": {
13
- "name": "python"
14
- }
15
- },
16
- "cells": [
17
- {
18
- "cell_type": "markdown",
19
- "source": [
20
- "1.\tDesign a custom 4-layer feed forward neural network for the weather prediction dataset. Modify your model to include L2 regularization on all hidden layers."
21
- ],
22
- "metadata": {
23
- "id": "41vyXTdsmm3h"
24
- }
25
- },
26
- {
27
- "cell_type": "code",
28
- "execution_count": 3,
29
- "metadata": {
30
- "colab": {
31
- "base_uri": "https://localhost:8080/"
32
- },
33
- "id": "HOFKtDK0kHT9",
34
- "outputId": "5366de78-d21f-4462-e430-327c4d38bb1e"
35
- },
36
- "outputs": [
37
- {
38
- "output_type": "stream",
39
- "name": "stdout",
40
- "text": [
41
- "Epoch 1/20, Loss: 0.7105\n",
42
- "Epoch 2/20, Loss: 0.7018\n",
43
- "Epoch 3/20, Loss: 0.6926\n",
44
- "Epoch 4/20, Loss: 0.6830\n",
45
- "Epoch 5/20, Loss: 0.6730\n",
46
- "Epoch 6/20, Loss: 0.6629\n",
47
- "Epoch 7/20, Loss: 0.6525\n",
48
- "Epoch 8/20, Loss: 0.6419\n",
49
- "Epoch 9/20, Loss: 0.6308\n",
50
- "Epoch 10/20, Loss: 0.6192\n",
51
- "Epoch 11/20, Loss: 0.6071\n",
52
- "Epoch 12/20, Loss: 0.5944\n",
53
- "Epoch 13/20, Loss: 0.5811\n",
54
- "Epoch 14/20, Loss: 0.5673\n",
55
- "Epoch 15/20, Loss: 0.5531\n",
56
- "Epoch 16/20, Loss: 0.5387\n",
57
- "Epoch 17/20, Loss: 0.5241\n",
58
- "Epoch 18/20, Loss: 0.5096\n",
59
- "Epoch 19/20, Loss: 0.4954\n",
60
- "Epoch 20/20, Loss: 0.4817\n",
61
- "\n",
62
- "Test Accuracy: 0.7860\n",
63
- "\n",
64
- "Classification Report:\n",
65
- " precision recall f1-score support\n",
66
- "\n",
67
- " 0.0 0.78 1.00 0.88 10588\n",
68
- " 1.0 1.00 0.04 0.08 3035\n",
69
- "\n",
70
- " accuracy 0.79 13623\n",
71
- " macro avg 0.89 0.52 0.48 13623\n",
72
- "weighted avg 0.83 0.79 0.70 13623\n",
73
- "\n"
74
- ]
75
- }
76
- ],
77
- "source": [
78
- "import pandas as pd\n",
79
- "import numpy as np\n",
80
- "from sklearn.model_selection import train_test_split\n",
81
- "from sklearn.preprocessing import LabelEncoder, StandardScaler\n",
82
- "from sklearn.metrics import accuracy_score, classification_report\n",
83
- "import torch\n",
84
- "import torch.nn as nn\n",
85
- "import torch.nn.functional as F\n",
86
- "\n",
87
- "df = pd.read_csv(\"weatherAUS.csv\", on_bad_lines='skip')\n",
88
- "\n",
89
- "df = df.dropna(subset=[\"RainTomorrow\"])\n",
90
- "\n",
91
- "num_cols = df.select_dtypes(include=[\"float64\", \"int64\"]).columns\n",
92
- "df[num_cols] = df[num_cols].fillna(df[num_cols].median())\n",
93
- "\n",
94
- "cat_cols = df.select_dtypes(include=[\"object\"]).columns\n",
95
- "df[cat_cols] = df[cat_cols].fillna(df[cat_cols].mode().iloc[0])\n",
96
- "\n",
97
- "le_dict = {}\n",
98
- "for col in cat_cols:\n",
99
- " le = LabelEncoder()\n",
100
- " df[col] = le.fit_transform(df[col])\n",
101
- " le_dict[col] = le\n",
102
- "\n",
103
- "X = df.drop(\"RainTomorrow\", axis=1)\n",
104
- "y = df[\"RainTomorrow\"]\n",
105
- "\n",
106
- "scaler = StandardScaler()\n",
107
- "X = scaler.fit_transform(X)\n",
108
- "\n",
109
- "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
110
- "\n",
111
- "X_train = torch.tensor(X_train, dtype=torch.float32)\n",
112
- "y_train = torch.tensor(y_train.values, dtype=torch.float32).view(-1, 1)\n",
113
- "X_test = torch.tensor(X_test, dtype=torch.float32)\n",
114
- "y_test = torch.tensor(y_test.values, dtype=torch.float32).view(-1, 1)\n",
115
- "\n",
116
- "class WeatherPredictor(nn.Module):\n",
117
- " def __init__(self, input_size):\n",
118
- " super(WeatherPredictor, self).__init__()\n",
119
- " self.fc1 = nn.Linear(input_size, 128)\n",
120
- " self.fc2 = nn.Linear(128, 64)\n",
121
- " self.fc3 = nn.Linear(64, 32)\n",
122
- " self.fc4 = nn.Linear(32, 1)\n",
123
- "\n",
124
- " def forward(self, x):\n",
125
- " x = F.relu(self.fc1(x))\n",
126
- " x = F.relu(self.fc2(x))\n",
127
- " x = F.relu(self.fc3(x))\n",
128
- " x = torch.sigmoid(self.fc4(x))\n",
129
- " return x\n",
130
- "\n",
131
- "model = WeatherPredictor(input_size=X_train.shape[1])\n",
132
- "criterion = nn.BCELoss()\n",
133
- "optimizer = torch.optim.Adam(model.parameters(), lr=0.001, weight_decay=1e-4) # L2 regularization\n",
134
- "\n",
135
- "epochs = 20\n",
136
- "for epoch in range(epochs):\n",
137
- " model.train()\n",
138
- " optimizer.zero_grad()\n",
139
- " outputs = model(X_train)\n",
140
- " loss = criterion(outputs, y_train)\n",
141
- " loss.backward()\n",
142
- " optimizer.step()\n",
143
- " print(f\"Epoch {epoch+1}/{epochs}, Loss: {loss.item():.4f}\")\n",
144
- "\n",
145
- "model.eval()\n",
146
- "with torch.no_grad():\n",
147
- " preds = model(X_test)\n",
148
- " preds_class = (preds > 0.5).float()\n",
149
- " acc = accuracy_score(y_test, preds_class)\n",
150
- " print(f\"\\nTest Accuracy: {acc:.4f}\")\n",
151
- " print(\"\\nClassification Report:\\n\", classification_report(y_test, preds_class))"
152
- ]
153
- }
154
- ]
155
- }
@@ -1,139 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "1919dce4",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import pandas as pd\n",
11
- "import numpy as np\n",
12
- "import seaborn as sns\n",
13
- "import matplotlib.pyplot as plt\n",
14
- "from sklearn.preprocessing import StandardScaler\n",
15
- "from sklearn.decomposition import PCA\n",
16
- "\n",
17
- "import warnings\n",
18
- "warnings.filterwarnings('ignore')"
19
- ]
20
- },
21
- {
22
- "cell_type": "code",
23
- "execution_count": null,
24
- "id": "459c19c9",
25
- "metadata": {},
26
- "outputs": [],
27
- "source": [
28
- "cols = ['class name', 'left-weight', 'left-distance', 'right-weight', 'right-distance']\n",
29
- "df = pd.read_table('data/balance-scale.txt', delimiter=',', names=cols)\n",
30
- "print(\"Shape:\", df.shape)\n",
31
- "df.head()"
32
- ]
33
- },
34
- {
35
- "cell_type": "code",
36
- "execution_count": null,
37
- "id": "ceb17e01",
38
- "metadata": {},
39
- "outputs": [],
40
- "source": [
41
- "df.describe()"
42
- ]
43
- },
44
- {
45
- "cell_type": "code",
46
- "execution_count": null,
47
- "id": "c3950e04",
48
- "metadata": {},
49
- "outputs": [],
50
- "source": [
51
- "df.info()"
52
- ]
53
- },
54
- {
55
- "cell_type": "code",
56
- "execution_count": null,
57
- "id": "2fd3e589-3f8f-4203-aa0b-7d3261a3c5b1",
58
- "metadata": {},
59
- "outputs": [],
60
- "source": [
61
- "sns.countplot(df, x='class name', hue='class name')\n",
62
- "plt.title(\"Count Plot ['B', 'R', 'L']\")\n",
63
- "plt.show()"
64
- ]
65
- },
66
- {
67
- "cell_type": "code",
68
- "execution_count": null,
69
- "id": "b9d4bb7e",
70
- "metadata": {},
71
- "outputs": [],
72
- "source": [
73
- "features = ['left-weight', 'left-distance', 'right-weight', 'right-distance']\n",
74
- "x = df.loc[:, features]\n",
75
- "y = df.loc[:, 'class name']"
76
- ]
77
- },
78
- {
79
- "cell_type": "code",
80
- "execution_count": null,
81
- "id": "de2b55cc",
82
- "metadata": {},
83
- "outputs": [],
84
- "source": [
85
- "x = StandardScaler().fit_transform(x)\n",
86
- "pca = PCA(n_components=2)\n",
87
- "pct = pca.fit_transform(x)"
88
- ]
89
- },
90
- {
91
- "cell_type": "code",
92
- "execution_count": null,
93
- "id": "08a8f4c9-05d6-4422-a6f3-5c6f7605220b",
94
- "metadata": {},
95
- "outputs": [],
96
- "source": [
97
- "principal_df = pd.DataFrame(pct, columns=['pc1', 'pc2'])\n",
98
- "principal_df['class name'] = df['class name']\n",
99
- "principal_df.head()\n",
100
- "\n",
101
- "fig = plt.figure(figsize=(8,8))\n",
102
- "ax = fig.add_subplot(1, 1, 1)\n",
103
- "\n",
104
- "targets = ['L','B','R']\n",
105
- "colors = ['r', 'g','b']\n",
106
- "for target, color in zip(targets, colors):\n",
107
- " selected = principal_df[principal_df['class name'] == target]\n",
108
- " ax.scatter(selected['pc1'], selected['pc2'], c=color, s=50)\n",
109
- "\n",
110
- "ax.set_xlabel('Principal Component 1')\n",
111
- "ax.set_ylabel('Principal Component 2')\n",
112
- "ax.set_title('2 component PCA')\n",
113
- "ax.legend(targets)\n",
114
- "ax.grid()"
115
- ]
116
- }
117
- ],
118
- "metadata": {
119
- "kernelspec": {
120
- "display_name": "Python 3 (ipykernel)",
121
- "language": "python",
122
- "name": "python3"
123
- },
124
- "language_info": {
125
- "codemirror_mode": {
126
- "name": "ipython",
127
- "version": 3
128
- },
129
- "file_extension": ".py",
130
- "mimetype": "text/x-python",
131
- "name": "python",
132
- "nbconvert_exporter": "python",
133
- "pygments_lexer": "ipython3",
134
- "version": "3.12.4"
135
- }
136
- },
137
- "nbformat": 4,
138
- "nbformat_minor": 5
139
- }
@@ -1,181 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "d27dd480-bff5-4179-8b5d-145b15fe2527",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import numpy as np\n",
11
- "import pandas as pd\n",
12
- "import seaborn as sns\n",
13
- "import scipy\n",
14
- "import matplotlib.pyplot as plt"
15
- ]
16
- },
17
- {
18
- "cell_type": "code",
19
- "execution_count": null,
20
- "id": "c34c5236-de26-47a7-b047-c084519f6ef7",
21
- "metadata": {},
22
- "outputs": [],
23
- "source": [
24
- "data, _ = scipy.io.arff.loadarff('data/rice.arff')\n",
25
- "df = pd.DataFrame(data)\n",
26
- "print(\"Shape:\", df.shape)\n",
27
- "df.head()"
28
- ]
29
- },
30
- {
31
- "cell_type": "code",
32
- "execution_count": null,
33
- "id": "9ef13fe2-6f7f-4e9e-97bf-f44c0b10694e",
34
- "metadata": {},
35
- "outputs": [],
36
- "source": [
37
- "df.describe()"
38
- ]
39
- },
40
- {
41
- "cell_type": "code",
42
- "execution_count": null,
43
- "id": "0a51ae34-5fa4-4f78-a08c-de89bcc1f6b2",
44
- "metadata": {},
45
- "outputs": [],
46
- "source": [
47
- "df.info()"
48
- ]
49
- },
50
- {
51
- "cell_type": "code",
52
- "execution_count": null,
53
- "id": "3a30c508-273f-46cd-8ecd-8361b255488b",
54
- "metadata": {},
55
- "outputs": [],
56
- "source": [
57
- "df.isnull().sum()"
58
- ]
59
- },
60
- {
61
- "cell_type": "code",
62
- "execution_count": null,
63
- "id": "f0651a71-0bc1-489e-ad5f-7b080a9cb978",
64
- "metadata": {},
65
- "outputs": [],
66
- "source": [
67
- "sns.countplot(df, x='Class', hue='Class')\n",
68
- "plt.title(\"Class Distribution\")\n",
69
- "plt.show()"
70
- ]
71
- },
72
- {
73
- "cell_type": "code",
74
- "execution_count": null,
75
- "id": "e2d1c93f-e097-4b08-b9ff-48c7d5fd9659",
76
- "metadata": {},
77
- "outputs": [],
78
- "source": [
79
- "print(\"Mean of Features\")\n",
80
- "df.iloc[:, :-1].mean()"
81
- ]
82
- },
83
- {
84
- "cell_type": "code",
85
- "execution_count": null,
86
- "id": "0977bb62-192e-43f4-8cd9-e054ea3526b9",
87
- "metadata": {},
88
- "outputs": [],
89
- "source": [
90
- "cov = df.iloc[:, :-1].cov().round(3)\n",
91
- "print(\"Covariance Matrix\")\n",
92
- "cov"
93
- ]
94
- },
95
- {
96
- "cell_type": "code",
97
- "execution_count": null,
98
- "id": "e2862d9a-76b9-4367-a135-0fc36ae60478",
99
- "metadata": {},
100
- "outputs": [],
101
- "source": [
102
- "eigen_vals, eigen_vecs = np.linalg.eig(cov)\n",
103
- "mapping = {round(eigen_vals[i], 2): eigen_vecs[:, i].round(2) \n",
104
- " for i in range(len(eigen_vals))}\n",
105
- "print(\"Eigen Value-Vector Pairs:\")\n",
106
- "mapping"
107
- ]
108
- },
109
- {
110
- "cell_type": "code",
111
- "execution_count": null,
112
- "id": "06a3c671-6cae-44c7-9960-56702042c0e5",
113
- "metadata": {},
114
- "outputs": [],
115
- "source": [
116
- "n = 2\n",
117
- "sorted_eigen_vals = sorted(mapping.keys(), reverse=True)\n",
118
- "top_eigen_vals = sorted_eigen_vals[:n]\n",
119
- "top_eigen_vals"
120
- ]
121
- },
122
- {
123
- "cell_type": "code",
124
- "execution_count": null,
125
- "id": "6473c348-871e-428d-a3d6-7942fc0df706",
126
- "metadata": {},
127
- "outputs": [],
128
- "source": [
129
- "projection_matrix = np.array([mapping[val] for val in top_eigen_vals]).T\n",
130
- "projection_matrix"
131
- ]
132
- },
133
- {
134
- "cell_type": "code",
135
- "execution_count": null,
136
- "id": "6014c705-cb9a-470f-905f-ec05eb5f89f9",
137
- "metadata": {},
138
- "outputs": [],
139
- "source": [
140
- "X = df.iloc[:, :-1].values\n",
141
- "reduced_data = X.dot(projection_matrix)\n",
142
- "reduced_df = pd.DataFrame(reduced_data, columns=[f'PC{i+1}' for i in range(n)])\n",
143
- "reduced_df['Class'] = df['Class'].values\n",
144
- "reduced_df.head()"
145
- ]
146
- },
147
- {
148
- "cell_type": "code",
149
- "execution_count": null,
150
- "id": "f53faa36-3044-4a48-9512-f7bc947bd9ba",
151
- "metadata": {},
152
- "outputs": [],
153
- "source": [
154
- "sns.scatterplot(data=reduced_df, x='PC1', y='PC2', hue='Class')\n",
155
- "plt.title('Principle Component Analysis')\n",
156
- "plt.show()"
157
- ]
158
- }
159
- ],
160
- "metadata": {
161
- "kernelspec": {
162
- "display_name": "Python 3 (ipykernel)",
163
- "language": "python",
164
- "name": "python3"
165
- },
166
- "language_info": {
167
- "codemirror_mode": {
168
- "name": "ipython",
169
- "version": 3
170
- },
171
- "file_extension": ".py",
172
- "mimetype": "text/x-python",
173
- "name": "python",
174
- "nbconvert_exporter": "python",
175
- "pygments_lexer": "ipython3",
176
- "version": "3.12.4"
177
- }
178
- },
179
- "nbformat": 4,
180
- "nbformat_minor": 5
181
- }