noshot 0.1.7__py3-none-any.whl → 0.1.9__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 (239) hide show
  1. noshot/data/ML TS XAI/ML/1. PCA - EDA/PCA-EDA.ipynb +207 -0
  2. noshot/data/ML TS XAI/ML/1. PCA - EDA/balance-scale.csv +626 -0
  3. noshot/data/ML TS XAI/ML/1. PCA - EDA/input.txt +625 -0
  4. noshot/data/ML TS XAI/ML/2. KNN Classifier/KNN.ipynb +287 -0
  5. noshot/data/ML TS XAI/ML/2. KNN Classifier/balance-scale.csv +626 -0
  6. noshot/data/ML TS XAI/ML/2. KNN Classifier/input.txt +625 -0
  7. noshot/data/ML TS XAI/ML/3. Linear Discriminant Analysis/LDA.ipynb +83 -0
  8. noshot/data/ML TS XAI/ML/3. Linear Discriminant Analysis/balance-scale.csv +626 -0
  9. noshot/data/ML TS XAI/ML/3. Linear Discriminant Analysis/input.txt +625 -0
  10. noshot/data/ML TS XAI/ML/4. Linear Regression/Linear-Regression.ipynb +117 -0
  11. noshot/data/ML TS XAI/ML/4. Linear Regression/machine-data.csv +210 -0
  12. noshot/data/ML TS XAI/ML/5. Logistic Regression/Logistic-Regression.ipynb +137 -0
  13. noshot/data/ML TS XAI/ML/5. Logistic Regression/wine-dataset.csv +179 -0
  14. noshot/data/ML TS XAI/ML/6. Bayesian Classifier/Bayesian.ipynb +129 -0
  15. noshot/data/ML TS XAI/ML/6. Bayesian Classifier/wine-dataset.csv +179 -0
  16. noshot/data/ML TS XAI/TS/1. EDA - Handling Time Series Data/Handling TS Data.ipynb +784 -0
  17. noshot/data/ML TS XAI/TS/1. EDA - Handling Time Series Data/raw_sales.csv +29581 -0
  18. noshot/data/ML TS XAI/TS/2. Feature Engineering/Feature Engineering-.ipynb +1445 -0
  19. noshot/data/ML TS XAI/TS/3. Temporal Relationships/Exploring Temporal Relationships.ipynb +603 -0
  20. noshot/data/ML TS XAI/TS/4. Up-Down-Sampling and Interploation/Up-Down-Sampling.ipynb +721 -0
  21. noshot/data/ML TS XAI/TS/4. Up-Down-Sampling and Interploation/shampoo_sales.csv +37 -0
  22. noshot/data/ML TS XAI/TS/5. Stationarity - Trend - Seasonality/Stationarity-Trend-Seasonality.ipynb +392 -0
  23. noshot/data/ML TS XAI/TS/5. Stationarity - Trend - Seasonality/daily-min-temperatures.csv +3651 -0
  24. noshot/data/ML TS XAI/TS/5. Stationarity - Trend - Seasonality/daily-total-female-births.csv +366 -0
  25. noshot/data/ML TS XAI/TS/6. Autocorrelation - Partial Autocorrelation/ACF-PACF.ipynb +175 -0
  26. noshot/data/ML TS XAI/TS/6. Autocorrelation - Partial Autocorrelation/daily-min-temperatures.csv +3651 -0
  27. {noshot-0.1.7.dist-info → noshot-0.1.9.dist-info}/METADATA +2 -2
  28. noshot-0.1.9.dist-info/RECORD +35 -0
  29. noshot/data/ML TS XAI/AIDS/1. Implement Basic Search Strategies/(A) Breadth First Search.ipynb +0 -112
  30. noshot/data/ML TS XAI/AIDS/1. Implement Basic Search Strategies/(B) Depth First Search.ipynb +0 -111
  31. noshot/data/ML TS XAI/AIDS/1. Implement Basic Search Strategies/(C) Uniform Cost Search.ipynb +0 -134
  32. noshot/data/ML TS XAI/AIDS/1. Implement Basic Search Strategies/(D) Depth Limites Search.ipynb +0 -115
  33. noshot/data/ML TS XAI/AIDS/1. Implement Basic Search Strategies/(E) Iterative Deepening DFS.ipynb +0 -123
  34. noshot/data/ML TS XAI/AIDS/10. ANOVA/2_ANOVA.csv +0 -769
  35. noshot/data/ML TS XAI/AIDS/10. ANOVA/One Way ANOVA (Repeated Measure).ipynb +0 -126
  36. noshot/data/ML TS XAI/AIDS/10. ANOVA/One Way ANOVA.ipynb +0 -134
  37. noshot/data/ML TS XAI/AIDS/10. ANOVA/Sample 1 Way ANOVA Test.ipynb +0 -119
  38. noshot/data/ML TS XAI/AIDS/10. ANOVA/Two Way ANOVA.ipynb +0 -138
  39. noshot/data/ML TS XAI/AIDS/10. ANOVA/reaction_time.csv +0 -5
  40. noshot/data/ML TS XAI/AIDS/10. ANOVA/sample_data.csv +0 -16
  41. noshot/data/ML TS XAI/AIDS/10. ANOVA/sleep_deprivation.csv +0 -4
  42. noshot/data/ML TS XAI/AIDS/11. Linear Regression/3_Linear.csv +0 -4802
  43. noshot/data/ML TS XAI/AIDS/11. Linear Regression/Linear Regression LAB.ipynb +0 -113
  44. noshot/data/ML TS XAI/AIDS/11. Linear Regression/Linear Regression New- sklearn.ipynb +0 -118
  45. noshot/data/ML TS XAI/AIDS/11. Linear Regression/Linear Regression.ipynb +0 -148
  46. noshot/data/ML TS XAI/AIDS/11. Linear Regression/house_rate.csv +0 -22
  47. noshot/data/ML TS XAI/AIDS/12. Logistic Regression/Logistic Regression New- sklearn.ipynb +0 -128
  48. noshot/data/ML TS XAI/AIDS/12. Logistic Regression/Logistic Regression.ipynb +0 -145
  49. noshot/data/ML TS XAI/AIDS/12. Logistic Regression/default.csv +0 -1001
  50. noshot/data/ML TS XAI/AIDS/12. Logistic Regression/hours_scores_records.csv +0 -101
  51. noshot/data/ML TS XAI/AIDS/2. Implement A Star And MA Star/(A) Astar.ipynb +0 -256
  52. noshot/data/ML TS XAI/AIDS/2. Implement A Star And MA Star/(B) IDAstar.ipynb +0 -157
  53. noshot/data/ML TS XAI/AIDS/2. Implement A Star And MA Star/(C) SMAstar.ipynb +0 -178
  54. noshot/data/ML TS XAI/AIDS/3. Genetic Algorithm/Genetic.ipynb +0 -95
  55. noshot/data/ML TS XAI/AIDS/4. Simulated Annealing/Simulated Annealing.ipynb +0 -74
  56. noshot/data/ML TS XAI/AIDS/4. Simulated Annealing/Sudoku Simulated Annealing.ipynb +0 -103
  57. noshot/data/ML TS XAI/AIDS/5. Alpha Beta Pruning/AlphaBetaPruning.ipynb +0 -182
  58. noshot/data/ML TS XAI/AIDS/6. Consraint Satisfaction Problems (CSP)/(A) CSP House Allocation.ipynb +0 -120
  59. noshot/data/ML TS XAI/AIDS/6. Consraint Satisfaction Problems (CSP)/(B) CSP Map Coloring.ipynb +0 -125
  60. noshot/data/ML TS XAI/AIDS/7. Random Sampling/Random Sampling.ipynb +0 -73
  61. noshot/data/ML TS XAI/AIDS/7. Random Sampling/height_weight_bmi.csv +0 -8389
  62. noshot/data/ML TS XAI/AIDS/8. Z Test/Z Test Hash Function.ipynb +0 -141
  63. noshot/data/ML TS XAI/AIDS/8. Z Test/Z Test.ipynb +0 -151
  64. noshot/data/ML TS XAI/AIDS/8. Z Test/height_weight_bmi.csv +0 -8389
  65. noshot/data/ML TS XAI/AIDS/9. T Test/1_heart.csv +0 -304
  66. noshot/data/ML TS XAI/AIDS/9. T Test/Independent T Test.ipynb +0 -119
  67. noshot/data/ML TS XAI/AIDS/9. T Test/Paired T Test.ipynb +0 -118
  68. noshot/data/ML TS XAI/AIDS/9. T Test/T Test Hash Function.ipynb +0 -142
  69. noshot/data/ML TS XAI/AIDS/9. T Test/T Test.ipynb +0 -158
  70. noshot/data/ML TS XAI/AIDS/9. T Test/height_weight_bmi.csv +0 -8389
  71. noshot/data/ML TS XAI/AIDS/9. T Test/iq_test.csv +0 -0
  72. noshot/data/ML TS XAI/AIDS/Others (AllinOne)/All In One.ipynb +0 -4581
  73. noshot/data/ML TS XAI/CN/1. Chat Application/chat.java +0 -81
  74. noshot/data/ML TS XAI/CN/1. Chat Application/output.png +0 -0
  75. noshot/data/ML TS XAI/CN/1. Chat Application/procedure.png +0 -0
  76. noshot/data/ML TS XAI/CN/10. Ethernet LAN IEEE 802.3/LAN.tcl +0 -65
  77. noshot/data/ML TS XAI/CN/10. Ethernet LAN IEEE 802.3/analysis.awk +0 -44
  78. noshot/data/ML TS XAI/CN/10. Ethernet LAN IEEE 802.3/output.png +0 -0
  79. noshot/data/ML TS XAI/CN/10. Ethernet LAN IEEE 802.3/procedure.png +0 -0
  80. noshot/data/ML TS XAI/CN/11. Wireless LAN IEEE 802.11/complexdcf.tcl +0 -229
  81. noshot/data/ML TS XAI/CN/11. Wireless LAN IEEE 802.11/output.png +0 -0
  82. noshot/data/ML TS XAI/CN/11. Wireless LAN IEEE 802.11/procedure.png +0 -0
  83. noshot/data/ML TS XAI/CN/2. File Transfer/file_to_send.txt +0 -2
  84. noshot/data/ML TS XAI/CN/2. File Transfer/filetransfer.java +0 -119
  85. noshot/data/ML TS XAI/CN/2. File Transfer/output.png +0 -0
  86. noshot/data/ML TS XAI/CN/2. File Transfer/procedure.png +0 -0
  87. noshot/data/ML TS XAI/CN/3. RMI (Remote Method Invocation)/Client.class +0 -0
  88. noshot/data/ML TS XAI/CN/3. RMI (Remote Method Invocation)/MyServerImpl.class +0 -0
  89. noshot/data/ML TS XAI/CN/3. RMI (Remote Method Invocation)/MyServerIntf.class +0 -0
  90. noshot/data/ML TS XAI/CN/3. RMI (Remote Method Invocation)/Server.class +0 -0
  91. noshot/data/ML TS XAI/CN/3. RMI (Remote Method Invocation)/output.png +0 -0
  92. noshot/data/ML TS XAI/CN/3. RMI (Remote Method Invocation)/procedure.png +0 -0
  93. noshot/data/ML TS XAI/CN/3. RMI (Remote Method Invocation)/rmi.java +0 -56
  94. noshot/data/ML TS XAI/CN/4. Wired Network/output.png +0 -0
  95. noshot/data/ML TS XAI/CN/4. Wired Network/procedure.png +0 -0
  96. noshot/data/ML TS XAI/CN/4. Wired Network/wired.awk +0 -25
  97. noshot/data/ML TS XAI/CN/4. Wired Network/wired.tcl +0 -81
  98. noshot/data/ML TS XAI/CN/5. Wireless Network/output.png +0 -0
  99. noshot/data/ML TS XAI/CN/5. Wireless Network/procedure.png +0 -0
  100. noshot/data/ML TS XAI/CN/5. Wireless Network/wireless.awk +0 -27
  101. noshot/data/ML TS XAI/CN/5. Wireless Network/wireless.tcl +0 -153
  102. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/analysis.awk +0 -27
  103. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/output.png +0 -0
  104. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/sack.tcl +0 -86
  105. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/vegas.tcl +0 -86
  106. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/analysis.awk +0 -28
  107. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/output.png +0 -0
  108. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/reno.tcl +0 -78
  109. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/tahoe.tcl +0 -79
  110. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Flow Control/analysis.awk +0 -27
  111. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Flow Control/flow.tcl +0 -163
  112. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/TCP Flow Control/output.png +0 -0
  113. noshot/data/ML TS XAI/CN/6. TCP Flow And Congestion Control/procedure.png +0 -0
  114. noshot/data/ML TS XAI/CN/7. Link State And Distance Vector Routing/DV.tcl +0 -111
  115. noshot/data/ML TS XAI/CN/7. Link State And Distance Vector Routing/LS.tcl +0 -106
  116. noshot/data/ML TS XAI/CN/7. Link State And Distance Vector Routing/analysis.awk +0 -36
  117. noshot/data/ML TS XAI/CN/7. Link State And Distance Vector Routing/output.png +0 -0
  118. noshot/data/ML TS XAI/CN/7. Link State And Distance Vector Routing/procedure.png +0 -0
  119. noshot/data/ML TS XAI/CN/8. Multicast And Broadcast Routing/analysis.awk +0 -20
  120. noshot/data/ML TS XAI/CN/8. Multicast And Broadcast Routing/broadcast.tcl +0 -76
  121. noshot/data/ML TS XAI/CN/8. Multicast And Broadcast Routing/multicast.tcl +0 -103
  122. noshot/data/ML TS XAI/CN/8. Multicast And Broadcast Routing/output.png +0 -0
  123. noshot/data/ML TS XAI/CN/8. Multicast And Broadcast Routing/procedure.png +0 -0
  124. noshot/data/ML TS XAI/CN/9. DHCP/DHCP.java +0 -125
  125. noshot/data/ML TS XAI/CN/9. DHCP/output.png +0 -0
  126. noshot/data/ML TS XAI/CN/9. DHCP/procedure.png +0 -0
  127. noshot/data/ML TS XAI/NLP/NLP 1/1-Prereqs.py +0 -18
  128. noshot/data/ML TS XAI/NLP/NLP 1/2-Chi2test.py +0 -83
  129. noshot/data/ML TS XAI/NLP/NLP 1/2-T-test.py +0 -79
  130. noshot/data/ML TS XAI/NLP/NLP 1/3-WSD-nb.py +0 -53
  131. noshot/data/ML TS XAI/NLP/NLP 1/4-Hindle-Rooth.py +0 -53
  132. noshot/data/ML TS XAI/NLP/NLP 1/5-HMM-Trellis.py +0 -82
  133. noshot/data/ML TS XAI/NLP/NLP 1/6-HMM-Viterbi.py +0 -16
  134. noshot/data/ML TS XAI/NLP/NLP 1/7-PCFG-parsetree.py +0 -15
  135. noshot/data/ML TS XAI/NLP/NLP 1/Chi2test.ipynb +0 -285
  136. noshot/data/ML TS XAI/NLP/NLP 1/Hindle-Rooth.ipynb +0 -179
  137. noshot/data/ML TS XAI/NLP/NLP 1/Lab 10 - Text generator using LSTM.ipynb +0 -1461
  138. noshot/data/ML TS XAI/NLP/NLP 1/Lab 11 NMT.ipynb +0 -2307
  139. noshot/data/ML TS XAI/NLP/NLP 1/PCFG.ipynb +0 -134
  140. noshot/data/ML TS XAI/NLP/NLP 1/Prereqs.ipynb +0 -131
  141. noshot/data/ML TS XAI/NLP/NLP 1/T test.ipynb +0 -252
  142. noshot/data/ML TS XAI/NLP/NLP 1/TFIDF BOW.ipynb +0 -171
  143. noshot/data/ML TS XAI/NLP/NLP 1/Trellis.ipynb +0 -244
  144. noshot/data/ML TS XAI/NLP/NLP 1/WSD.ipynb +0 -645
  145. noshot/data/ML TS XAI/NLP/NLP 1/Word2Vec.ipynb +0 -93
  146. noshot/data/ML TS XAI/NLP/NLP 2/Lab01(tokenizer)/tokenizer.ipynb +0 -370
  147. noshot/data/ML TS XAI/NLP/NLP 2/Lab01(tokenizer)/training_tokenizer.txt +0 -6
  148. noshot/data/ML TS XAI/NLP/NLP 2/Lab02(stemming)/exp0.ipynb +0 -274
  149. noshot/data/ML TS XAI/NLP/NLP 2/Lab02(stemming)/lab2.ipynb +0 -905
  150. noshot/data/ML TS XAI/NLP/NLP 2/Lab02(stemming)/test.txt +0 -1
  151. noshot/data/ML TS XAI/NLP/NLP 2/Lab02(stemming)/tokenizing.ipynb +0 -272
  152. noshot/data/ML TS XAI/NLP/NLP 2/Lab03(parse-tree)/collocation.ipynb +0 -332
  153. noshot/data/ML TS XAI/NLP/NLP 2/Lab03(parse-tree)/lab3.ipynb +0 -549
  154. noshot/data/ML TS XAI/NLP/NLP 2/Lab03(parse-tree)/nlp.txt +0 -1
  155. noshot/data/ML TS XAI/NLP/NLP 2/Lab04(collocation)/Lab4-NLP-Exp-2.ipynb +0 -817
  156. noshot/data/ML TS XAI/NLP/NLP 2/Lab04(collocation)/collocation.ipynb +0 -332
  157. noshot/data/ML TS XAI/NLP/NLP 2/Lab05(WSD)/NLP-Lab-5-Exp3.ipynb +0 -231
  158. noshot/data/ML TS XAI/NLP/NLP 2/Lab05(WSD)/word-sense-disambiguation.ipynb +0 -507
  159. noshot/data/ML TS XAI/NLP/NLP 2/Lab06(additional-exercise)/lab6.ipynb +0 -134
  160. noshot/data/ML TS XAI/NLP/NLP 2/Lab07(HMM,Viterbi)/NLP Exp 4.ipynb +0 -255
  161. noshot/data/ML TS XAI/NLP/NLP 2/Lab07(HMM,Viterbi)/NLP_Exp_5.ipynb +0 -159
  162. noshot/data/ML TS XAI/NLP/NLP 2/Lab08(PCFG)/PCFG.ipynb +0 -282
  163. noshot/data/ML TS XAI/NLP/NLP 2/Lab09-Hindle-rooth&MLP/Lab 9 - MLP classifier.ipynb +0 -670
  164. noshot/data/ML TS XAI/NLP/NLP 2/Lab09-Hindle-rooth&MLP/MLP-alternative-code.ipynb +0 -613
  165. noshot/data/ML TS XAI/NLP/NLP 2/Lab09-Hindle-rooth&MLP/hindle-rooth-algorithm.ipynb +0 -74
  166. noshot/data/ML TS XAI/NLP/NLP 2/Lab10(LSTM)/Lab_10_Text_generator_using_LSTM.ipynb +0 -480
  167. noshot/data/ML TS XAI/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/Machine-translation.ipynb +0 -445
  168. noshot/data/ML TS XAI/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/Viterbi-PCFG.ipynb +0 -105
  169. noshot/data/ML TS XAI/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/corpora_tools.py +0 -87
  170. noshot/data/ML TS XAI/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/data_utils.py +0 -11
  171. noshot/data/ML TS XAI/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/train_translator.py +0 -83
  172. noshot/data/ML TS XAI/NLP/NLP 2/Lab12(Information-Extraction)/Information_Extraction.ipynb +0 -201
  173. noshot/data/ML TS XAI/NLP/NLP 3/Backtrack-without-Verbitri.ipynb +0 -185
  174. noshot/data/ML TS XAI/NLP/NLP 3/Backward-Procedure.ipynb +0 -597
  175. noshot/data/ML TS XAI/NLP/NLP 3/Bag_of.ipynb +0 -1422
  176. noshot/data/ML TS XAI/NLP/NLP 3/CYK-algorithm.ipynb +0 -1067
  177. noshot/data/ML TS XAI/NLP/NLP 3/Forward-Procedure.ipynb +0 -477
  178. noshot/data/ML TS XAI/NLP/NLP 3/LSTM.ipynb +0 -1290
  179. noshot/data/ML TS XAI/NLP/NLP 3/Lab 10 - Text generator using LSTM.ipynb +0 -1461
  180. noshot/data/ML TS XAI/NLP/NLP 3/Lab 11 NMT.ipynb +0 -2307
  181. noshot/data/ML TS XAI/NLP/NLP 3/NLP-LAB-4.ipynb +0 -216
  182. noshot/data/ML TS XAI/NLP/NLP 3/NLP-LAB-5.ipynb +0 -216
  183. noshot/data/ML TS XAI/NLP/NLP 3/abc.txt +0 -6
  184. noshot/data/ML TS XAI/NLP/NLP 3/ex-1-nltk.ipynb +0 -711
  185. noshot/data/ML TS XAI/NLP/NLP 3/ex-2-nlp.ipynb +0 -267
  186. noshot/data/ML TS XAI/NLP/NLP 3/exp8&9.ipynb +0 -305
  187. noshot/data/ML TS XAI/NLP/NLP 3/hind.ipynb +0 -287
  188. noshot/data/ML TS XAI/NLP/NLP 3/lab66.ipynb +0 -752
  189. noshot/data/ML TS XAI/NLP/NLP 3/leb_3.ipynb +0 -612
  190. noshot/data/ML TS XAI/NLP/NLP 3/naive_bayes_classifier.pkl +0 -0
  191. noshot/data/ML TS XAI/NLP/NLP 3/nlp_leb_1.ipynb +0 -3008
  192. noshot/data/ML TS XAI/NLP/NLP 3/nlp_leb_2.ipynb +0 -3095
  193. noshot/data/ML TS XAI/NLP/NLP 3/nlplab-9.ipynb +0 -295
  194. noshot/data/ML TS XAI/NLP/NLP 3/nltk-ex-4.ipynb +0 -506
  195. noshot/data/ML TS XAI/NLP/NLP 3/text1.txt +0 -48
  196. noshot/data/ML TS XAI/NLP/NLP 3/text2.txt +0 -8
  197. noshot/data/ML TS XAI/NLP/NLP 3/text3.txt +0 -48
  198. noshot/data/ML TS XAI/NLP/NLP 3/translation-rnn.ipynb +0 -812
  199. noshot/data/ML TS XAI/NLP/NLP 3/word2vector.ipynb +0 -173
  200. noshot/data/ML TS XAI/NLP/NLP 4/Backward Procedure Algorithm.ipynb +0 -179
  201. noshot/data/ML TS XAI/NLP/NLP 4/Chi Square Collocation.ipynb +0 -208
  202. noshot/data/ML TS XAI/NLP/NLP 4/Collocation (T test).ipynb +0 -188
  203. noshot/data/ML TS XAI/NLP/NLP 4/Experiment 1.ipynb +0 -437
  204. noshot/data/ML TS XAI/NLP/NLP 4/Forward Procedure Algorithm.ipynb +0 -132
  205. noshot/data/ML TS XAI/NLP/NLP 4/Hindle Rooth.ipynb +0 -414
  206. noshot/data/ML TS XAI/NLP/NLP 4/MachineTranslation.ipynb +0 -368
  207. noshot/data/ML TS XAI/NLP/NLP 4/Multi Layer Perceptron using MLPClassifier.ipynb +0 -86
  208. noshot/data/ML TS XAI/NLP/NLP 4/Multi Layer Perceptron using Tensorflow.ipynb +0 -112
  209. noshot/data/ML TS XAI/NLP/NLP 4/PCFG Inside Probability.ipynb +0 -451
  210. noshot/data/ML TS XAI/NLP/NLP 4/Text Generation using LSTM.ipynb +0 -297
  211. noshot/data/ML TS XAI/NLP/NLP 4/Viterbi.ipynb +0 -310
  212. noshot/data/ML TS XAI/NLP/NLP 4/Word Sense Disambiguation.ipynb +0 -335
  213. noshot/data/ML TS XAI/NLP/NLP 5/10.Text Generation using LSTM.ipynb +0 -316
  214. noshot/data/ML TS XAI/NLP/NLP 5/11.Machine Translation.ipynb +0 -868
  215. noshot/data/ML TS XAI/NLP/NLP 5/2.T and Chi2 Test.ipynb +0 -204
  216. noshot/data/ML TS XAI/NLP/NLP 5/3.Word Sense Diambiguation.ipynb +0 -234
  217. noshot/data/ML TS XAI/NLP/NLP 5/4.Hinddle and Rooth.ipynb +0 -128
  218. noshot/data/ML TS XAI/NLP/NLP 5/5.Forward and Backward.ipynb +0 -149
  219. noshot/data/ML TS XAI/NLP/NLP 5/6.Viterbi.ipynb +0 -111
  220. noshot/data/ML TS XAI/NLP/NLP 5/7.PCFG Parse Tree.ipynb +0 -134
  221. noshot/data/ML TS XAI/NLP/NLP 5/7.PCFG using cyk.ipynb +0 -101
  222. noshot/data/ML TS XAI/NLP/NLP 5/8.Bag of words and TF-IDF.ipynb +0 -310
  223. noshot/data/ML TS XAI/NLP/NLP 5/9.Word2Vector.ipynb +0 -78
  224. noshot/data/ML TS XAI/NLP/NLP 5/NLP ALL In One.ipynb +0 -2619
  225. noshot/data/ML TS XAI/NLP/NLP 5/sample1.txt +0 -15
  226. noshot/data/ML TS XAI/NLP/NLP 5/sample2.txt +0 -4
  227. noshot/data/ML TS XAI/NLP/NLP 5/word2vec_model.bin +0 -0
  228. noshot/data/ML TS XAI/NLP/NLP 6/1. Tokenize, Tagging, NER, Parse Tree.ipynb +0 -312
  229. noshot/data/ML TS XAI/NLP/NLP 6/2. T Test and Chi2 Test.ipynb +0 -185
  230. noshot/data/ML TS XAI/NLP/NLP 6/3. Naive Bayes WSD.ipynb +0 -199
  231. noshot/data/ML TS XAI/NLP/NLP 6/4. Hinddle and Rooth.ipynb +0 -151
  232. noshot/data/ML TS XAI/NLP/NLP 6/5 and 6 FWD, BWD, Viterbi.ipynb +0 -164
  233. noshot/data/ML TS XAI/NLP/NLP 6/7. PCFG using CYK.ipynb +0 -383
  234. noshot/data/ML TS XAI/NLP/NLP 6/8. BOW and TF-IDF.ipynb +0 -252
  235. noshot/data/ML TS XAI/Ubuntu CN Lab.iso +0 -0
  236. noshot-0.1.7.dist-info/RECORD +0 -216
  237. {noshot-0.1.7.dist-info → noshot-0.1.9.dist-info}/LICENSE.txt +0 -0
  238. {noshot-0.1.7.dist-info → noshot-0.1.9.dist-info}/WHEEL +0 -0
  239. {noshot-0.1.7.dist-info → noshot-0.1.9.dist-info}/top_level.txt +0 -0
