noshot 6.0.0__py3-none-any.whl → 7.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 (43) hide show
  1. noshot/data/ML TS XAI/ML/Rolls Royce AllinOne.ipynb +691 -0
  2. noshot/data/ML TS XAI/ML/Tamilan Code/1. EDA-PCA (Balance Scale Dataset).ipynb +147 -0
  3. noshot/data/ML TS XAI/ML/Tamilan Code/1. EDA-PCA (Rice Dataset).ipynb +181 -0
  4. noshot/data/ML TS XAI/ML/Tamilan Code/10. HMM Veterbi.ipynb +152 -0
  5. noshot/data/ML TS XAI/ML/Tamilan Code/2. KNN (Balance Scale Dataset).ipynb +117 -0
  6. noshot/data/ML TS XAI/ML/Tamilan Code/2. KNN (Iris Dataset).ipynb +156 -0
  7. noshot/data/ML TS XAI/ML/Tamilan Code/2. KNN (Sobar-72 Dataset).ipynb +215 -0
  8. noshot/data/ML TS XAI/ML/Tamilan Code/3. LDA (Balance Scale Dataset).ipynb +78 -0
  9. noshot/data/ML TS XAI/ML/Tamilan Code/3. LDA (NPHA Doctor Visits Dataset).ipynb +114 -0
  10. noshot/data/ML TS XAI/ML/Tamilan Code/4. Linear Regression (Machine Dataset).ipynb +115 -0
  11. noshot/data/ML TS XAI/ML/Tamilan Code/4. Linear Regression (Real Estate Dataset).ipynb +146 -0
  12. noshot/data/ML TS XAI/ML/Tamilan Code/5. Logistic Regression (Magic04 Dataset).ipynb +130 -0
  13. noshot/data/ML TS XAI/ML/Tamilan Code/5. Logistic Regression (Wine Dataset).ipynb +112 -0
  14. noshot/data/ML TS XAI/ML/Tamilan Code/6. Naive Bayes Classifier (Agaricus Lepiota Dataset).ipynb +118 -0
  15. noshot/data/ML TS XAI/ML/Tamilan Code/6. Naive Bayes Classifier (Wine Dataset).ipynb +89 -0
  16. noshot/data/ML TS XAI/ML/Tamilan Code/7. SVM (Rice Dataset).ipynb +120 -0
  17. noshot/data/ML TS XAI/ML/Tamilan Code/8. FeedForward NN (Sobar72 Dataset).ipynb +262 -0
  18. noshot/data/ML TS XAI/ML/Tamilan Code/9. CNN (Cifar10 Dataset).ipynb +156 -0
  19. noshot/data/ML TS XAI/ML/Whitefang Code/1. PCA.ipynb +162 -0
  20. noshot/data/ML TS XAI/ML/Whitefang Code/10. CNN.ipynb +100 -0
  21. noshot/data/ML TS XAI/ML/Whitefang Code/11. HMM.ipynb +336 -0
  22. noshot/data/ML TS XAI/ML/Whitefang Code/2. KNN.ipynb +149 -0
  23. noshot/data/ML TS XAI/ML/Whitefang Code/3. LDA.ipynb +132 -0
  24. noshot/data/ML TS XAI/ML/Whitefang Code/4. Linear Regression.ipynb +86 -0
  25. noshot/data/ML TS XAI/ML/Whitefang Code/5. Logistic Regression.ipynb +115 -0
  26. noshot/data/ML TS XAI/ML/Whitefang Code/6. Naive Bayes (Titanic).ipynb +196 -0
  27. noshot/data/ML TS XAI/ML/Whitefang Code/6. Naive Bayes (Wine).ipynb +98 -0
  28. noshot/data/ML TS XAI/ML/Whitefang Code/7. SVM Linear.ipynb +109 -0
  29. noshot/data/ML TS XAI/ML/Whitefang Code/8. SVM Non-Linear.ipynb +195 -0
  30. noshot/data/ML TS XAI/ML/Whitefang Code/9. FNN With Regularization.ipynb +189 -0
  31. noshot/data/ML TS XAI/ML/Whitefang Code/9. FNN Without Regularization.ipynb +197 -0
  32. noshot/data/ML TS XAI/ML/Whitefang Code/All in One Lab CIA 1 Q.ipynb +1087 -0
  33. {noshot-6.0.0.dist-info → noshot-7.0.0.dist-info}/METADATA +1 -1
  34. noshot-7.0.0.dist-info/RECORD +41 -0
  35. {noshot-6.0.0.dist-info → noshot-7.0.0.dist-info}/WHEEL +1 -1
  36. noshot/data/ML TS XAI/XAI/Q1.ipynb +0 -377
  37. noshot/data/ML TS XAI/XAI/Q2.ipynb +0 -362
  38. noshot/data/ML TS XAI/XAI/Q3.ipynb +0 -637
  39. noshot/data/ML TS XAI/XAI/Q4.ipynb +0 -206
  40. noshot/data/ML TS XAI/XAI/Q5.ipynb +0 -1018
  41. noshot-6.0.0.dist-info/RECORD +0 -14
  42. {noshot-6.0.0.dist-info → noshot-7.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  43. {noshot-6.0.0.dist-info → noshot-7.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,197 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {
7
+ "colab": {
8
+ "base_uri": "https://localhost:8080/",
9
+ "height": 1000
10
+ },
11
+ "executionInfo": {
12
+ "elapsed": 15796,
13
+ "status": "ok",
14
+ "timestamp": 1743486879713,
15
+ "user": {
16
+ "displayName": "Jaison A",
17
+ "userId": "07006398627763032071"
18
+ },
19
+ "user_tz": -330
20
+ },
21
+ "id": "S919d8O06g3w",
22
+ "outputId": "a9c34590-8cf2-4bcc-de16-ebbea74d63b7"
23
+ },
24
+ "outputs": [],
25
+ "source": [
26
+ "import pandas as pd\n",
27
+ "import numpy as np\n",
28
+ "import matplotlib.pyplot as plt\n",
29
+ "from sklearn.neural_network import MLPClassifier\n",
30
+ "from sklearn.model_selection import train_test_split\n",
31
+ "from sklearn.metrics import classification_report, confusion_matrix, accuracy_score\n",
32
+ "from sklearn.preprocessing import StandardScaler, LabelEncoder\n",
33
+ "from sklearn.impute import SimpleImputer\n",
34
+ "\n",
35
+ "# Load dataset\n",
36
+ "df = pd.read_csv('/content/heart_disease_uci.csv')\n",
37
+ "\n",
38
+ "# Data preprocessing\n",
39
+ "# Handle missing values - fill numeric with median, categorical with mode\n",
40
+ "numeric_cols = ['age', 'trestbps', 'chol', 'thalch', 'oldpeak']\n",
41
+ "categorical_cols = ['sex', 'cp', 'fbs', 'restecg', 'exang', 'slope', 'ca', 'thal']\n",
42
+ "\n",
43
+ "# Impute missing values\n",
44
+ "imputer_num = SimpleImputer(strategy='median')\n",
45
+ "df[numeric_cols] = imputer_num.fit_transform(df[numeric_cols])\n",
46
+ "\n",
47
+ "imputer_cat = SimpleImputer(strategy='most_frequent')\n",
48
+ "df[categorical_cols] = imputer_cat.fit_transform(df[categorical_cols])\n",
49
+ "\n",
50
+ "# Encode categorical variables\n",
51
+ "label_encoders = {}\n",
52
+ "for col in categorical_cols:\n",
53
+ " le = LabelEncoder()\n",
54
+ " df[col] = le.fit_transform(df[col].astype(str)) # Convert to string before encoding\n",
55
+ " label_encoders[col] = le\n",
56
+ "\n",
57
+ "# Target variable - assuming 'num' is the target (0 = no disease, >0 = disease)\n",
58
+ "df['target'] = (df['num'] > 0).astype(int)\n",
59
+ "\n",
60
+ "# Select features and target\n",
61
+ "features = numeric_cols + categorical_cols\n",
62
+ "X = df[features]\n",
63
+ "y = df['target']\n",
64
+ "\n",
65
+ "# Split data\n",
66
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)\n",
67
+ "\n",
68
+ "# Standardize features\n",
69
+ "scaler = StandardScaler()\n",
70
+ "X_train = scaler.fit_transform(X_train)\n",
71
+ "X_test = scaler.transform(X_test)\n",
72
+ "\n",
73
+ "# Function to evaluate different configurations\n",
74
+ "def evaluate_model(hidden_layer_sizes, activation, max_iter=500):\n",
75
+ " model = MLPClassifier(hidden_layer_sizes=hidden_layer_sizes,\n",
76
+ " activation=activation,\n",
77
+ " max_iter=max_iter,\n",
78
+ " random_state=42)\n",
79
+ " model.fit(X_train, y_train)\n",
80
+ " y_pred = model.predict(X_test)\n",
81
+ " accuracy = accuracy_score(y_test, y_pred)\n",
82
+ " return accuracy, model.loss_curve_\n",
83
+ "\n",
84
+ "# Test different configurations\n",
85
+ "configurations = [\n",
86
+ " {\"hidden\": (10,), \"activation\": \"relu\", \"name\": \"Single(10) - ReLU\"},\n",
87
+ " {\"hidden\": (30,), \"activation\": \"tanh\", \"name\": \"Single(30) - Tanh\"},\n",
88
+ " {\"hidden\": (10, 10), \"activation\": \"relu\", \"name\": \"Double(10,10) - ReLU\"},\n",
89
+ " {\"hidden\": (20, 10), \"activation\": \"logistic\", \"name\": \"Double(20,10) - Logistic\"},\n",
90
+ " {\"hidden\": (10, 5, 3), \"activation\": \"relu\", \"name\": \"Triple(10,5,3) - ReLU\"},\n",
91
+ " {\"hidden\": (20, 15, 10), \"activation\": \"tanh\", \"name\": \"Triple(20,15,10) - Tanh\"},\n",
92
+ "]\n",
93
+ "\n",
94
+ "results = []\n",
95
+ "loss_curves = []\n",
96
+ "\n",
97
+ "for config in configurations:\n",
98
+ " accuracy, loss_curve = evaluate_model(config[\"hidden\"], config[\"activation\"])\n",
99
+ " results.append({\n",
100
+ " \"Configuration\": config[\"name\"],\n",
101
+ " \"Accuracy\": accuracy,\n",
102
+ " \"Activation\": config[\"activation\"],\n",
103
+ " \"Architecture\": str(config[\"hidden\"])\n",
104
+ " })\n",
105
+ " loss_curves.append((config[\"name\"], loss_curve))\n",
106
+ "\n",
107
+ " # Print detailed report for each configuration\n",
108
+ " print(f\"\\nConfiguration: {config['name']}\")\n",
109
+ " print(\"Classification Report:\")\n",
110
+ " model = MLPClassifier(hidden_layer_sizes=config[\"hidden\"],\n",
111
+ " activation=config[\"activation\"],\n",
112
+ " max_iter=500,\n",
113
+ " random_state=42)\n",
114
+ " model.fit(X_train, y_train)\n",
115
+ " y_pred = model.predict(X_test)\n",
116
+ " print(classification_report(y_test, y_pred))\n",
117
+ " print(\"Confusion Matrix:\")\n",
118
+ " print(confusion_matrix(y_test, y_pred))\n",
119
+ "\n",
120
+ "# Display results\n",
121
+ "results_df = pd.DataFrame(results)\n",
122
+ "print(\"\\nSummary of Results:\")\n",
123
+ "print(results_df.sort_values(by=\"Accuracy\", ascending=False))\n",
124
+ "\n",
125
+ "# Visualization\n",
126
+ "plt.figure(figsize=(14, 6))\n",
127
+ "\n",
128
+ "# Accuracy comparison\n",
129
+ "plt.subplot(1, 2, 1)\n",
130
+ "plt.barh(results_df['Configuration'], results_df['Accuracy'], color='skyblue')\n",
131
+ "plt.title('Test Accuracy by Configuration')\n",
132
+ "plt.xlabel('Accuracy')\n",
133
+ "plt.xlim(0.7, 0.9)\n",
134
+ "\n",
135
+ "# Training loss curves\n",
136
+ "plt.subplot(1, 2, 2)\n",
137
+ "for name, curve in loss_curves:\n",
138
+ " plt.plot(curve, label=name)\n",
139
+ "plt.title('Training Loss Across Configurations')\n",
140
+ "plt.xlabel('Iterations')\n",
141
+ "plt.ylabel('Loss')\n",
142
+ "plt.legend()\n",
143
+ "plt.grid()\n",
144
+ "\n",
145
+ "plt.tight_layout()\n",
146
+ "plt.show()\n",
147
+ "\n",
148
+ "# Feature importance analysis (using weights from the best model)\n",
149
+ "best_config_idx = np.argmax(results_df['Accuracy'])\n",
150
+ "best_model = MLPClassifier(hidden_layer_sizes=configurations[best_config_idx][\"hidden\"],\n",
151
+ " activation=configurations[best_config_idx][\"activation\"],\n",
152
+ " max_iter=500,\n",
153
+ " random_state=42)\n",
154
+ "best_model.fit(X_train, y_train)\n",
155
+ "\n",
156
+ "# Get the weights from input to first hidden layer\n",
157
+ "if len(best_model.coefs_) > 0:\n",
158
+ " input_weights = best_model.coefs_[0]\n",
159
+ " feature_importance = np.mean(np.abs(input_weights), axis=1)\n",
160
+ "\n",
161
+ " plt.figure(figsize=(10, 6))\n",
162
+ " plt.barh(features, feature_importance)\n",
163
+ " plt.title('Feature Importance (Average Absolute Weight)')\n",
164
+ " plt.xlabel('Importance')\n",
165
+ " plt.tight_layout()\n",
166
+ " plt.show()\n",
167
+ "else:\n",
168
+ " print(\"Could not extract feature importance - model weights not available\")"
169
+ ]
170
+ }
171
+ ],
172
+ "metadata": {
173
+ "colab": {
174
+ "authorship_tag": "ABX9TyPivrGG2d31eEVHX9BuG3D8",
175
+ "provenance": []
176
+ },
177
+ "kernelspec": {
178
+ "display_name": "Python 3 (ipykernel)",
179
+ "language": "python",
180
+ "name": "python3"
181
+ },
182
+ "language_info": {
183
+ "codemirror_mode": {
184
+ "name": "ipython",
185
+ "version": 3
186
+ },
187
+ "file_extension": ".py",
188
+ "mimetype": "text/x-python",
189
+ "name": "python",
190
+ "nbconvert_exporter": "python",
191
+ "pygments_lexer": "ipython3",
192
+ "version": "3.12.4"
193
+ }
194
+ },
195
+ "nbformat": 4,
196
+ "nbformat_minor": 4
197
+ }