noshot 1.0.0__py3-none-any.whl → 2.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 (34) hide show
  1. noshot/data/ML TS XAI/TS/bill-charge.ipynb +239 -0
  2. noshot/data/ML TS XAI/{XAI/XAI 2/Exp-3 (EDA-loan).ipynb → TS/daily-min-temperatures.ipynb } +68 -50
  3. noshot/data/ML TS XAI/TS/data/bill-data.csv +21 -0
  4. noshot/data/ML TS XAI/TS/data/daily-min-temperatures.csv +3651 -0
  5. noshot/data/ML TS XAI/TS/data/monthly-sunspots.csv +2821 -0
  6. noshot/data/ML TS XAI/TS/monthly-sunspots.ipynb +241 -0
  7. {noshot-1.0.0.dist-info → noshot-2.0.0.dist-info}/METADATA +1 -1
  8. noshot-2.0.0.dist-info/RECORD +15 -0
  9. {noshot-1.0.0.dist-info → noshot-2.0.0.dist-info}/WHEEL +1 -1
  10. noshot/data/ML TS XAI/TS/10. Seasonal ARIMA Forecasting.ipynb +0 -246
  11. noshot/data/ML TS XAI/TS/11. Multivariate ARIMA Forecasting.ipynb +0 -228
  12. noshot/data/ML TS XAI/TS/6. ACF PACF.ipynb +0 -77
  13. noshot/data/ML TS XAI/TS/7. Differencing.ipynb +0 -167
  14. noshot/data/ML TS XAI/TS/8. ARMA Forecasting.ipynb +0 -197
  15. noshot/data/ML TS XAI/TS/9. ARIMA Forecasting.ipynb +0 -220
  16. noshot/data/ML TS XAI/XAI/XAI 1/EDA2_chipsdatset.ipynb +0 -633
  17. noshot/data/ML TS XAI/XAI/XAI 1/EDA_IRISH_8thjan.ipynb +0 -326
  18. noshot/data/ML TS XAI/XAI/XAI 1/XAI_EX1 MODEL BIAS (FINAL).ipynb +0 -487
  19. noshot/data/ML TS XAI/XAI/XAI 1/complete_guide_to_eda_on_text_data.ipynb +0 -845
  20. noshot/data/ML TS XAI/XAI/XAI 1/deepchecksframeworks.ipynb +0 -100
  21. noshot/data/ML TS XAI/XAI/XAI 1/deepexplainers (mnist).ipynb +0 -90
  22. noshot/data/ML TS XAI/XAI/XAI 1/guidedbackpropagation.ipynb +0 -203
  23. noshot/data/ML TS XAI/XAI/XAI 1/updated_image_EDA1_with_LRP.ipynb +0 -3998
  24. noshot/data/ML TS XAI/XAI/XAI 1/zebrastripes.ipynb +0 -271
  25. noshot/data/ML TS XAI/XAI/XAI 2/EXP_5.ipynb +0 -1545
  26. noshot/data/ML TS XAI/XAI/XAI 2/Exp-3 (EDA-movie).ipynb +0 -229
  27. noshot/data/ML TS XAI/XAI/XAI 2/Exp-4(Flower dataset).ipynb +0 -237
  28. noshot/data/ML TS XAI/XAI/XAI 2/Exp-4.ipynb +0 -241
  29. noshot/data/ML TS XAI/XAI/XAI 2/Exp_2.ipynb +0 -352
  30. noshot/data/ML TS XAI/XAI/XAI 2/Exp_7.ipynb +0 -110
  31. noshot/data/ML TS XAI/XAI/XAI 2/FeatureImportance_SensitivityAnalysis.ipynb +0 -708
  32. noshot-1.0.0.dist-info/RECORD +0 -32
  33. {noshot-1.0.0.dist-info → noshot-2.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  34. {noshot-1.0.0.dist-info → noshot-2.0.0.dist-info}/top_level.txt +0 -0
@@ -1,100 +0,0 @@
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
- "resources": {
11
- "http://localhost:8080/jupyterlab-plotly.js": {
12
- "data": "",
13
- "headers": [
14
- [
15
- "content-length",
16
- "0"
17
- ]
18
- ],
19
- "ok": false,
20
- "status": 404,
21
- "status_text": ""
22
- }
23
- }
24
- },
25
- "id": "mJC5pjBETXIW",
26
- "outputId": "2d1d08a1-9acb-4a24-bb57-83c35a4f62d6"
27
- },
28
- "outputs": [],
29
- "source": [
30
- "import pandas as pd\n",
31
- "from sklearn.model_selection import train_test_split\n",
32
- "!pip install deepchecks\n",
33
- "from deepchecks.tabular import Dataset\n",
34
- "from deepchecks.suites import data_integrity, train_test_validation\n",
35
- "\n",
36
- "# Load the dataset manually (replace with the actual path)\n",
37
- "file_path = \"adult.csv\" # Update this with your dataset file path\n",
38
- "column_names = [\n",
39
- " 'age', 'workclass', 'fnlwgt', 'education', 'education-num', 'marital-status',\n",
40
- " 'occupation', 'relationship', 'race', 'sex', 'capital-gain', 'capital-loss',\n",
41
- " 'hours-per-week', 'native-country', 'income'\n",
42
- "]\n",
43
- "\n",
44
- "# Read CSV file\n",
45
- "df = pd.read_csv(file_path, names=column_names, skipinitialspace=True)\n",
46
- "\n",
47
- "# Convert categorical features to string (if needed)\n",
48
- "cat_features = ['workclass', 'education', 'marital-status', 'occupation',\n",
49
- " 'relationship', 'race', 'sex', 'native-country']\n",
50
- "\n",
51
- "df[cat_features] = df[cat_features].astype(str)\n",
52
- "\n",
53
- "# Separate features and labels\n",
54
- "X = df.drop(columns=['income'])\n",
55
- "y = df['income']\n",
56
- "\n",
57
- "# Split into train and test sets\n",
58
- "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
59
- "\n",
60
- "# Create Deepchecks Dataset objects\n",
61
- "train_ds = Dataset(X_train, label=y_train, cat_features=cat_features)\n",
62
- "test_ds = Dataset(X_test, label=y_test, cat_features=cat_features)\n",
63
- "\n",
64
- "# Run Data Integrity Suite\n",
65
- "integrity_suite = data_integrity()\n",
66
- "integrity_result = integrity_suite.run(train_ds)\n",
67
- "integrity_result.show()\n",
68
- "\n",
69
- "# Run Train-Test Validation Suite\n",
70
- "validation_suite = train_test_validation()\n",
71
- "validation_result = validation_suite.run(train_ds, test_ds)\n",
72
- "validation_result.show()\n"
73
- ]
74
- }
75
- ],
76
- "metadata": {
77
- "colab": {
78
- "provenance": []
79
- },
80
- "kernelspec": {
81
- "display_name": "Python 3 (ipykernel)",
82
- "language": "python",
83
- "name": "python3"
84
- },
85
- "language_info": {
86
- "codemirror_mode": {
87
- "name": "ipython",
88
- "version": 3
89
- },
90
- "file_extension": ".py",
91
- "mimetype": "text/x-python",
92
- "name": "python",
93
- "nbconvert_exporter": "python",
94
- "pygments_lexer": "ipython3",
95
- "version": "3.12.4"
96
- }
97
- },
98
- "nbformat": 4,
99
- "nbformat_minor": 4
100
- }
@@ -1,90 +0,0 @@
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
- "id": "hGTdvcVMiIrP",
12
- "outputId": "4581c094-26c9-4b7c-d4e3-7c69d8a81713"
13
- },
14
- "outputs": [],
15
- "source": [
16
- "import shap\n",
17
- "import tensorflow as tf\n",
18
- "import numpy as np\n",
19
- "import matplotlib.pyplot as plt\n",
20
- "\n",
21
- "# Load a sample dataset (for demonstration, using MNIST)\n",
22
- "from tensorflow.keras.datasets import mnist\n",
23
- "from tensorflow.keras.models import Sequential\n",
24
- "from tensorflow.keras.layers import Dense, Flatten\n",
25
- "\n",
26
- "# Load MNIST dataset\n",
27
- "(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
28
- "\n",
29
- "# Normalize pixel values to 0-1\n",
30
- "x_train, x_test = x_train / 255.0, x_test / 255.0\n",
31
- "\n",
32
- "# Build a simple neural network\n",
33
- "model = Sequential([\n",
34
- " Flatten(input_shape=(28, 28)),\n",
35
- " Dense(128, activation='relu'),\n",
36
- " Dense(10, activation='softmax')\n",
37
- "])\n",
38
- "\n",
39
- "# Compile the model\n",
40
- "model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])\n",
41
- "\n",
42
- "# Train the model (using fewer epochs for quick results)\n",
43
- "model.fit(x_train, y_train, epochs=3, batch_size=128, validation_data=(x_test, y_test))\n",
44
- "\n",
45
- "# Select background data for SHAP explanations\n",
46
- "background = x_train[np.random.choice(x_train.shape[0], 100, replace=False)]\n",
47
- "\n",
48
- "# ✅ Initialize SHAP DeepExplainer\n",
49
- "explainer = shap.DeepExplainer(model, background)\n",
50
- "\n",
51
- "# Select a few test samples\n",
52
- "X_test_sample = x_test[:10]\n",
53
- "\n",
54
- "# ✅ Compute SHAP values\n",
55
- "shap_values = explainer.shap_values(X_test_sample)\n",
56
- "\n",
57
- "# ✅ Visualize SHAP values for an image\n",
58
- "# Plot the SHAP values for class 0 (change index to see for other classes)\n",
59
- "index = 0 # Change this to visualize different images\n",
60
- "\n",
61
- "plt.figure(figsize=(8, 4))\n",
62
- "shap.image_plot(shap_values, X_test_sample)\n"
63
- ]
64
- }
65
- ],
66
- "metadata": {
67
- "colab": {
68
- "provenance": []
69
- },
70
- "kernelspec": {
71
- "display_name": "Python 3 (ipykernel)",
72
- "language": "python",
73
- "name": "python3"
74
- },
75
- "language_info": {
76
- "codemirror_mode": {
77
- "name": "ipython",
78
- "version": 3
79
- },
80
- "file_extension": ".py",
81
- "mimetype": "text/x-python",
82
- "name": "python",
83
- "nbconvert_exporter": "python",
84
- "pygments_lexer": "ipython3",
85
- "version": "3.12.4"
86
- }
87
- },
88
- "nbformat": 4,
89
- "nbformat_minor": 4
90
- }
@@ -1,203 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "metadata": {
7
- "colab": {
8
- "base_uri": "https://localhost:8080/",
9
- "height": 406
10
- },
11
- "id": "t71r0zijG0_7",
12
- "outputId": "e772d9a6-eaf7-4363-b00a-4e46913ae149"
13
- },
14
- "outputs": [],
15
- "source": [
16
- "import torch\n",
17
- "import torch.nn as nn\n",
18
- "from torchvision import models, transforms\n",
19
- "from PIL import Image\n",
20
- "import numpy as np\n",
21
- "import matplotlib.pyplot as plt\n",
22
- "\n",
23
- "\n",
24
- "# Custom Guided Backpropagation ReLU\n",
25
- "class GuidedBackpropReLU(nn.Module):\n",
26
- " def forward(self, input):\n",
27
- " return torch.relu(input)\n",
28
- "\n",
29
- " def backward(self, grad_output):\n",
30
- " grad_input = torch.clamp(grad_output, min=0.0)\n",
31
- " return grad_input\n",
32
- "\n",
33
- "\n",
34
- "# Replace ReLU with GuidedBackpropReLU\n",
35
- "def replace_relu_with_guided(model):\n",
36
- " for name, module in model.named_children():\n",
37
- " if isinstance(module, nn.ReLU):\n",
38
- " setattr(model, name, GuidedBackpropReLU())\n",
39
- " else:\n",
40
- " replace_relu_with_guided(module)\n",
41
- "\n",
42
- "\n",
43
- "# Preprocess the input image\n",
44
- "def preprocess_image(image_path):\n",
45
- " preprocess = transforms.Compose([\n",
46
- " transforms.Resize((224, 224)),\n",
47
- " transforms.ToTensor(),\n",
48
- " transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),\n",
49
- " ])\n",
50
- " image = Image.open(image_path).convert('RGB')\n",
51
- " return preprocess(image).unsqueeze(0) # Add batch dimension\n",
52
- "\n",
53
- "\n",
54
- "# Guided Backpropagation function\n",
55
- "def guided_backpropagation(model, input_image, target_class):\n",
56
- " model.eval() # Set model to evaluation mode\n",
57
- " input_image.requires_grad = True # Enable gradient computation for input\n",
58
- "\n",
59
- " replace_relu_with_guided(model) # Replace all ReLU activations\n",
60
- "\n",
61
- " output = model(input_image) # Forward pass\n",
62
- " loss = output[0, target_class] # Target class loss\n",
63
- " model.zero_grad() # Zero out gradients\n",
64
- " loss.backward() # Backward pass\n",
65
- "\n",
66
- " return input_image.grad.data # Return gradients w.r.t. input image\n",
67
- "\n",
68
- "\n",
69
- "# Visualize the gradients\n",
70
- "def visualize_gradients(gradients):\n",
71
- " gradients = gradients[0].cpu().numpy() # Remove batch dimension\n",
72
- " gradients = np.moveaxis(gradients, 0, -1) # Rearrange channels to last dimension\n",
73
- " gradients = (gradients - gradients.min()) / (gradients.max() - gradients.min()) # Normalize\n",
74
- " plt.imshow(gradients)\n",
75
- " plt.axis('off')\n",
76
- " plt.show()\n",
77
- "\n",
78
- "\n",
79
- "# Main script\n",
80
- "if __name__ == \"__main__\":\n",
81
- " # Load a pretrained model\n",
82
- " model = models.vgg16(pretrained=True)\n",
83
- "\n",
84
- " # Load and preprocess the input image\n",
85
- " image_path = \"/content/g2.jpeg\" # Replace with the path to your image\n",
86
- " input_image = preprocess_image(image_path)\n",
87
- "\n",
88
- " # Define target class (e.g., 'bull mastiff' class in ImageNet)\n",
89
- " target_class = 243\n",
90
- "\n",
91
- " # Move to device (CPU/GPU)\n",
92
- " device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
93
- " model = model.to(device)\n",
94
- " input_image = input_image.to(device)\n",
95
- "\n",
96
- " # Perform Guided Backpropagation\n",
97
- " gradients = guided_backpropagation(model, input_image, target_class)\n",
98
- "\n",
99
- " # Visualize the gradients\n",
100
- " visualize_gradients(gradients)\n"
101
- ]
102
- },
103
- {
104
- "cell_type": "code",
105
- "execution_count": null,
106
- "metadata": {
107
- "id": "x5z8OBtLIqWh"
108
- },
109
- "outputs": [],
110
- "source": [
111
- "gradients = (gradients - gradients.min()) / (gradients.max() - gradients.min()) # Normalize\n"
112
- ]
113
- },
114
- {
115
- "cell_type": "code",
116
- "execution_count": null,
117
- "metadata": {
118
- "colab": {
119
- "base_uri": "https://localhost:8080/"
120
- },
121
- "id": "tIlhZt2SIt8S",
122
- "outputId": "d22fdb34-f725-41d1-9117-5a8456daddbc"
123
- },
124
- "outputs": [],
125
- "source": [
126
- "print(\"Gradient shape:\", gradients.shape)\n"
127
- ]
128
- },
129
- {
130
- "cell_type": "code",
131
- "execution_count": null,
132
- "metadata": {
133
- "colab": {
134
- "base_uri": "https://localhost:8080/"
135
- },
136
- "id": "PxPrybk2JQdQ",
137
- "outputId": "f3e1ed74-8b5b-476c-e70e-f682a528d2a1"
138
- },
139
- "outputs": [],
140
- "source": [
141
- "output = model(input_image)\n",
142
- "print(\"Model output:\", output)\n"
143
- ]
144
- },
145
- {
146
- "cell_type": "code",
147
- "execution_count": null,
148
- "metadata": {
149
- "colab": {
150
- "base_uri": "https://localhost:8080/"
151
- },
152
- "id": "hOjkXsMrJZF3",
153
- "outputId": "65173d32-1016-4616-dfd4-3cb6cc858615"
154
- },
155
- "outputs": [],
156
- "source": [
157
- "gradients = guided_backpropagation(model, input_image, target_class)\n",
158
- "print(\"Gradients shape:\", gradients.shape) # Should be [1, 3, 224, 224] for a single image\n"
159
- ]
160
- },
161
- {
162
- "cell_type": "code",
163
- "execution_count": null,
164
- "metadata": {
165
- "colab": {
166
- "base_uri": "https://localhost:8080/",
167
- "height": 434
168
- },
169
- "id": "dXeuco_bJd8h",
170
- "outputId": "f7bef501-ada9-4afb-8531-c069bd1d417a"
171
- },
172
- "outputs": [],
173
- "source": [
174
- "plt.imshow(gradients[0].cpu().numpy()[0], cmap='hot') # Display the first channel's gradients\n",
175
- "plt.show()"
176
- ]
177
- }
178
- ],
179
- "metadata": {
180
- "colab": {
181
- "provenance": []
182
- },
183
- "kernelspec": {
184
- "display_name": "Python 3 (ipykernel)",
185
- "language": "python",
186
- "name": "python3"
187
- },
188
- "language_info": {
189
- "codemirror_mode": {
190
- "name": "ipython",
191
- "version": 3
192
- },
193
- "file_extension": ".py",
194
- "mimetype": "text/x-python",
195
- "name": "python",
196
- "nbconvert_exporter": "python",
197
- "pygments_lexer": "ipython3",
198
- "version": "3.12.4"
199
- }
200
- },
201
- "nbformat": 4,
202
- "nbformat_minor": 4
203
- }