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.
- noshot/data/DLE FSD BDA/DLE/1. DNN (Image Classification).ipynb +389 -0
- noshot/data/DLE FSD BDA/DLE/2. DNN vs CNN.ipynb +516 -0
- noshot/data/DLE FSD BDA/DLE/3. CNN (Object Detecrion).ipynb +259 -0
- noshot/data/DLE FSD BDA/DLE/4. FCN (Image Segmentaion).ipynb +274 -0
- noshot/main.py +3 -3
- {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/METADATA +1 -1
- noshot-12.0.0.dist-info/RECORD +13 -0
- {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/WHEEL +1 -1
- noshot/data/ML TS XAI/ML/CNN(Image_for_Folders_5).ipynb +0 -201
- noshot/data/ML TS XAI/ML/CNN(Image_form_Folder_2).ipynb +0 -201
- noshot/data/ML TS XAI/ML/Json Codes/ML LAB CIA 2.ipynb +0 -409
- noshot/data/ML TS XAI/ML/ML 1/1. EDA-PCA (Balance Scale Dataset).ipynb +0 -147
- noshot/data/ML TS XAI/ML/ML 1/1. EDA-PCA (Rice Dataset).ipynb +0 -181
- noshot/data/ML TS XAI/ML/ML 1/10. HMM Veterbi.ipynb +0 -152
- noshot/data/ML TS XAI/ML/ML 1/2. KNN (Balance Scale Dataset).ipynb +0 -117
- noshot/data/ML TS XAI/ML/ML 1/2. KNN (Iris Dataset).ipynb +0 -156
- noshot/data/ML TS XAI/ML/ML 1/2. KNN (Sobar-72 Dataset).ipynb +0 -215
- noshot/data/ML TS XAI/ML/ML 1/3. LDA (Balance Scale Dataset).ipynb +0 -78
- noshot/data/ML TS XAI/ML/ML 1/3. LDA (NPHA Doctor Visits Dataset).ipynb +0 -114
- noshot/data/ML TS XAI/ML/ML 1/4. Linear Regression (Machine Dataset).ipynb +0 -115
- noshot/data/ML TS XAI/ML/ML 1/4. Linear Regression (Real Estate Dataset).ipynb +0 -146
- noshot/data/ML TS XAI/ML/ML 1/5. Logistic Regression (Magic04 Dataset).ipynb +0 -130
- noshot/data/ML TS XAI/ML/ML 1/5. Logistic Regression (Wine Dataset).ipynb +0 -112
- noshot/data/ML TS XAI/ML/ML 1/6. Naive Bayes Classifier (Agaricus Lepiota Dataset).ipynb +0 -118
- noshot/data/ML TS XAI/ML/ML 1/6. Naive Bayes Classifier (Wine Dataset).ipynb +0 -89
- noshot/data/ML TS XAI/ML/ML 1/7. SVM (Rice Dataset).ipynb +0 -120
- noshot/data/ML TS XAI/ML/ML 1/8. FeedForward NN (Sobar72 Dataset).ipynb +0 -262
- noshot/data/ML TS XAI/ML/ML 1/9. CNN (Cifar10 Dataset).ipynb +0 -156
- noshot/data/ML TS XAI/ML/ML 2/1. PCA.ipynb +0 -162
- noshot/data/ML TS XAI/ML/ML 2/10. CNN.ipynb +0 -100
- noshot/data/ML TS XAI/ML/ML 2/11. HMM.ipynb +0 -336
- noshot/data/ML TS XAI/ML/ML 2/2. KNN.ipynb +0 -149
- noshot/data/ML TS XAI/ML/ML 2/3. LDA.ipynb +0 -132
- noshot/data/ML TS XAI/ML/ML 2/4. Linear Regression.ipynb +0 -86
- noshot/data/ML TS XAI/ML/ML 2/5. Logistic Regression.ipynb +0 -115
- noshot/data/ML TS XAI/ML/ML 2/6. Naive Bayes (Titanic).ipynb +0 -196
- noshot/data/ML TS XAI/ML/ML 2/6. Naive Bayes (Wine).ipynb +0 -98
- noshot/data/ML TS XAI/ML/ML 2/7. SVM Linear.ipynb +0 -109
- noshot/data/ML TS XAI/ML/ML 2/8. SVM Non-Linear.ipynb +0 -195
- noshot/data/ML TS XAI/ML/ML 2/9. FNN With Regularization.ipynb +0 -189
- noshot/data/ML TS XAI/ML/ML 2/9. FNN Without Regularization.ipynb +0 -197
- noshot/data/ML TS XAI/ML/ML 2/All in One Lab CIA 1 Q.ipynb +0 -1087
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/1. PCA EDA.ipynb +0 -274
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/10. CNN.ipynb +0 -170
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 2.ipynb +0 -1087
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 3.ipynb +0 -178
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 4.ipynb +0 -185
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM.ipynb +0 -106
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/2. KNN.ipynb +0 -177
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/3. LDA.ipynb +0 -195
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/4. Linear Regression.ipynb +0 -267
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/5. Logistic Regression.ipynb +0 -104
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/6. Bayesian Classifier.ipynb +0 -109
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/7. SVM.ipynb +0 -220
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/8. MLP.ipynb +0 -99
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/9. Ridge - Lasso.ipynb +0 -211
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/9. Ridge Lasso 2.ipynb +0 -99
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/Image Load Example.ipynb +0 -118
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/Updated_Untitled.ipynb +0 -603
- noshot/data/ML TS XAI/ML/ML Lab AllinOne.ipynb +0 -961
- noshot/data/ML TS XAI/ML/ML Lab H Sec/1. Iris Dataset (Softmax vs Sigmoid).ipynb +0 -231
- noshot/data/ML TS XAI/ML/ML Lab H Sec/2. Student Dataset (Overfit vs Regularized).ipynb +0 -269
- noshot/data/ML TS XAI/ML/ML Lab H Sec/3. Insurance Target Categorical (Overfit vs Regularized).ipynb +0 -274
- noshot/data/ML TS XAI/ML/ML Lab H Sec/3. Insurance Target Numerical (Overfit vs Regularized).ipynb +0 -263
- noshot/data/ML TS XAI/ML/ML Lab H Sec/4. Smart House System HMM.ipynb +0 -198
- noshot/data/ML TS XAI/ML/ML Lab H Sec/5. Fraud Detection System HMM.ipynb +0 -201
- noshot/data/ML TS XAI/ML/ML Lab H Sec/insurance.csv +0 -1339
- noshot/data/ML TS XAI/ML/ML Lab H Sec/iris1.data +0 -151
- noshot/data/ML TS XAI/ML/ML Lab H Sec/student-mat.csv +0 -396
- noshot/data/ML TS XAI/ML/ML Lab H Sec/student-por.csv +0 -650
- noshot/data/ML TS XAI/ML/Rolls Royce AllinOne.ipynb +0 -691
- noshot-10.0.0.dist-info/RECORD +0 -72
- {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/licenses/LICENSE.txt +0 -0
- {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/top_level.txt +0 -0
@@ -1,336 +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
|
-
"executionInfo": {
|
12
|
-
"elapsed": 4740,
|
13
|
-
"status": "ok",
|
14
|
-
"timestamp": 1745300903286,
|
15
|
-
"user": {
|
16
|
-
"displayName": "Jaison A",
|
17
|
-
"userId": "07006398627763032071"
|
18
|
-
},
|
19
|
-
"user_tz": -330
|
20
|
-
},
|
21
|
-
"id": "4a-KUub89a-f",
|
22
|
-
"outputId": "b5058ef1-2acb-4100-d6c5-3f8fd8662e2e"
|
23
|
-
},
|
24
|
-
"outputs": [],
|
25
|
-
"source": [
|
26
|
-
"import numpy as np\n",
|
27
|
-
"import pandas as pd\n",
|
28
|
-
"import networkx.drawing.nx_pydot as gl\n",
|
29
|
-
"import networkx as nx\n",
|
30
|
-
"import matplotlib.pyplot as plt\n",
|
31
|
-
"from pprint import pprint\n",
|
32
|
-
"states = ['O1', 'O2', 'O3']\n",
|
33
|
-
"pi = [0.25, 0.4, 0.35]\n",
|
34
|
-
"state_space = pd.Series(pi, index=states, name='states')\n",
|
35
|
-
"print(state_space)\n",
|
36
|
-
"print(state_space.sum())\n",
|
37
|
-
"q_df = pd.DataFrame(columns=states, index=states)\n",
|
38
|
-
"q_df.loc[states[0]] = [0.4, 0.2, 0.4]\n",
|
39
|
-
"q_df.loc[states[1]] = [0.45, 0.45, 0.1]\n",
|
40
|
-
"q_df.loc[states[2]] = [0.45, 0.25, .3]\n",
|
41
|
-
"print(q_df)\n",
|
42
|
-
"q = q_df.values\n",
|
43
|
-
"#print('\\n')\n",
|
44
|
-
"print(q, q.shape)\n",
|
45
|
-
"print('\\n')\n",
|
46
|
-
"print(q_df.sum(axis=1))\n",
|
47
|
-
"from pprint import pprint\n",
|
48
|
-
"\n",
|
49
|
-
"def _get_markov_edges(Q):\n",
|
50
|
-
" edges = {}\n",
|
51
|
-
" for col in Q.columns:\n",
|
52
|
-
" for idx in Q.index:\n",
|
53
|
-
" edges[(idx,col)] = Q.loc[idx,col]\n",
|
54
|
-
" return edges\n",
|
55
|
-
"edges_wts = _get_markov_edges(q_df)\n",
|
56
|
-
"pprint(edges_wts)\n",
|
57
|
-
"G = nx.MultiDiGraph()\n",
|
58
|
-
"# nodes correspond to states\n",
|
59
|
-
"G.add_nodes_from(states)\n",
|
60
|
-
"print('Nodes:\\n')\n",
|
61
|
-
"print(G.nodes())\n",
|
62
|
-
"print('\\n')\n",
|
63
|
-
"for k, v in edges_wts.items():\n",
|
64
|
-
" tmp_origin, tmp_destination = k[0], k[1]\n",
|
65
|
-
" G.add_edge(tmp_origin, tmp_destination, weight=v, label=v)\n",
|
66
|
-
"print('Edges:')\n",
|
67
|
-
"pprint(G.edges(data=True))\n",
|
68
|
-
"pos = nx.drawing.nx_pydot.graphviz_layout(G, prog='dot')\n",
|
69
|
-
"nx.draw_networkx(G, pos)\n",
|
70
|
-
"hidden_states = ['S1', 'S2']\n",
|
71
|
-
"pi = [0.5, 0.5]\n",
|
72
|
-
"print('\\n')\n",
|
73
|
-
"state_space = pd.Series(pi, index=hidden_states, name='states')\n",
|
74
|
-
"print(state_space)\n",
|
75
|
-
"print('\\n')\n",
|
76
|
-
"print(state_space.sum())\n",
|
77
|
-
"a_df = pd.DataFrame(columns=hidden_states, index=hidden_states)\n",
|
78
|
-
"a_df.loc[hidden_states[0]] = [0.7, 0.3]\n",
|
79
|
-
"a_df.loc[hidden_states[1]] = [0.4, 0.6]\n",
|
80
|
-
"print(a_df)\n",
|
81
|
-
"a = a_df.values\n",
|
82
|
-
"print('\\n')\n",
|
83
|
-
"print(a)\n",
|
84
|
-
"print(a.shape)\n",
|
85
|
-
"print('\\n')\n",
|
86
|
-
"print(a_df.sum(axis=1))\n",
|
87
|
-
"observable_states = states\n",
|
88
|
-
"b_df = pd.DataFrame(columns=observable_states, index=hidden_states)\n",
|
89
|
-
"b_df.loc[hidden_states[0]] = [0.2, 0.6, 0.2]\n",
|
90
|
-
"b_df.loc[hidden_states[1]] = [0.4, 0.1, 0.5]\n",
|
91
|
-
"print(b_df)\n",
|
92
|
-
"\n",
|
93
|
-
"b = b_df.values\n",
|
94
|
-
"print('\\n')\n",
|
95
|
-
"print(b)\n",
|
96
|
-
"print(b.shape)\n",
|
97
|
-
"print('\\n')\n",
|
98
|
-
"print(b_df.sum(axis=1))\n",
|
99
|
-
"hide_edges_wts = _get_markov_edges(a_df)\n",
|
100
|
-
"pprint(hide_edges_wts)\n",
|
101
|
-
"emit_edges_wts = _get_markov_edges(b_df)\n",
|
102
|
-
"pprint(emit_edges_wts)\n",
|
103
|
-
"G = nx.MultiDiGraph()\n",
|
104
|
-
"G.add_nodes_from(hidden_states)\n",
|
105
|
-
"print('Nodes:\\n')\n",
|
106
|
-
"print(G.nodes())\n",
|
107
|
-
"print('\\n')\n",
|
108
|
-
"pos = nx.drawing.nx_pydot.graphviz_layout(G, prog='neato')\n",
|
109
|
-
"nx.draw_networkx(G, pos)\n",
|
110
|
-
"plt.show()\n",
|
111
|
-
"state_map = {0:'S1', 1:'S2'}\n",
|
112
|
-
"path=[0,1,0]\n",
|
113
|
-
"state_path = [state_map[v] for v in path]\n",
|
114
|
-
"obs_seq=['O1','O3','O2']\n",
|
115
|
-
"result = (pd.DataFrame().assign(Observation=obs_seq).assign(Best_Path=state_path))\n",
|
116
|
-
"print(result)"
|
117
|
-
]
|
118
|
-
},
|
119
|
-
{
|
120
|
-
"cell_type": "code",
|
121
|
-
"execution_count": null,
|
122
|
-
"metadata": {
|
123
|
-
"colab": {
|
124
|
-
"base_uri": "https://localhost:8080/",
|
125
|
-
"height": 1000
|
126
|
-
},
|
127
|
-
"executionInfo": {
|
128
|
-
"elapsed": 2283,
|
129
|
-
"status": "ok",
|
130
|
-
"timestamp": 1745300905577,
|
131
|
-
"user": {
|
132
|
-
"displayName": "Jaison A",
|
133
|
-
"userId": "07006398627763032071"
|
134
|
-
},
|
135
|
-
"user_tz": -330
|
136
|
-
},
|
137
|
-
"id": "9tVvFPx4A4PN",
|
138
|
-
"outputId": "7c0549b9-bb15-450d-ee72-45bec5c8811c"
|
139
|
-
},
|
140
|
-
"outputs": [],
|
141
|
-
"source": [
|
142
|
-
"import numpy as np\n",
|
143
|
-
"import pandas as pd\n",
|
144
|
-
"import networkx as nx\n",
|
145
|
-
"import matplotlib.pyplot as plt\n",
|
146
|
-
"from pprint import pprint\n",
|
147
|
-
"\n",
|
148
|
-
"# ====================\n",
|
149
|
-
"# 1. Define the HMM parameters\n",
|
150
|
-
"# ====================\n",
|
151
|
-
"\n",
|
152
|
-
"# Observable states\n",
|
153
|
-
"states = ['O1', 'O2', 'O3']\n",
|
154
|
-
"pi = [0.25, 0.4, 0.35]\n",
|
155
|
-
"state_space = pd.Series(pi, index=states, name='states')\n",
|
156
|
-
"print(\"Initial State Probabilities:\")\n",
|
157
|
-
"print(state_space)\n",
|
158
|
-
"print(\"Sum:\", state_space.sum())\n",
|
159
|
-
"print(\"\\n\")\n",
|
160
|
-
"\n",
|
161
|
-
"# Transition matrix for observable states\n",
|
162
|
-
"q_df = pd.DataFrame(columns=states, index=states)\n",
|
163
|
-
"q_df.loc[states[0]] = [0.4, 0.2, 0.4]\n",
|
164
|
-
"q_df.loc[states[1]] = [0.45, 0.45, 0.1]\n",
|
165
|
-
"q_df.loc[states[2]] = [0.45, 0.25, 0.3]\n",
|
166
|
-
"print(\"Transition Matrix (Observable States):\")\n",
|
167
|
-
"print(q_df)\n",
|
168
|
-
"print(\"\\nRow Sums:\")\n",
|
169
|
-
"print(q_df.sum(axis=1))\n",
|
170
|
-
"print(\"\\n\")\n",
|
171
|
-
"\n",
|
172
|
-
"# ====================\n",
|
173
|
-
"# 2. Visualization of observable state transitions\n",
|
174
|
-
"# ====================\n",
|
175
|
-
"\n",
|
176
|
-
"def _get_markov_edges(Q):\n",
|
177
|
-
" edges = {}\n",
|
178
|
-
" for col in Q.columns:\n",
|
179
|
-
" for idx in Q.index:\n",
|
180
|
-
" edges[(idx, col)] = Q.loc[idx, col]\n",
|
181
|
-
" return edges\n",
|
182
|
-
"\n",
|
183
|
-
"edges_wts = _get_markov_edges(q_df)\n",
|
184
|
-
"print(\"Edge Weights:\")\n",
|
185
|
-
"pprint(edges_wts)\n",
|
186
|
-
"\n",
|
187
|
-
"G = nx.MultiDiGraph()\n",
|
188
|
-
"G.add_nodes_from(states)\n",
|
189
|
-
"print('\\nNodes:')\n",
|
190
|
-
"print(G.nodes())\n",
|
191
|
-
"\n",
|
192
|
-
"for k, v in edges_wts.items():\n",
|
193
|
-
" tmp_origin, tmp_destination = k[0], k[1]\n",
|
194
|
-
" G.add_edge(tmp_origin, tmp_destination, weight=v, label=v)\n",
|
195
|
-
"\n",
|
196
|
-
"print('\\nEdges:')\n",
|
197
|
-
"pprint(G.edges(data=True))\n",
|
198
|
-
"\n",
|
199
|
-
"pos = nx.drawing.nx_pydot.graphviz_layout(G, prog='dot')\n",
|
200
|
-
"nx.draw_networkx(G, pos, with_labels=True, node_size=1000,\n",
|
201
|
-
" node_color='skyblue', font_size=12, arrows=True)\n",
|
202
|
-
"edge_labels = nx.get_edge_attributes(G, 'label')\n",
|
203
|
-
"nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)\n",
|
204
|
-
"plt.title(\"Observable State Transitions\")\n",
|
205
|
-
"plt.show()\n",
|
206
|
-
"\n",
|
207
|
-
"# ====================\n",
|
208
|
-
"# 3. Hidden States and their parameters\n",
|
209
|
-
"# ====================\n",
|
210
|
-
"\n",
|
211
|
-
"hidden_states = ['S1', 'S2']\n",
|
212
|
-
"pi = [0.5, 0.5]\n",
|
213
|
-
"state_space = pd.Series(pi, index=hidden_states, name='states')\n",
|
214
|
-
"print(\"\\nHidden State Probabilities:\")\n",
|
215
|
-
"print(state_space)\n",
|
216
|
-
"print(\"Sum:\", state_space.sum())\n",
|
217
|
-
"print(\"\\n\")\n",
|
218
|
-
"\n",
|
219
|
-
"# Transition matrix for hidden states\n",
|
220
|
-
"a_df = pd.DataFrame(columns=hidden_states, index=hidden_states)\n",
|
221
|
-
"a_df.loc[hidden_states[0]] = [0.7, 0.3]\n",
|
222
|
-
"a_df.loc[hidden_states[1]] = [0.4, 0.6]\n",
|
223
|
-
"print(\"Transition Matrix (Hidden States):\")\n",
|
224
|
-
"print(a_df)\n",
|
225
|
-
"print(\"\\nRow Sums:\")\n",
|
226
|
-
"print(a_df.sum(axis=1))\n",
|
227
|
-
"print(\"\\n\")\n",
|
228
|
-
"\n",
|
229
|
-
"# Emission probabilities\n",
|
230
|
-
"observable_states = states\n",
|
231
|
-
"b_df = pd.DataFrame(columns=observable_states, index=hidden_states)\n",
|
232
|
-
"b_df.loc[hidden_states[0]] = [0.2, 0.6, 0.2]\n",
|
233
|
-
"b_df.loc[hidden_states[1]] = [0.4, 0.1, 0.5]\n",
|
234
|
-
"print(\"Emission Probabilities:\")\n",
|
235
|
-
"print(b_df)\n",
|
236
|
-
"print(\"\\nRow Sums:\")\n",
|
237
|
-
"print(b_df.sum(axis=1))\n",
|
238
|
-
"print(\"\\n\")\n",
|
239
|
-
"\n",
|
240
|
-
"# ====================\n",
|
241
|
-
"# 4. Visualization of hidden state transitions and emissions\n",
|
242
|
-
"# ====================\n",
|
243
|
-
"\n",
|
244
|
-
"hide_edges_wts = _get_markov_edges(a_df)\n",
|
245
|
-
"print(\"Hidden State Transition Weights:\")\n",
|
246
|
-
"pprint(hide_edges_wts)\n",
|
247
|
-
"\n",
|
248
|
-
"emit_edges_wts = _get_markov_edges(b_df)\n",
|
249
|
-
"print(\"\\nEmission Weights:\")\n",
|
250
|
-
"pprint(emit_edges_wts)\n",
|
251
|
-
"\n",
|
252
|
-
"# Hidden state transitions graph\n",
|
253
|
-
"G_hidden = nx.MultiDiGraph()\n",
|
254
|
-
"G_hidden.add_nodes_from(hidden_states)\n",
|
255
|
-
"print('\\nHidden State Nodes:')\n",
|
256
|
-
"print(G_hidden.nodes())\n",
|
257
|
-
"\n",
|
258
|
-
"for k, v in hide_edges_wts.items():\n",
|
259
|
-
" tmp_origin, tmp_destination = k[0], k[1]\n",
|
260
|
-
" G_hidden.add_edge(tmp_origin, tmp_destination, weight=v, label=v)\n",
|
261
|
-
"\n",
|
262
|
-
"pos = nx.drawing.nx_pydot.graphviz_layout(G_hidden, prog='dot')\n",
|
263
|
-
"nx.draw_networkx(G_hidden, pos, with_labels=True, node_size=1000,\n",
|
264
|
-
" node_color='lightgreen', font_size=12, arrows=True)\n",
|
265
|
-
"edge_labels = nx.get_edge_attributes(G_hidden, 'label')\n",
|
266
|
-
"nx.draw_networkx_edge_labels(G_hidden, pos, edge_labels=edge_labels)\n",
|
267
|
-
"plt.title(\"Hidden State Transitions\")\n",
|
268
|
-
"plt.show()\n",
|
269
|
-
"\n",
|
270
|
-
"# Emission probabilities graph\n",
|
271
|
-
"G_emit = nx.MultiDiGraph()\n",
|
272
|
-
"G_emit.add_nodes_from(hidden_states)\n",
|
273
|
-
"print('\\nEmission Nodes:')\n",
|
274
|
-
"print(G_emit.nodes())\n",
|
275
|
-
"\n",
|
276
|
-
"for k, v in emit_edges_wts.items():\n",
|
277
|
-
" tmp_origin, tmp_destination = k[0], k[1]\n",
|
278
|
-
" G_emit.add_edge(tmp_origin, tmp_destination, weight=v, label=v)\n",
|
279
|
-
"\n",
|
280
|
-
"pos = nx.drawing.nx_pydot.graphviz_layout(G_emit, prog='neato')\n",
|
281
|
-
"nx.draw_networkx(G_emit, pos, with_labels=True, node_size=1000,\n",
|
282
|
-
" node_color='lightcoral', font_size=12, arrows=True)\n",
|
283
|
-
"edge_labels = nx.get_edge_attributes(G_emit, 'label')\n",
|
284
|
-
"nx.draw_networkx_edge_labels(G_emit, pos, edge_labels=edge_labels)\n",
|
285
|
-
"plt.title(\"Emission Probabilities\")\n",
|
286
|
-
"plt.show()\n",
|
287
|
-
"\n",
|
288
|
-
"# ====================\n",
|
289
|
-
"# 5. Sample Observation Sequence and State Path\n",
|
290
|
-
"# ====================\n",
|
291
|
-
"\n",
|
292
|
-
"# Sample data (as shown in the lab manual output)\n",
|
293
|
-
"obs_seq = ['O2', 'O2', 'O3', 'O2', 'O1', 'O2', 'O3', 'O2', 'O1', 'O3', 'O3', 'O1', 'O2', 'O1', 'O2']\n",
|
294
|
-
"path = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0] # 0=S1, 1=S2\n",
|
295
|
-
"\n",
|
296
|
-
"state_map = {0:'S1', 1:'S2'}\n",
|
297
|
-
"state_path = [state_map[v] for v in path]\n",
|
298
|
-
"\n",
|
299
|
-
"result = pd.DataFrame({\n",
|
300
|
-
" 'Observation': obs_seq,\n",
|
301
|
-
" 'Best_Path': state_path\n",
|
302
|
-
"})\n",
|
303
|
-
"\n",
|
304
|
-
"print(\"\\nObservation Sequence with Most Likely Hidden States:\")\n",
|
305
|
-
"print(result)"
|
306
|
-
]
|
307
|
-
}
|
308
|
-
],
|
309
|
-
"metadata": {
|
310
|
-
"accelerator": "GPU",
|
311
|
-
"colab": {
|
312
|
-
"authorship_tag": "ABX9TyMGDLt9IOT6gGXDCsIPtxky",
|
313
|
-
"gpuType": "T4",
|
314
|
-
"provenance": []
|
315
|
-
},
|
316
|
-
"kernelspec": {
|
317
|
-
"display_name": "Python 3 (ipykernel)",
|
318
|
-
"language": "python",
|
319
|
-
"name": "python3"
|
320
|
-
},
|
321
|
-
"language_info": {
|
322
|
-
"codemirror_mode": {
|
323
|
-
"name": "ipython",
|
324
|
-
"version": 3
|
325
|
-
},
|
326
|
-
"file_extension": ".py",
|
327
|
-
"mimetype": "text/x-python",
|
328
|
-
"name": "python",
|
329
|
-
"nbconvert_exporter": "python",
|
330
|
-
"pygments_lexer": "ipython3",
|
331
|
-
"version": "3.12.4"
|
332
|
-
}
|
333
|
-
},
|
334
|
-
"nbformat": 4,
|
335
|
-
"nbformat_minor": 4
|
336
|
-
}
|
@@ -1,149 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "code",
|
5
|
-
"execution_count": null,
|
6
|
-
"metadata": {
|
7
|
-
"executionInfo": {
|
8
|
-
"elapsed": 9,
|
9
|
-
"status": "ok",
|
10
|
-
"timestamp": 1740322226638,
|
11
|
-
"user": {
|
12
|
-
"displayName": "Jaison A",
|
13
|
-
"userId": "07006398627763032071"
|
14
|
-
},
|
15
|
-
"user_tz": -330
|
16
|
-
},
|
17
|
-
"id": "bbUA3qg5SCrE"
|
18
|
-
},
|
19
|
-
"outputs": [],
|
20
|
-
"source": [
|
21
|
-
"import pandas as pd\n",
|
22
|
-
"from sklearn.preprocessing import StandardScaler\n",
|
23
|
-
"from sklearn.neighbors import KNeighborsClassifier\n",
|
24
|
-
"from sklearn.model_selection import train_test_split\n",
|
25
|
-
"from sklearn.metrics import accuracy_score,classification_report"
|
26
|
-
]
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"cell_type": "code",
|
30
|
-
"execution_count": null,
|
31
|
-
"metadata": {
|
32
|
-
"colab": {
|
33
|
-
"base_uri": "https://localhost:8080/",
|
34
|
-
"height": 327
|
35
|
-
},
|
36
|
-
"executionInfo": {
|
37
|
-
"elapsed": 97,
|
38
|
-
"status": "ok",
|
39
|
-
"timestamp": 1740322228224,
|
40
|
-
"user": {
|
41
|
-
"displayName": "Jaison A",
|
42
|
-
"userId": "07006398627763032071"
|
43
|
-
},
|
44
|
-
"user_tz": -330
|
45
|
-
},
|
46
|
-
"id": "hNhWJ01kSF2W",
|
47
|
-
"outputId": "9a86b0be-6836-4b37-9ed9-1e8593126884"
|
48
|
-
},
|
49
|
-
"outputs": [],
|
50
|
-
"source": [
|
51
|
-
"data2=pd.read_csv('/content/dataset2.csv',names=['Class name','Left weight','Left distance','Right weight','Right distance'])\n",
|
52
|
-
"display(data2.head())\n",
|
53
|
-
"\n",
|
54
|
-
"x=data2.loc[:,['Left weight','Left distance','Right weight','Right distance']] #input features.\n",
|
55
|
-
"y=data2.loc[:,'Class name'] #output feature.\n",
|
56
|
-
"\n",
|
57
|
-
"Standardized_x=StandardScaler().fit_transform(x)#statndardize the dataset.\n",
|
58
|
-
"display(Standardized_x)\n",
|
59
|
-
"\n",
|
60
|
-
"X_train,X_test,y_train,y_test=train_test_split(Standardized_x,y,test_size=0.4,random_state=4)#split data for training and prediction.\n"
|
61
|
-
]
|
62
|
-
},
|
63
|
-
{
|
64
|
-
"cell_type": "code",
|
65
|
-
"execution_count": null,
|
66
|
-
"metadata": {
|
67
|
-
"colab": {
|
68
|
-
"base_uri": "https://localhost:8080/"
|
69
|
-
},
|
70
|
-
"executionInfo": {
|
71
|
-
"elapsed": 17,
|
72
|
-
"status": "ok",
|
73
|
-
"timestamp": 1740322230944,
|
74
|
-
"user": {
|
75
|
-
"displayName": "Jaison A",
|
76
|
-
"userId": "07006398627763032071"
|
77
|
-
},
|
78
|
-
"user_tz": -330
|
79
|
-
},
|
80
|
-
"id": "7eEwp2cZSI8M",
|
81
|
-
"outputId": "3f03a6b2-b582-4d6b-abbb-5fd695636f71"
|
82
|
-
},
|
83
|
-
"outputs": [],
|
84
|
-
"source": [
|
85
|
-
"# shape of each terms.\n",
|
86
|
-
"\n",
|
87
|
-
"print(\"Shape of X_train : \",X_train.shape)\n",
|
88
|
-
"print(\"Shape of y_train : \",y_train.shape)\n",
|
89
|
-
"print(\"Shape of X_test : \",X_test.shape)\n",
|
90
|
-
"print(\"Shape of y_test : \",y_test.shape)"
|
91
|
-
]
|
92
|
-
},
|
93
|
-
{
|
94
|
-
"cell_type": "code",
|
95
|
-
"execution_count": null,
|
96
|
-
"metadata": {
|
97
|
-
"colab": {
|
98
|
-
"base_uri": "https://localhost:8080/"
|
99
|
-
},
|
100
|
-
"executionInfo": {
|
101
|
-
"elapsed": 11,
|
102
|
-
"status": "ok",
|
103
|
-
"timestamp": 1740322232987,
|
104
|
-
"user": {
|
105
|
-
"displayName": "Jaison A",
|
106
|
-
"userId": "07006398627763032071"
|
107
|
-
},
|
108
|
-
"user_tz": -330
|
109
|
-
},
|
110
|
-
"id": "iXrVxshWSK2Y",
|
111
|
-
"outputId": "be67027b-e257-43dc-c8b3-125d12de519a"
|
112
|
-
},
|
113
|
-
"outputs": [],
|
114
|
-
"source": [
|
115
|
-
"knn=KNeighborsClassifier(n_neighbors=15) #n_neighbors indicates no of clusters to be formed.\n",
|
116
|
-
"knn.fit(X_train,y_train) #training the knn model with training data.\n",
|
117
|
-
"\n",
|
118
|
-
"y_pred=knn.predict(X_test) #prediction using test data.\n",
|
119
|
-
"print(f\"Accuracy Score : {accuracy_score(y_test,y_pred)}\") #comparing original output with predicted output.\n",
|
120
|
-
"print(\"\\n\\nClassification Report : \\n\",classification_report(y_test,y_pred,zero_division=0)) #classification report."
|
121
|
-
]
|
122
|
-
}
|
123
|
-
],
|
124
|
-
"metadata": {
|
125
|
-
"colab": {
|
126
|
-
"authorship_tag": "ABX9TyOAjGoDOV/8NCJ7O3AdF9qL",
|
127
|
-
"provenance": []
|
128
|
-
},
|
129
|
-
"kernelspec": {
|
130
|
-
"display_name": "Python 3 (ipykernel)",
|
131
|
-
"language": "python",
|
132
|
-
"name": "python3"
|
133
|
-
},
|
134
|
-
"language_info": {
|
135
|
-
"codemirror_mode": {
|
136
|
-
"name": "ipython",
|
137
|
-
"version": 3
|
138
|
-
},
|
139
|
-
"file_extension": ".py",
|
140
|
-
"mimetype": "text/x-python",
|
141
|
-
"name": "python",
|
142
|
-
"nbconvert_exporter": "python",
|
143
|
-
"pygments_lexer": "ipython3",
|
144
|
-
"version": "3.12.4"
|
145
|
-
}
|
146
|
-
},
|
147
|
-
"nbformat": 4,
|
148
|
-
"nbformat_minor": 4
|
149
|
-
}
|
@@ -1,132 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "markdown",
|
5
|
-
"id": "0e55f86f-412e-466f-bba9-25f0f0e6a4cf",
|
6
|
-
"metadata": {},
|
7
|
-
"source": [
|
8
|
-
"LDA- Linear Discriminant Analysis."
|
9
|
-
]
|
10
|
-
},
|
11
|
-
{
|
12
|
-
"cell_type": "code",
|
13
|
-
"execution_count": null,
|
14
|
-
"id": "530aa877-bc4c-4705-9558-c3699fddcb48",
|
15
|
-
"metadata": {},
|
16
|
-
"outputs": [],
|
17
|
-
"source": [
|
18
|
-
"#required packages.\n",
|
19
|
-
"\n",
|
20
|
-
"import pandas as pd\n",
|
21
|
-
"import matplotlib.pyplot as plt\n",
|
22
|
-
"import seaborn as sns\n",
|
23
|
-
"import numpy as np\n",
|
24
|
-
"from sklearn.preprocessing import StandardScaler\n",
|
25
|
-
"from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA"
|
26
|
-
]
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"cell_type": "code",
|
30
|
-
"execution_count": null,
|
31
|
-
"id": "dc60a6db-5b8e-4915-9d54-41fd24137b78",
|
32
|
-
"metadata": {},
|
33
|
-
"outputs": [],
|
34
|
-
"source": [
|
35
|
-
"#load dataset.\n",
|
36
|
-
"\n",
|
37
|
-
"df=pd.read_csv(\"E:/126156055/dataset.csv\",names=['class name',\"left-weight\",\"left-distance\",'right-weight','right-distance'])\n",
|
38
|
-
"print(\"First Five rows : \\n\",df.head())\n",
|
39
|
-
"print(\"\\nInfo : \\n\",df.info)\n",
|
40
|
-
"print(\"\\nDescribe : \\n\",df.describe())"
|
41
|
-
]
|
42
|
-
},
|
43
|
-
{
|
44
|
-
"cell_type": "code",
|
45
|
-
"execution_count": null,
|
46
|
-
"id": "65db7f61-68a6-44e1-8cc7-59d4598ea56a",
|
47
|
-
"metadata": {},
|
48
|
-
"outputs": [],
|
49
|
-
"source": [
|
50
|
-
"features=[\"left-weight\",\"left-distance\",'right-weight','right-distance']\n",
|
51
|
-
"x=df.loc[:,features]\n",
|
52
|
-
"x"
|
53
|
-
]
|
54
|
-
},
|
55
|
-
{
|
56
|
-
"cell_type": "code",
|
57
|
-
"execution_count": null,
|
58
|
-
"id": "07a4edf8-e592-4ccb-b433-17f2054b5a60",
|
59
|
-
"metadata": {},
|
60
|
-
"outputs": [],
|
61
|
-
"source": [
|
62
|
-
"y=df.loc[:,'class name']\n",
|
63
|
-
"y"
|
64
|
-
]
|
65
|
-
},
|
66
|
-
{
|
67
|
-
"cell_type": "code",
|
68
|
-
"execution_count": null,
|
69
|
-
"id": "4888333a-ac2c-4310-ad2f-6cf3786cbcf6",
|
70
|
-
"metadata": {},
|
71
|
-
"outputs": [],
|
72
|
-
"source": [
|
73
|
-
"lda=LDA(n_components=2)\n",
|
74
|
-
"lda"
|
75
|
-
]
|
76
|
-
},
|
77
|
-
{
|
78
|
-
"cell_type": "code",
|
79
|
-
"execution_count": null,
|
80
|
-
"id": "c6904766-9fea-4f83-8fe8-9b225f118afe",
|
81
|
-
"metadata": {},
|
82
|
-
"outputs": [],
|
83
|
-
"source": [
|
84
|
-
"lda_x=lda.fit(x,y).transform(x)\n",
|
85
|
-
"lda_x"
|
86
|
-
]
|
87
|
-
},
|
88
|
-
{
|
89
|
-
"cell_type": "code",
|
90
|
-
"execution_count": null,
|
91
|
-
"id": "94165d9a-5825-4b5b-804b-4a41b9353f9e",
|
92
|
-
"metadata": {},
|
93
|
-
"outputs": [],
|
94
|
-
"source": [
|
95
|
-
"plt.scatter(lda_x[y == 'L', 0], lda_x[y == 'L', 1], s =50, c = 'orange',label = 'L')\n",
|
96
|
-
"plt.scatter(lda_x[y == 'B', 0], lda_x[y == 'B', 1], s =50, c = 'blue',label = 'B')\n",
|
97
|
-
"plt.scatter(lda_x[y == 'R', 0], lda_x[y == 'R', 1], s =50, c = 'green',label = 'R')\n",
|
98
|
-
"plt.title('LDA plot for cmc DataSet')\n",
|
99
|
-
"plt.show()"
|
100
|
-
]
|
101
|
-
},
|
102
|
-
{
|
103
|
-
"cell_type": "code",
|
104
|
-
"execution_count": null,
|
105
|
-
"id": "7c0f9c23-7a44-4194-b5dd-5c6524b44bb9",
|
106
|
-
"metadata": {},
|
107
|
-
"outputs": [],
|
108
|
-
"source": []
|
109
|
-
}
|
110
|
-
],
|
111
|
-
"metadata": {
|
112
|
-
"kernelspec": {
|
113
|
-
"display_name": "Python 3 (ipykernel)",
|
114
|
-
"language": "python",
|
115
|
-
"name": "python3"
|
116
|
-
},
|
117
|
-
"language_info": {
|
118
|
-
"codemirror_mode": {
|
119
|
-
"name": "ipython",
|
120
|
-
"version": 3
|
121
|
-
},
|
122
|
-
"file_extension": ".py",
|
123
|
-
"mimetype": "text/x-python",
|
124
|
-
"name": "python",
|
125
|
-
"nbconvert_exporter": "python",
|
126
|
-
"pygments_lexer": "ipython3",
|
127
|
-
"version": "3.12.4"
|
128
|
-
}
|
129
|
-
},
|
130
|
-
"nbformat": 4,
|
131
|
-
"nbformat_minor": 5
|
132
|
-
}
|