@@ -1,597 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 1,
6
- "id": "8d2eeff8-b13a-497d-a879-98946745f92e",
7
- "metadata": {},
8
- "outputs": [
9
- {
10
- "name": "stdin",
11
- "output_type": "stream",
12
- "text": [
13
- "Enter the states (comma-separated): cp,ip\n",
14
- "Enter the possible observations (comma-separated): lem,icet,cola\n",
15
- "Enter the observation sequence as space-separated names (options: ['lem', 'icet', 'cola']): lem icet cola\n"
16
- ]
17
- },
18
- {
19
- "name": "stdout",
20
- "output_type": "stream",
21
- "text": [
22
- "\n",
23
- "Enter the state transition probabilities:\n"
24
- ]
25
- },
26
- {
27
- "name": "stdin",
28
- "output_type": "stream",
29
- "text": [
30
- "P(cp | cp): 0.7\n",
31
- "P(ip | cp): 0.5\n",
32
- "P(cp | ip): 0.3\n",
33
- "P(ip | ip): 0.5\n"
34
- ]
35
- },
36
- {
37
- "name": "stdout",
38
- "output_type": "stream",
39
- "text": [
40
- "\n",
41
- "Enter the emission probabilities:\n"
42
- ]
43
- },
44
- {
45
- "name": "stdin",
46
- "output_type": "stream",
47
- "text": [
48
- "P(lem | cp): 0.3\n",
49
- "P(icet | cp): 0.1\n",
50
- "P(cola | cp): 0.6\n",
51
- "P(lem | ip): 0.2\n",
52
- "P(icet | ip): 0.7\n",
53
- "P(cola | ip): 0.1\n"
54
- ]
55
- },
56
- {
57
- "name": "stdout",
58
- "output_type": "stream",
59
- "text": [
60
- "\n",
61
- "Enter the initial state probabilities (comma-separated):\n"
62
- ]
63
- },
64
- {
65
- "name": "stdin",
66
- "output_type": "stream",
67
- "text": [
68
- "Enter initial probabilities for ['cp', 'ip']: 1.0,0.0\n"
69
- ]
70
- },
71
- {
72
- "name": "stdout",
73
- "output_type": "stream",
74
- "text": [
75
- "\n",
76
- "Backward Matrix:\n",
77
- " [[0.1134 0.47 1. ]\n",
78
- " [0.0946 0.23 1. ]]\n",
79
- "Probability of the observation sequence (using backward procedure): 0.03401999999999999\n",
80
- "\n",
81
- "Viterbi Matrix:\n",
82
- " [[0.3 0.021 0.0189 ]\n",
83
- " [0. 0.105 0.00525]]\n",
84
- "Most probable state sequence: ['cp', 'ip', 'cp']\n"
85
- ]
86
- }
87
- ],
88
- "source": [
89
- "import numpy as np\n",
90
- "\n",
91
- "# Step 1: Define states and observations based on user input\n",
92
- "states = list(map(str.strip, input(\"Enter the states (comma-separated): \").split(',')))\n",
93
- "observations = list(map(str.strip, input(\"Enter the possible observations (comma-separated): \").split(',')))\n",
94
- "\n",
95
- "# Step 2: Get user input for the observation sequence\n",
96
- "observation_seq = list(map(str.strip, input(f\"Enter the observation sequence as space-separated names (options: {observations}): \").split()))\n",
97
- "\n",
98
- "# Step 3: Convert observation sequence to indices\n",
99
- "try:\n",
100
- " observation_indices = [observations.index(obs) for obs in observation_seq]\n",
101
- "except ValueError as e:\n",
102
- " print(f\"Error: {e}. Please make sure your observation sequence contains only valid options: {observations}.\")\n",
103
- " exit()\n",
104
- "\n",
105
- "# Step 4: Get user input for the transition matrix\n",
106
- "print(\"\\nEnter the state transition probabilities:\")\n",
107
- "transition_matrix = np.zeros((len(states), len(states)))\n",
108
- "for i in range(len(states)):\n",
109
- " for j in range(len(states)):\n",
110
- " transition_matrix[i, j] = float(input(f\"P({states[j]} | {states[i]}): \"))\n",
111
- "\n",
112
- "# Step 5: Get user input for the emission matrix\n",
113
- "print(\"\\nEnter the emission probabilities:\")\n",
114
- "emission_matrix = np.zeros((len(states), len(observations)))\n",
115
- "for i in range(len(states)):\n",
116
- " for j in range(len(observations)):\n",
117
- " emission_matrix[i, j] = float(input(f\"P({observations[j]} | {states[i]}): \"))\n",
118
- "\n",
119
- "# Step 6: Set initial state probabilities (ask the user to input them)\n",
120
- "initial_probabilities = np.zeros(len(states))\n",
121
- "print(\"\\nEnter the initial state probabilities (comma-separated):\")\n",
122
- "initial_probabilities = list(map(float, input(f\"Enter initial probabilities for {states}: \").split(',')))\n",
123
- "\n",
124
- "# Step 7: Backward Procedure\n",
125
- "def backward_procedure(observation_seq, transition_matrix, emission_matrix):\n",
126
- " num_states = len(transition_matrix)\n",
127
- " num_observations = len(observation_seq)\n",
128
- " \n",
129
- " # Initialize the backward matrix\n",
130
- " backward_matrix = np.zeros((num_states, num_observations))\n",
131
- " \n",
132
- " # Initialization step: Fill the last column with 1 (termination condition)\n",
133
- " backward_matrix[:, num_observations - 1] = 1\n",
134
- " \n",
135
- " # Recursion step\n",
136
- " for t in range(num_observations - 2, -1, -1):\n",
137
- " for i in range(num_states):\n",
138
- " backward_matrix[i, t] = sum(transition_matrix[i, j] * emission_matrix[j, observation_seq[t + 1]] * backward_matrix[j, t + 1] for j in range(num_states))\n",
139
- " \n",
140
- " # Compute the probability of the observation sequence\n",
141
- " prob_observation = sum(initial_probabilities[i] * emission_matrix[i, observation_seq[0]] * backward_matrix[i, 0] for i in range(num_states))\n",
142
- " \n",
143
- " return backward_matrix, prob_observation\n",
144
- "\n",
145
- "# Step 8: Viterbi Algorithm (to find the best state sequence)\n",
146
- "def viterbi_algorithm(observation_seq, transition_matrix, emission_matrix, initial_probabilities):\n",
147
- " num_states = len(transition_matrix)\n",
148
- " num_observations = len(observation_seq)\n",
149
- " \n",
150
- " # Initialize the Viterbi matrix and the backpointer matrix\n",
151
- " viterbi_matrix = np.zeros((num_states, num_observations))\n",
152
- " backpointer = np.zeros((num_states, num_observations), dtype=int)\n",
153
- " \n",
154
- " # Initialization step\n",
155
- " for i in range(num_states):\n",
156
- " viterbi_matrix[i, 0] = initial_probabilities[i] * emission_matrix[i, observation_seq[0]]\n",
157
- " \n",
158
- " # Recursion step\n",
159
- " for t in range(1, num_observations):\n",
160
- " for j in range(num_states):\n",
161
- " probabilities = [viterbi_matrix[i, t - 1] * transition_matrix[i, j] * emission_matrix[j, observation_seq[t]] for i in range(num_states)]\n",
162
- " viterbi_matrix[j, t] = max(probabilities)\n",
163
- " backpointer[j, t] = np.argmax(probabilities)\n",
164
- " \n",
165
- " # Termination step\n",
166
- " best_last_state = np.argmax(viterbi_matrix[:, num_observations - 1])\n",
167
- " \n",
168
- " # Backtrack to find the most probable state sequence\n",
169
- " best_path = [best_last_state]\n",
170
- " for t in range(num_observations - 1, 0, -1):\n",
171
- " best_last_state = backpointer[best_last_state, t]\n",
172
- " best_path.insert(0, best_last_state)\n",
173
- " \n",
174
- " best_state_sequence = [states[state_index] for state_index in best_path]\n",
175
- " \n",
176
- " return best_state_sequence, viterbi_matrix\n",
177
- "\n",
178
- "# Step 9: Compute the backward matrix and the probability of the observation sequence\n",
179
- "backward_matrix, prob_observation_backward = backward_procedure(observation_indices, transition_matrix, emission_matrix)\n",
180
- "print(\"\\nBackward Matrix:\\n\", backward_matrix)\n",
181
- "print(\"Probability of the observation sequence (using backward procedure):\", prob_observation_backward)\n",
182
- "\n",
183
- "# Step 10: Compute the most probable state sequence using Viterbi algorithm\n",
184
- "best_state_sequence, viterbi_matrix = viterbi_algorithm(observation_indices, transition_matrix, emission_matrix, initial_probabilities)\n",
185
- "print(\"\\nViterbi Matrix:\\n\", viterbi_matrix)\n",
186
- "print(\"Most probable state sequence:\", best_state_sequence)\n"
187
- ]
188
- },
189
- {
190
- "cell_type": "code",
191
- "execution_count": 1,
192
- "id": "2acfa85e-c9f1-41ce-9ebf-6283066554cc",
193
- "metadata": {},
194
- "outputs": [
195
- {
196
- "name": "stdin",
197
- "output_type": "stream",
198
- "text": [
199
- "Enter the states (comma-separated): 1,2,3\n",
200
- "Enter the possible observations (comma-separated): up,down,unchanged\n",
201
- "Enter the observation sequence as space-separated names (options: ['up', 'down', 'unchanged']): up up up up up\n"
202
- ]
203
- },
204
- {
205
- "name": "stdout",
206
- "output_type": "stream",
207
- "text": [
208
- "\n",
209
- "Enter the state transition probabilities:\n"
210
- ]
211
- },
212
- {
213
- "name": "stdin",
214
- "output_type": "stream",
215
- "text": [
216
- "P(1 | 1): 0.6\n",
217
- "P(2 | 1): 0.2\n",
218
- "P(3 | 1): 0.2\n",
219
- "P(1 | 2): 0.5\n",
220
- "P(2 | 2): 0.3\n",
221
- "P(3 | 2): 0.2\n",
222
- "P(1 | 3): 0.4\n",
223
- "P(2 | 3): 0.1\n",
224
- "P(3 | 3): 0.5\n"
225
- ]
226
- },
227
- {
228
- "name": "stdout",
229
- "output_type": "stream",
230
- "text": [
231
- "\n",
232
- "Enter the emission probabilities:\n"
233
- ]
234
- },
235
- {
236
- "name": "stdin",
237
- "output_type": "stream",
238
- "text": [
239
- "P(up | 1): 0.7\n",
240
- "P(down | 1): 0.1\n",
241
- "P(unchanged | 1): 0.2\n",
242
- "P(up | 2): 0.1\n",
243
- "P(down | 2): 0.6\n",
244
- "P(unchanged | 2): 0.3\n",
245
- "P(up | 3): 0.3\n",
246
- "P(down | 3): 0.3\n",
247
- "P(unchanged | 3): 0.4\n"
248
- ]
249
- },
250
- {
251
- "name": "stdout",
252
- "output_type": "stream",
253
- "text": [
254
- "\n",
255
- "Enter the initial state probabilities (comma-separated):\n"
256
- ]
257
- },
258
- {
259
- "name": "stdin",
260
- "output_type": "stream",
261
- "text": [
262
- "Enter initial probabilities for ['1', '2', '3']: 0.5,0.2,0.3\n"
263
- ]
264
- },
265
- {
266
- "name": "stdout",
267
- "output_type": "stream",
268
- "text": [
269
- "\n",
270
- "Backward Matrix:\n",
271
- " [[0.05859736 0.1199 0.2452 0.5 1. ]\n",
272
- " [0.05125318 0.104882 0.2146 0.44 1. ]\n",
273
- " [0.04997512 0.102362 0.2104 0.44 1. ]]\n",
274
- "Probability of the observation sequence (using backward procedure): 0.026031900399999995\n",
275
- "\n",
276
- "Viterbi Matrix:\n",
277
- " [[0.35 0.147 0.06174 0.0259308 0.01089094]\n",
278
- " [0.02 0.007 0.00294 0.0012348 0.00051862]\n",
279
- " [0.09 0.021 0.00882 0.0037044 0.00155585]]\n",
280
- "Most probable state sequence: ['1', '1', '1', '1', '1']\n"
281
- ]
282
- }
283
- ],
284
- "source": [
285
- "import numpy as np\n",
286
- "\n",
287
- "# Step 1: Define states and observations based on user input\n",
288
- "states = list(map(str.strip, input(\"Enter the states (comma-separated): \").split(',')))\n",
289
- "observations = list(map(str.strip, input(\"Enter the possible observations (comma-separated): \").split(',')))\n",
290
- "\n",
291
- "# Step 2: Get user input for the observation sequence\n",
292
- "observation_seq = list(map(str.strip, input(f\"Enter the observation sequence as space-separated names (options: {observations}): \").split()))\n",
293
- "\n",
294
- "# Step 3: Convert observation sequence to indices\n",
295
- "try:\n",
296
- " observation_indices = [observations.index(obs) for obs in observation_seq]\n",
297
- "except ValueError as e:\n",
298
- " print(f\"Error: {e}. Please make sure your observation sequence contains only valid options: {observations}.\")\n",
299
- " exit()\n",
300
- "\n",
301
- "# Step 4: Get user input for the transition matrix\n",
302
- "print(\"\\nEnter the state transition probabilities:\")\n",
303
- "transition_matrix = np.zeros((len(states), len(states)))\n",
304
- "for i in range(len(states)):\n",
305
- " for j in range(len(states)):\n",
306
- " transition_matrix[i, j] = float(input(f\"P({states[j]} | {states[i]}): \"))\n",
307
- "\n",
308
- "# Step 5: Get user input for the emission matrix\n",
309
- "print(\"\\nEnter the emission probabilities:\")\n",
310
- "emission_matrix = np.zeros((len(states), len(observations)))\n",
311
- "for i in range(len(states)):\n",
312
- " for j in range(len(observations)):\n",
313
- " emission_matrix[i, j] = float(input(f\"P({observations[j]} | {states[i]}): \"))\n",
314
- "\n",
315
- "# Step 6: Set initial state probabilities (ask the user to input them)\n",
316
- "initial_probabilities = np.zeros(len(states))\n",
317
- "print(\"\\nEnter the initial state probabilities (comma-separated):\")\n",
318
- "initial_probabilities = list(map(float, input(f\"Enter initial probabilities for {states}: \").split(',')))\n",
319
- "\n",
320
- "# Step 7: Backward Procedure\n",
321
- "def backward_procedure(observation_seq, transition_matrix, emission_matrix):\n",
322
- " num_states = len(transition_matrix)\n",
323
- " num_observations = len(observation_seq)\n",
324
- " \n",
325
- " # Initialize the backward matrix\n",
326
- " backward_matrix = np.zeros((num_states, num_observations))\n",
327
- " \n",
328
- " # Initialization step: Fill the last column with 1 (termination condition)\n",
329
- " backward_matrix[:, num_observations - 1] = 1\n",
330
- " \n",
331
- " # Recursion step\n",
332
- " for t in range(num_observations - 2, -1, -1):\n",
333
- " for i in range(num_states):\n",
334
- " backward_matrix[i, t] = sum(transition_matrix[i, j] * emission_matrix[j, observation_seq[t + 1]] * backward_matrix[j, t + 1] for j in range(num_states))\n",
335
- " \n",
336
- " # Compute the probability of the observation sequence\n",
337
- " prob_observation = sum(initial_probabilities[i] * emission_matrix[i, observation_seq[0]] * backward_matrix[i, 0] for i in range(num_states))\n",
338
- " \n",
339
- " return backward_matrix, prob_observation\n",
340
- "\n",
341
- "# Step 8: Viterbi Algorithm (to find the best state sequence)\n",
342
- "def viterbi_algorithm(observation_seq, transition_matrix, emission_matrix, initial_probabilities):\n",
343
- " num_states = len(transition_matrix)\n",
344
- " num_observations = len(observation_seq)\n",
345
- " \n",
346
- " # Initialize the Viterbi matrix and the backpointer matrix\n",
347
- " viterbi_matrix = np.zeros((num_states, num_observations))\n",
348
- " backpointer = np.zeros((num_states, num_observations), dtype=int)\n",
349
- " \n",
350
- " # Initialization step\n",
351
- " for i in range(num_states):\n",
352
- " viterbi_matrix[i, 0] = initial_probabilities[i] * emission_matrix[i, observation_seq[0]]\n",
353
- " \n",
354
- " # Recursion step\n",
355
- " for t in range(1, num_observations):\n",
356
- " for j in range(num_states):\n",
357
- " probabilities = [viterbi_matrix[i, t - 1] * transition_matrix[i, j] * emission_matrix[j, observation_seq[t]] for i in range(num_states)]\n",
358
- " viterbi_matrix[j, t] = max(probabilities)\n",
359
- " backpointer[j, t] = np.argmax(probabilities)\n",
360
- " \n",
361
- " # Termination step\n",
362
- " best_last_state = np.argmax(viterbi_matrix[:, num_observations - 1])\n",
363
- " \n",
364
- " # Backtrack to find the most probable state sequence\n",
365
- " best_path = [best_last_state]\n",
366
- " for t in range(num_observations - 1, 0, -1):\n",
367
- " best_last_state = backpointer[best_last_state, t]\n",
368
- " best_path.insert(0, best_last_state)\n",
369
- " \n",
370
- " best_state_sequence = [states[state_index] for state_index in best_path]\n",
371
- " \n",
372
- " return best_state_sequence, viterbi_matrix\n",
373
- "\n",
374
- "# Step 9: Compute the backward matrix and the probability of the observation sequence\n",
375
- "backward_matrix, prob_observation_backward = backward_procedure(observation_indices, transition_matrix, emission_matrix)\n",
376
- "print(\"\\nBackward Matrix:\\n\", backward_matrix)\n",
377
- "print(\"Probability of the observation sequence (using backward procedure):\", prob_observation_backward)\n",
378
- "\n",
379
- "# Step 10: Compute the most probable state sequence using Viterbi algorithm\n",
380
- "best_state_sequence, viterbi_matrix = viterbi_algorithm(observation_indices, transition_matrix, emission_matrix, initial_probabilities)\n",
381
- "print(\"\\nViterbi Matrix:\\n\", viterbi_matrix)\n",
382
- "print(\"Most probable state sequence:\", best_state_sequence)\n"
383
- ]
384
- },
385
- {
386
- "cell_type": "code",
387
- "execution_count": 2,
388
- "id": "47ad375b-4939-4c61-84b9-cff0eb2485c8",
389
- "metadata": {},
390
- "outputs": [
391
- {
392
- "name": "stdin",
393
- "output_type": "stream",
394
- "text": [
395
- "Enter the number of states: 2\n",
396
- "Enter state 1: cp\n",
397
- "Enter state 2: ip\n",
398
- "Enter the number of observations: 3\n",
399
- "Enter observation 1: lem\n",
400
- "Enter observation 2: icet\n",
401
- "Enter observation 3: cola\n"
402
- ]
403
- },
404
- {
405
- "name": "stdout",
406
- "output_type": "stream",
407
- "text": [
408
- "\n",
409
- "Enter start probabilities for each state:\n"
410
- ]
411
- },
412
- {
413
- "name": "stdin",
414
- "output_type": "stream",
415
- "text": [
416
- "Start probability for cp: 1.0\n",
417
- "Start probability for ip: 0.0\n"
418
- ]
419
- },
420
- {
421
- "name": "stdout",
422
- "output_type": "stream",
423
- "text": [
424
- "\n",
425
- "Enter transition probabilities (from each state to other states):\n"
426
- ]
427
- },
428
- {
429
- "name": "stdin",
430
- "output_type": "stream",
431
- "text": [
432
- "Transition probability from cp to cp: 0.7\n",
433
- "Transition probability from cp to ip: 0.3\n",
434
- "Transition probability from ip to cp: 0.5\n",
435
- "Transition probability from ip to ip: 0.5\n"
436
- ]
437
- },
438
- {
439
- "name": "stdout",
440
- "output_type": "stream",
441
- "text": [
442
- "\n",
443
- "Enter emission probabilities (from each state to each observation):\n"
444
- ]
445
- },
446
- {
447
- "name": "stdin",
448
- "output_type": "stream",
449
- "text": [
450
- "Emission probability of lem from cp: 0.3\n",
451
- "Emission probability of icet from cp: 0.1\n",
452
- "Emission probability of cola from cp: 0.6\n",
453
- "Emission probability of lem from ip: 0.2\n",
454
- "Emission probability of icet from ip: 0.7\n",
455
- "Emission probability of cola from ip: 0.1\n",
456
- "\n",
457
- "Enter the observation sequence (space-separated): lem icet cola\n"
458
- ]
459
- },
460
- {
461
- "name": "stdout",
462
- "output_type": "stream",
463
- "text": [
464
- "\n",
465
- "Best state sequence: ['cp', 'ip', 'cp']\n",
466
- "Best path probability: 0.0189\n"
467
- ]
468
- }
469
- ],
470
- "source": [
471
- "import numpy as np\n",
472
- "class HiddenMarkovModel:\n",
473
- " def __init__(self, states, observations, start_prob, trans_prob, emission_prob):\n",
474
- " self.states = states # Possible hidden states (tags)\n",
475
- " self.observations = observations # Possible observations (words)\n",
476
- " self.start_prob = start_prob # Initial probabilities of states\n",
477
- " self.trans_prob = trans_prob # Transition probabilities between states\n",
478
- " self.emission_prob = emission_prob # Emission probabilities of states producing observations\n",
479
- "\n",
480
- " def viterbi(self, obs_seq):\n",
481
- " n_states = len(self.states)\n",
482
- " n_observations = len(obs_seq)\n",
483
- "\n",
484
- " viterbi_table = np.zeros((n_states, n_observations))\n",
485
- " backpointer = np.zeros((n_states, n_observations), dtype=int)\n",
486
- "\n",
487
- " for s in range(n_states):\n",
488
- " viterbi_table[s, 0] = self.start_prob[s] * self.emission_prob[s][self.observations.index(obs_seq[0])]\n",
489
- " backpointer[s, 0] = 0\n",
490
- "\n",
491
- " for t in range(1, n_observations):\n",
492
- " for s in range(n_states):\n",
493
- "\n",
494
- " max_prob, max_state = max(\n",
495
- " (viterbi_table[prev_s, t-1] * self.trans_prob[prev_s][s] *\n",
496
- " self.emission_prob[s][self.observations.index(obs_seq[t])], prev_s)\n",
497
- " for prev_s in range(n_states)\n",
498
- " )\n",
499
- " viterbi_table[s, t] = max_prob\n",
500
- " backpointer[s, t] = max_state\n",
501
- " \n",
502
- " best_path_prob = max(viterbi_table[:, -1])\n",
503
- " best_path_pointer = np.argmax(viterbi_table[:, -1])\n",
504
- " best_path = [best_path_pointer]\n",
505
- " \n",
506
- " for t in range(n_observations - 1, 0, -1):\n",
507
- " best_path_pointer = backpointer[best_path_pointer, t]\n",
508
- " best_path.insert(0, best_path_pointer)\n",
509
- " \n",
510
- " best_state_sequence = [self.states[i] for i in best_path]\n",
511
- " return best_state_sequence, best_path_prob\n",
512
- "\n",
513
- "\n",
514
- "def get_user_input():\n",
515
- " num_states = int(input(\"Enter the number of states: \"))\n",
516
- " states = []\n",
517
- " for i in range(num_states):\n",
518
- " state = input(f\"Enter state {i + 1}: \")\n",
519
- " states.append(state)\n",
520
- " \n",
521
- " num_observations = int(input(\"Enter the number of observations: \"))\n",
522
- " observations = []\n",
523
- " for i in range(num_observations):\n",
524
- " observation = input(f\"Enter observation {i + 1}: \")\n",
525
- " observations.append(observation)\n",
526
- " \n",
527
- " print(\"\\nEnter start probabilities for each state:\")\n",
528
- " start_prob = []\n",
529
- " for state in states:\n",
530
- " prob = float(input(f\"Start probability for {state}: \"))\n",
531
- " start_prob.append(prob)\n",
532
- " \n",
533
- " print(\"\\nEnter transition probabilities (from each state to other states):\")\n",
534
- " trans_prob = []\n",
535
- " for i, from_state in enumerate(states):\n",
536
- " trans_row = []\n",
537
- " for j, to_state in enumerate(states):\n",
538
- " prob = float(input(f\"Transition probability from {from_state} to {to_state}: \"))\n",
539
- " trans_row.append(prob)\n",
540
- " trans_prob.append(trans_row)\n",
541
- " \n",
542
- " print(\"\\nEnter emission probabilities (from each state to each observation):\")\n",
543
- " emission_prob = []\n",
544
- " for i, state in enumerate(states):\n",
545
- " emission_row = []\n",
546
- " for j, observation in enumerate(observations):\n",
547
- " prob = float(input(f\"Emission probability of {observation} from {state}: \"))\n",
548
- " emission_row.append(prob)\n",
549
- " emission_prob.append(emission_row)\n",
550
- " \n",
551
- " return states, observations, start_prob, trans_prob, emission_prob\n",
552
- "\n",
553
- "\n",
554
- "if __name__ == \"__main__\":\n",
555
- " states, observations, start_prob, trans_prob, emission_prob = get_user_input()\n",
556
- "\n",
557
- " hmm = HiddenMarkovModel(states, observations, start_prob, trans_prob, emission_prob)\n",
558
- "\n",
559
- " obs_seq = input(\"\\nEnter the observation sequence (space-separated): \").split()\n",
560
- "\n",
561
- " best_sequence, best_prob = hmm.viterbi(obs_seq)\n",
562
- " print(\"\\nBest state sequence:\", best_sequence)\n",
563
- " print(\"Best path probability:\", best_prob)\n",
564
- " "
565
- ]
566
- },
567
- {
568
- "cell_type": "code",
569
- "execution_count": null,
570
- "id": "a7d52d1f-c7fb-4b4b-acc5-cc8c4ee70dbe",
571
- "metadata": {},
572
- "outputs": [],
573
- "source": []
574
- }
575
- ],
576
- "metadata": {
577
- "kernelspec": {
578
- "display_name": "Python 3 (ipykernel)",
579
- "language": "python",
580
- "name": "python3"
581
- },
582
- "language_info": {
583
- "codemirror_mode": {
584
- "name": "ipython",
585
- "version": 3
586
- },
587
- "file_extension": ".py",
588
- "mimetype": "text/x-python",
589
- "name": "python",
590
- "nbconvert_exporter": "python",
591
- "pygments_lexer": "ipython3",
592
- "version": "3.11.7"
593
- }
594
- },
595
- "nbformat": 4,
596
- "nbformat_minor": 5
597
- }