noshot 0.1.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 (210) hide show
  1. noshot/__init__.py +1 -0
  2. noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(A) Breadth First Search.ipynb +112 -0
  3. noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(B) Depth First Search.ipynb +111 -0
  4. noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(C) Uniform Cost Search.ipynb +134 -0
  5. noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(D) Depth Limites Search.ipynb +115 -0
  6. noshot/data/AIDS CN NLP/AIDS/1. Implement Basic Search Strategies/(E) Iterative Deepening DFS.ipynb +123 -0
  7. noshot/data/AIDS CN NLP/AIDS/10. ANOVA/2_ANOVA.csv +769 -0
  8. noshot/data/AIDS CN NLP/AIDS/10. ANOVA/One Way ANOVA (Repeated Measure).ipynb +126 -0
  9. noshot/data/AIDS CN NLP/AIDS/10. ANOVA/One Way ANOVA.ipynb +134 -0
  10. noshot/data/AIDS CN NLP/AIDS/10. ANOVA/Sample 1 Way ANOVA Test.ipynb +119 -0
  11. noshot/data/AIDS CN NLP/AIDS/10. ANOVA/Two Way ANOVA.ipynb +138 -0
  12. noshot/data/AIDS CN NLP/AIDS/10. ANOVA/reaction_time.csv +5 -0
  13. noshot/data/AIDS CN NLP/AIDS/10. ANOVA/sample_data.csv +16 -0
  14. noshot/data/AIDS CN NLP/AIDS/10. ANOVA/sleep_deprivation.csv +4 -0
  15. noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/3_Linear.csv +4802 -0
  16. noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/Linear Regression LAB.ipynb +113 -0
  17. noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/Linear Regression New- sklearn.ipynb +118 -0
  18. noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/Linear Regression.ipynb +148 -0
  19. noshot/data/AIDS CN NLP/AIDS/11. Linear Regression/house_rate.csv +22 -0
  20. noshot/data/AIDS CN NLP/AIDS/12. Logistic Regression/Logistic Regression New- sklearn.ipynb +128 -0
  21. noshot/data/AIDS CN NLP/AIDS/12. Logistic Regression/Logistic Regression.ipynb +145 -0
  22. noshot/data/AIDS CN NLP/AIDS/12. Logistic Regression/default.csv +1001 -0
  23. noshot/data/AIDS CN NLP/AIDS/12. Logistic Regression/hours_scores_records.csv +101 -0
  24. noshot/data/AIDS CN NLP/AIDS/2. Implement A Star And MA Star/(A) Astar.ipynb +256 -0
  25. noshot/data/AIDS CN NLP/AIDS/2. Implement A Star And MA Star/(B) IDAstar.ipynb +157 -0
  26. noshot/data/AIDS CN NLP/AIDS/2. Implement A Star And MA Star/(C) SMAstar.ipynb +178 -0
  27. noshot/data/AIDS CN NLP/AIDS/3. Genetic Algorithm/Genetic.ipynb +95 -0
  28. noshot/data/AIDS CN NLP/AIDS/4. Simulated Annealing/Simulated Annealing.ipynb +74 -0
  29. noshot/data/AIDS CN NLP/AIDS/4. Simulated Annealing/Sudoku Simulated Annealing.ipynb +103 -0
  30. noshot/data/AIDS CN NLP/AIDS/5. Alpha Beta Pruning/AlphaBetaPruning.ipynb +182 -0
  31. noshot/data/AIDS CN NLP/AIDS/6. Consraint Satisfaction Problems (CSP)/(A) CSP House Allocation.ipynb +120 -0
  32. noshot/data/AIDS CN NLP/AIDS/6. Consraint Satisfaction Problems (CSP)/(B) CSP Map Coloring.ipynb +125 -0
  33. noshot/data/AIDS CN NLP/AIDS/7. Random Sampling/Random Sampling.ipynb +73 -0
  34. noshot/data/AIDS CN NLP/AIDS/7. Random Sampling/height_weight_bmi.csv +8389 -0
  35. noshot/data/AIDS CN NLP/AIDS/8. Z Test/Z Test Hash Function.ipynb +141 -0
  36. noshot/data/AIDS CN NLP/AIDS/8. Z Test/Z Test.ipynb +151 -0
  37. noshot/data/AIDS CN NLP/AIDS/8. Z Test/height_weight_bmi.csv +8389 -0
  38. noshot/data/AIDS CN NLP/AIDS/9. T Test/1_heart.csv +304 -0
  39. noshot/data/AIDS CN NLP/AIDS/9. T Test/Independent T Test.ipynb +119 -0
  40. noshot/data/AIDS CN NLP/AIDS/9. T Test/Paired T Test.ipynb +118 -0
  41. noshot/data/AIDS CN NLP/AIDS/9. T Test/T Test Hash Function.ipynb +142 -0
  42. noshot/data/AIDS CN NLP/AIDS/9. T Test/T Test.ipynb +158 -0
  43. noshot/data/AIDS CN NLP/AIDS/9. T Test/height_weight_bmi.csv +8389 -0
  44. noshot/data/AIDS CN NLP/AIDS/9. T Test/iq_test.csv +0 -0
  45. noshot/data/AIDS CN NLP/AIDS/Others (AllinOne)/All In One.ipynb +4581 -0
  46. noshot/data/AIDS CN NLP/CN/1. Chat Application/chat.java +81 -0
  47. noshot/data/AIDS CN NLP/CN/1. Chat Application/output.png +0 -0
  48. noshot/data/AIDS CN NLP/CN/1. Chat Application/procedure.png +0 -0
  49. noshot/data/AIDS CN NLP/CN/10. Ethernet LAN IEEE 802.3/LAN.tcl +65 -0
  50. noshot/data/AIDS CN NLP/CN/10. Ethernet LAN IEEE 802.3/analysis.awk +44 -0
  51. noshot/data/AIDS CN NLP/CN/10. Ethernet LAN IEEE 802.3/output.png +0 -0
  52. noshot/data/AIDS CN NLP/CN/10. Ethernet LAN IEEE 802.3/procedure.png +0 -0
  53. noshot/data/AIDS CN NLP/CN/11. Wireless LAN IEEE 802.11/complexdcf.tcl +229 -0
  54. noshot/data/AIDS CN NLP/CN/11. Wireless LAN IEEE 802.11/output.png +0 -0
  55. noshot/data/AIDS CN NLP/CN/11. Wireless LAN IEEE 802.11/procedure.png +0 -0
  56. noshot/data/AIDS CN NLP/CN/2. File Transfer/file_to_send.txt +2 -0
  57. noshot/data/AIDS CN NLP/CN/2. File Transfer/filetransfer.java +119 -0
  58. noshot/data/AIDS CN NLP/CN/2. File Transfer/output.png +0 -0
  59. noshot/data/AIDS CN NLP/CN/2. File Transfer/procedure.png +0 -0
  60. noshot/data/AIDS CN NLP/CN/3. RMI (Remote Method Invocation)/output.png +0 -0
  61. noshot/data/AIDS CN NLP/CN/3. RMI (Remote Method Invocation)/procedure.png +0 -0
  62. noshot/data/AIDS CN NLP/CN/3. RMI (Remote Method Invocation)/rmi.java +56 -0
  63. noshot/data/AIDS CN NLP/CN/4. Wired Network/output.png +0 -0
  64. noshot/data/AIDS CN NLP/CN/4. Wired Network/procedure.png +0 -0
  65. noshot/data/AIDS CN NLP/CN/4. Wired Network/wired.awk +25 -0
  66. noshot/data/AIDS CN NLP/CN/4. Wired Network/wired.tcl +81 -0
  67. noshot/data/AIDS CN NLP/CN/5. Wireless Network/output.png +0 -0
  68. noshot/data/AIDS CN NLP/CN/5. Wireless Network/procedure.png +0 -0
  69. noshot/data/AIDS CN NLP/CN/5. Wireless Network/wireless.awk +27 -0
  70. noshot/data/AIDS CN NLP/CN/5. Wireless Network/wireless.tcl +153 -0
  71. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/analysis.awk +27 -0
  72. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/output.png +0 -0
  73. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/sack.tcl +86 -0
  74. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Sack And Vegas/vegas.tcl +86 -0
  75. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/analysis.awk +28 -0
  76. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/output.png +0 -0
  77. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/reno.tcl +78 -0
  78. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Congestion Control/Tahoe And Reno/tahoe.tcl +79 -0
  79. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Flow Control/analysis.awk +27 -0
  80. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Flow Control/flow.tcl +163 -0
  81. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/TCP Flow Control/output.png +0 -0
  82. noshot/data/AIDS CN NLP/CN/6. TCP Flow And Congestion Control/procedure.png +0 -0
  83. noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/DV.tcl +111 -0
  84. noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/LS.tcl +106 -0
  85. noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/analysis.awk +36 -0
  86. noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/output.png +0 -0
  87. noshot/data/AIDS CN NLP/CN/7. Link State And Distance Vector Routing/procedure.png +0 -0
  88. noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/analysis.awk +20 -0
  89. noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/broadcast.tcl +76 -0
  90. noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/multicast.tcl +103 -0
  91. noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/output.png +0 -0
  92. noshot/data/AIDS CN NLP/CN/8. Multicast And Broadcast Routing/procedure.png +0 -0
  93. noshot/data/AIDS CN NLP/CN/9. DHCP/DHCP.java +125 -0
  94. noshot/data/AIDS CN NLP/CN/9. DHCP/output.png +0 -0
  95. noshot/data/AIDS CN NLP/CN/9. DHCP/procedure.png +0 -0
  96. noshot/data/AIDS CN NLP/NLP/NLP 1/1-Prereqs.py +18 -0
  97. noshot/data/AIDS CN NLP/NLP/NLP 1/2-Chi2test.py +83 -0
  98. noshot/data/AIDS CN NLP/NLP/NLP 1/2-T-test.py +79 -0
  99. noshot/data/AIDS CN NLP/NLP/NLP 1/3-WSD-nb.py +53 -0
  100. noshot/data/AIDS CN NLP/NLP/NLP 1/4-Hindle-Rooth.py +53 -0
  101. noshot/data/AIDS CN NLP/NLP/NLP 1/5-HMM-Trellis.py +82 -0
  102. noshot/data/AIDS CN NLP/NLP/NLP 1/6-HMM-Viterbi.py +16 -0
  103. noshot/data/AIDS CN NLP/NLP/NLP 1/7-PCFG-parsetree.py +15 -0
  104. noshot/data/AIDS CN NLP/NLP/NLP 1/Chi2test.ipynb +285 -0
  105. noshot/data/AIDS CN NLP/NLP/NLP 1/Hindle-Rooth.ipynb +179 -0
  106. noshot/data/AIDS CN NLP/NLP/NLP 1/Lab 10 - Text generator using LSTM.ipynb +1461 -0
  107. noshot/data/AIDS CN NLP/NLP/NLP 1/Lab 11 NMT.ipynb +2307 -0
  108. noshot/data/AIDS CN NLP/NLP/NLP 1/PCFG.ipynb +134 -0
  109. noshot/data/AIDS CN NLP/NLP/NLP 1/Prereqs.ipynb +131 -0
  110. noshot/data/AIDS CN NLP/NLP/NLP 1/T test.ipynb +252 -0
  111. noshot/data/AIDS CN NLP/NLP/NLP 1/TFIDF BOW.ipynb +171 -0
  112. noshot/data/AIDS CN NLP/NLP/NLP 1/Trellis.ipynb +244 -0
  113. noshot/data/AIDS CN NLP/NLP/NLP 1/WSD.ipynb +645 -0
  114. noshot/data/AIDS CN NLP/NLP/NLP 1/Word2Vec.ipynb +93 -0
  115. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab01(tokenizer)/tokenizer.ipynb +370 -0
  116. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab01(tokenizer)/training_tokenizer.txt +6 -0
  117. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab02(stemming)/exp0.ipynb +274 -0
  118. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab02(stemming)/lab2.ipynb +905 -0
  119. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab02(stemming)/test.txt +1 -0
  120. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab02(stemming)/tokenizing.ipynb +272 -0
  121. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab03(parse-tree)/collocation.ipynb +332 -0
  122. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab03(parse-tree)/lab3.ipynb +549 -0
  123. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab03(parse-tree)/nlp.txt +1 -0
  124. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab04(collocation)/Lab4-NLP-Exp-2.ipynb +817 -0
  125. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab04(collocation)/collocation.ipynb +332 -0
  126. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab05(WSD)/NLP-Lab-5-Exp3.ipynb +231 -0
  127. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab05(WSD)/word-sense-disambiguation.ipynb +507 -0
  128. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab06(additional-exercise)/lab6.ipynb +134 -0
  129. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab07(HMM,Viterbi)/NLP Exp 4.ipynb +255 -0
  130. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab07(HMM,Viterbi)/NLP_Exp_5.ipynb +159 -0
  131. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab08(PCFG)/PCFG.ipynb +282 -0
  132. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab09-Hindle-rooth&MLP/Lab 9 - MLP classifier.ipynb +670 -0
  133. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab09-Hindle-rooth&MLP/MLP-alternative-code.ipynb +613 -0
  134. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab09-Hindle-rooth&MLP/hindle-rooth-algorithm.ipynb +74 -0
  135. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab10(LSTM)/Lab_10_Text_generator_using_LSTM.ipynb +480 -0
  136. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/Machine-translation.ipynb +445 -0
  137. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/Viterbi-PCFG.ipynb +105 -0
  138. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/corpora_tools.py +87 -0
  139. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/data_utils.py +11 -0
  140. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab11(Viterbi-PCFG,Machine-translation)/train_translator.py +83 -0
  141. noshot/data/AIDS CN NLP/NLP/NLP 2/Lab12(Information-Extraction)/Information_Extraction.ipynb +201 -0
  142. noshot/data/AIDS CN NLP/NLP/NLP 3/Backtrack-without-Verbitri.ipynb +185 -0
  143. noshot/data/AIDS CN NLP/NLP/NLP 3/Backward-Procedure.ipynb +597 -0
  144. noshot/data/AIDS CN NLP/NLP/NLP 3/Bag_of.ipynb +1422 -0
  145. noshot/data/AIDS CN NLP/NLP/NLP 3/CYK-algorithm.ipynb +1067 -0
  146. noshot/data/AIDS CN NLP/NLP/NLP 3/Forward-Procedure.ipynb +477 -0
  147. noshot/data/AIDS CN NLP/NLP/NLP 3/LSTM.ipynb +1290 -0
  148. noshot/data/AIDS CN NLP/NLP/NLP 3/Lab 10 - Text generator using LSTM.ipynb +1461 -0
  149. noshot/data/AIDS CN NLP/NLP/NLP 3/Lab 11 NMT.ipynb +2307 -0
  150. noshot/data/AIDS CN NLP/NLP/NLP 3/NLP-LAB-4.ipynb +216 -0
  151. noshot/data/AIDS CN NLP/NLP/NLP 3/NLP-LAB-5.ipynb +216 -0
  152. noshot/data/AIDS CN NLP/NLP/NLP 3/abc.txt +6 -0
  153. noshot/data/AIDS CN NLP/NLP/NLP 3/ex-1-nltk.ipynb +711 -0
  154. noshot/data/AIDS CN NLP/NLP/NLP 3/ex-2-nlp.ipynb +267 -0
  155. noshot/data/AIDS CN NLP/NLP/NLP 3/exp8&9.ipynb +305 -0
  156. noshot/data/AIDS CN NLP/NLP/NLP 3/hind.ipynb +287 -0
  157. noshot/data/AIDS CN NLP/NLP/NLP 3/lab66.ipynb +752 -0
  158. noshot/data/AIDS CN NLP/NLP/NLP 3/leb_3.ipynb +612 -0
  159. noshot/data/AIDS CN NLP/NLP/NLP 3/naive_bayes_classifier.pkl +0 -0
  160. noshot/data/AIDS CN NLP/NLP/NLP 3/nlp_leb_1.ipynb +3008 -0
  161. noshot/data/AIDS CN NLP/NLP/NLP 3/nlp_leb_2.ipynb +3095 -0
  162. noshot/data/AIDS CN NLP/NLP/NLP 3/nlplab-9.ipynb +295 -0
  163. noshot/data/AIDS CN NLP/NLP/NLP 3/nltk-ex-4.ipynb +506 -0
  164. noshot/data/AIDS CN NLP/NLP/NLP 3/text1.txt +48 -0
  165. noshot/data/AIDS CN NLP/NLP/NLP 3/text2.txt +8 -0
  166. noshot/data/AIDS CN NLP/NLP/NLP 3/text3.txt +48 -0
  167. noshot/data/AIDS CN NLP/NLP/NLP 3/translation-rnn.ipynb +812 -0
  168. noshot/data/AIDS CN NLP/NLP/NLP 3/word2vector.ipynb +173 -0
  169. noshot/data/AIDS CN NLP/NLP/NLP 4/Backward Procedure Algorithm.ipynb +179 -0
  170. noshot/data/AIDS CN NLP/NLP/NLP 4/Chi Square Collocation.ipynb +208 -0
  171. noshot/data/AIDS CN NLP/NLP/NLP 4/Collocation (T test).ipynb +188 -0
  172. noshot/data/AIDS CN NLP/NLP/NLP 4/Experiment 1.ipynb +437 -0
  173. noshot/data/AIDS CN NLP/NLP/NLP 4/Forward Procedure Algorithm.ipynb +132 -0
  174. noshot/data/AIDS CN NLP/NLP/NLP 4/Hindle Rooth.ipynb +414 -0
  175. noshot/data/AIDS CN NLP/NLP/NLP 4/MachineTranslation.ipynb +368 -0
  176. noshot/data/AIDS CN NLP/NLP/NLP 4/Multi Layer Perceptron using MLPClassifier.ipynb +86 -0
  177. noshot/data/AIDS CN NLP/NLP/NLP 4/Multi Layer Perceptron using Tensorflow.ipynb +112 -0
  178. noshot/data/AIDS CN NLP/NLP/NLP 4/PCFG Inside Probability.ipynb +451 -0
  179. noshot/data/AIDS CN NLP/NLP/NLP 4/Text Generation using LSTM.ipynb +297 -0
  180. noshot/data/AIDS CN NLP/NLP/NLP 4/Viterbi.ipynb +310 -0
  181. noshot/data/AIDS CN NLP/NLP/NLP 4/Word Sense Disambiguation.ipynb +335 -0
  182. noshot/data/AIDS CN NLP/NLP/NLP 5/10.Text Generation using LSTM.ipynb +316 -0
  183. noshot/data/AIDS CN NLP/NLP/NLP 5/11.Machine Translation.ipynb +868 -0
  184. noshot/data/AIDS CN NLP/NLP/NLP 5/2.T and Chi2 Test.ipynb +204 -0
  185. noshot/data/AIDS CN NLP/NLP/NLP 5/3.Word Sense Diambiguation.ipynb +234 -0
  186. noshot/data/AIDS CN NLP/NLP/NLP 5/4.Hinddle and Rooth.ipynb +128 -0
  187. noshot/data/AIDS CN NLP/NLP/NLP 5/5.Forward and Backward.ipynb +149 -0
  188. noshot/data/AIDS CN NLP/NLP/NLP 5/6.Viterbi.ipynb +111 -0
  189. noshot/data/AIDS CN NLP/NLP/NLP 5/7.PCFG Parse Tree.ipynb +134 -0
  190. noshot/data/AIDS CN NLP/NLP/NLP 5/7.PCFG using cyk.ipynb +101 -0
  191. noshot/data/AIDS CN NLP/NLP/NLP 5/8.Bag of words and TF-IDF.ipynb +310 -0
  192. noshot/data/AIDS CN NLP/NLP/NLP 5/9.Word2Vector.ipynb +78 -0
  193. noshot/data/AIDS CN NLP/NLP/NLP 5/NLP ALL In One.ipynb +2619 -0
  194. noshot/data/AIDS CN NLP/NLP/NLP 5/sample1.txt +15 -0
  195. noshot/data/AIDS CN NLP/NLP/NLP 5/sample2.txt +4 -0
  196. noshot/data/AIDS CN NLP/NLP/NLP 5/word2vec_model.bin +0 -0
  197. noshot/data/AIDS CN NLP/NLP/NLP 6/1. Tokenize, Tagging, NER, Parse Tree.ipynb +312 -0
  198. noshot/data/AIDS CN NLP/NLP/NLP 6/2. T Test and Chi2 Test.ipynb +185 -0
  199. noshot/data/AIDS CN NLP/NLP/NLP 6/3. Naive Bayes WSD.ipynb +199 -0
  200. noshot/data/AIDS CN NLP/NLP/NLP 6/4. Hinddle and Rooth.ipynb +151 -0
  201. noshot/data/AIDS CN NLP/NLP/NLP 6/5 and 6 FWD, BWD, Viterbi.ipynb +164 -0
  202. noshot/data/AIDS CN NLP/NLP/NLP 6/7. PCFG using CYK.ipynb +383 -0
  203. noshot/data/AIDS CN NLP/NLP/NLP 6/8. BOW and TF-IDF.ipynb +252 -0
  204. noshot/data/AIDS CN NLP/Ubuntu CN Lab.iso +0 -0
  205. noshot/main.py +47 -0
  206. noshot-0.1.0.dist-info/LICENSE.txt +21 -0
  207. noshot-0.1.0.dist-info/METADATA +65 -0
  208. noshot-0.1.0.dist-info/RECORD +210 -0
  209. noshot-0.1.0.dist-info/WHEEL +5 -0
  210. noshot-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,134 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "LHS `->` RHS \n",
8
+ "Element1 `|` Element2 `|` Element3 \n",
9
+ "`NP PP [0.4]` -- non-terminal symbol \n",
10
+ "`'he' [0.6]` -- terminal symbol "
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 1,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "grammarstring = \"\"\"\n",
20
+ "S -> NP VP [1.0]\n",
21
+ "NP -> NP PP [0.4] | 'he' [0.1] | 'dessert' [0.3] | 'lunch' [0.1] | 'saw' [0.1]\n",
22
+ "PP -> Pre NP [1.0]\n",
23
+ "VP -> Verb NP [0.3] | VP PP [0.7]\n",
24
+ "Pre -> 'with' [0.6] | 'in' [0.4]\n",
25
+ "Verb -> 'ate' [0.7] | 'saw' [0.3]\n",
26
+ "\"\"\""
27
+ ]
28
+ },
29
+ {
30
+ "cell_type": "code",
31
+ "execution_count": 2,
32
+ "metadata": {},
33
+ "outputs": [],
34
+ "source": [
35
+ "from nltk import PCFG, InsideChartParser \n",
36
+ "# Remember InsideChartParser\n",
37
+ "\n",
38
+ "grammar = PCFG.fromstring(grammarstring)\n",
39
+ "\n",
40
+ "parser = InsideChartParser(grammar=grammar)"
41
+ ]
42
+ },
43
+ {
44
+ "cell_type": "code",
45
+ "execution_count": 3,
46
+ "metadata": {},
47
+ "outputs": [
48
+ {
49
+ "data": {
50
+ "text/plain": [
51
+ "['he', 'saw', 'lunch', 'with', 'dessert']"
52
+ ]
53
+ },
54
+ "execution_count": 3,
55
+ "metadata": {},
56
+ "output_type": "execute_result"
57
+ }
58
+ ],
59
+ "source": [
60
+ "from nltk.tokenize import word_tokenize\n",
61
+ "\n",
62
+ "sentence = \"he saw lunch with dessert\"\n",
63
+ "\n",
64
+ "tokens = word_tokenize(sentence)\n",
65
+ "tokens"
66
+ ]
67
+ },
68
+ {
69
+ "cell_type": "code",
70
+ "execution_count": 4,
71
+ "metadata": {},
72
+ "outputs": [
73
+ {
74
+ "name": "stdout",
75
+ "output_type": "stream",
76
+ "text": [
77
+ " S \n",
78
+ " _____________|____ \n",
79
+ " | VP \n",
80
+ " | _________|________ \n",
81
+ " | VP PP \n",
82
+ " | ____|____ ____|_____ \n",
83
+ " NP Verb NP Pre NP \n",
84
+ " | | | | | \n",
85
+ " he saw lunch with dessert\n",
86
+ "\n",
87
+ "Prob: 0.00011339999999999999\n",
88
+ " S \n",
89
+ " _________|____ \n",
90
+ " | VP \n",
91
+ " | __________|___ \n",
92
+ " | | NP \n",
93
+ " | | ________|____ \n",
94
+ " | | | PP \n",
95
+ " | | | ____|_____ \n",
96
+ " NP Verb NP Pre NP \n",
97
+ " | | | | | \n",
98
+ " he saw lunch with dessert\n",
99
+ "\n",
100
+ "Prob: 6.480000000000002e-05\n"
101
+ ]
102
+ }
103
+ ],
104
+ "source": [
105
+ "trees = parser.parse(tokens)\n",
106
+ "\n",
107
+ "for tree in trees:\n",
108
+ " tree.pretty_print() # Remember this\n",
109
+ " print(\"Prob: \", tree.prob())# .prob"
110
+ ]
111
+ }
112
+ ],
113
+ "metadata": {
114
+ "kernelspec": {
115
+ "display_name": "Python 3",
116
+ "language": "python",
117
+ "name": "python3"
118
+ },
119
+ "language_info": {
120
+ "codemirror_mode": {
121
+ "name": "ipython",
122
+ "version": 3
123
+ },
124
+ "file_extension": ".py",
125
+ "mimetype": "text/x-python",
126
+ "name": "python",
127
+ "nbconvert_exporter": "python",
128
+ "pygments_lexer": "ipython3",
129
+ "version": "3.12.7"
130
+ }
131
+ },
132
+ "nbformat": 4,
133
+ "nbformat_minor": 2
134
+ }
@@ -0,0 +1,131 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 54,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "from nltk.tokenize import word_tokenize\n",
10
+ "from nltk.corpus import stopwords\n",
11
+ "from nltk.util import bigrams\n",
12
+ "import string"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": 31,
18
+ "metadata": {},
19
+ "outputs": [],
20
+ "source": [
21
+ "sentences = [\n",
22
+ " \"I love studying data science.\",\n",
23
+ " \"Data science is an interesting field.\",\n",
24
+ " \"Science requires data for analysis.\",\n",
25
+ " \"Data is key in modern science.\",\n",
26
+ " \"Data science helps in business decision-making.\"\n",
27
+ "]"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 32,
33
+ "metadata": {},
34
+ "outputs": [],
35
+ "source": [
36
+ "def process(line):\n",
37
+ " line = line.lower()\n",
38
+ " tokens = word_tokenize(line)\n",
39
+ "\n",
40
+ " # stopwords\n",
41
+ " stops = set(stopwords.words('english'))\n",
42
+ " tokens = [i for i in tokens if i not in stops and i not in string.punctuation]\n",
43
+ " return tokens"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": 36,
49
+ "metadata": {},
50
+ "outputs": [
51
+ {
52
+ "data": {
53
+ "text/plain": [
54
+ "[['love', 'studying', 'data', 'science'],\n",
55
+ " ['data', 'science', 'interesting', 'field'],\n",
56
+ " ['science', 'requires', 'data', 'analysis'],\n",
57
+ " ['data', 'key', 'modern', 'science'],\n",
58
+ " ['data', 'science', 'helps', 'business', 'decision-making']]"
59
+ ]
60
+ },
61
+ "execution_count": 36,
62
+ "metadata": {},
63
+ "output_type": "execute_result"
64
+ }
65
+ ],
66
+ "source": [
67
+ "tokens = [process(i) for i in sentences]\n",
68
+ "tokens"
69
+ ]
70
+ },
71
+ {
72
+ "cell_type": "code",
73
+ "execution_count": 55,
74
+ "metadata": {},
75
+ "outputs": [],
76
+ "source": [
77
+ "def bgrm(l):\n",
78
+ " return bigrams(l)"
79
+ ]
80
+ },
81
+ {
82
+ "cell_type": "code",
83
+ "execution_count": 59,
84
+ "metadata": {},
85
+ "outputs": [
86
+ {
87
+ "data": {
88
+ "text/plain": [
89
+ "[('love', 'studying'), ('studying', 'data'), ('data', 'science')]"
90
+ ]
91
+ },
92
+ "execution_count": 59,
93
+ "metadata": {},
94
+ "output_type": "execute_result"
95
+ }
96
+ ],
97
+ "source": [
98
+ "bigrams_all = list(bgrm(tokens[0]))\n",
99
+ "bigrams_all"
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "execution_count": null,
105
+ "metadata": {},
106
+ "outputs": [],
107
+ "source": []
108
+ }
109
+ ],
110
+ "metadata": {
111
+ "kernelspec": {
112
+ "display_name": "Python 3",
113
+ "language": "python",
114
+ "name": "python3"
115
+ },
116
+ "language_info": {
117
+ "codemirror_mode": {
118
+ "name": "ipython",
119
+ "version": 3
120
+ },
121
+ "file_extension": ".py",
122
+ "mimetype": "text/x-python",
123
+ "name": "python",
124
+ "nbconvert_exporter": "python",
125
+ "pygments_lexer": "ipython3",
126
+ "version": "3.12.7"
127
+ }
128
+ },
129
+ "nbformat": 4,
130
+ "nbformat_minor": 2
131
+ }
@@ -0,0 +1,252 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "1. List out the sentences from the dataframe"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": 1,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "import pandas as pd\n",
17
+ "import numpy as np\n",
18
+ "from nltk.util import bigrams\n",
19
+ "from nltk.corpus import stopwords \n",
20
+ "from nltk.tokenize import word_tokenize\n",
21
+ "import string\n",
22
+ "from collections import defaultdict"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": 2,
28
+ "metadata": {},
29
+ "outputs": [
30
+ {
31
+ "data": {
32
+ "text/html": [
33
+ "<div>\n",
34
+ "<style scoped>\n",
35
+ " .dataframe tbody tr th:only-of-type {\n",
36
+ " vertical-align: middle;\n",
37
+ " }\n",
38
+ "\n",
39
+ " .dataframe tbody tr th {\n",
40
+ " vertical-align: top;\n",
41
+ " }\n",
42
+ "\n",
43
+ " .dataframe thead th {\n",
44
+ " text-align: right;\n",
45
+ " }\n",
46
+ "</style>\n",
47
+ "<table border=\"1\" class=\"dataframe\">\n",
48
+ " <thead>\n",
49
+ " <tr style=\"text-align: right;\">\n",
50
+ " <th></th>\n",
51
+ " <th>Sastra University is located in Tamil Nadu.</th>\n",
52
+ " </tr>\n",
53
+ " </thead>\n",
54
+ " <tbody>\n",
55
+ " <tr>\n",
56
+ " <th>0</th>\n",
57
+ " <td>Students at Sastra University engage in rigoro...</td>\n",
58
+ " </tr>\n",
59
+ " <tr>\n",
60
+ " <th>1</th>\n",
61
+ " <td>The university's main campus, Sastra Tanjore, ...</td>\n",
62
+ " </tr>\n",
63
+ " <tr>\n",
64
+ " <th>2</th>\n",
65
+ " <td>Sastra University offers undergraduate and pos...</td>\n",
66
+ " </tr>\n",
67
+ " <tr>\n",
68
+ " <th>3</th>\n",
69
+ " <td>Sastra University's commitment to quality educ...</td>\n",
70
+ " </tr>\n",
71
+ " <tr>\n",
72
+ " <th>4</th>\n",
73
+ " <td>The university's reputation for excellence ext...</td>\n",
74
+ " </tr>\n",
75
+ " </tbody>\n",
76
+ "</table>\n",
77
+ "</div>"
78
+ ],
79
+ "text/plain": [
80
+ " Sastra University is located in Tamil Nadu.\n",
81
+ "0 Students at Sastra University engage in rigoro...\n",
82
+ "1 The university's main campus, Sastra Tanjore, ...\n",
83
+ "2 Sastra University offers undergraduate and pos...\n",
84
+ "3 Sastra University's commitment to quality educ...\n",
85
+ "4 The university's reputation for excellence ext..."
86
+ ]
87
+ },
88
+ "execution_count": 2,
89
+ "metadata": {},
90
+ "output_type": "execute_result"
91
+ }
92
+ ],
93
+ "source": [
94
+ "df = pd.read_csv(\"../sastralines.csv\")\n",
95
+ "df.head()"
96
+ ]
97
+ },
98
+ {
99
+ "cell_type": "code",
100
+ "execution_count": 3,
101
+ "metadata": {},
102
+ "outputs": [
103
+ {
104
+ "data": {
105
+ "text/plain": [
106
+ "['Students at Sastra University engage in rigorous academic pursuits.',\n",
107
+ " \"The university's main campus, Sastra Tanjore, is known for its scenic beauty.\",\n",
108
+ " 'Sastra University offers undergraduate and postgraduate programs in diverse disciplines.',\n",
109
+ " \"Sastra University's commitment to quality education is evident in its faculty.\",\n",
110
+ " \"The university's reputation for excellence extends beyond national borders.\"]"
111
+ ]
112
+ },
113
+ "execution_count": 3,
114
+ "metadata": {},
115
+ "output_type": "execute_result"
116
+ }
117
+ ],
118
+ "source": [
119
+ "lines = df.iloc[:,0].tolist() #pandas series\n",
120
+ "lines[:5]\n"
121
+ ]
122
+ },
123
+ {
124
+ "cell_type": "code",
125
+ "execution_count": 4,
126
+ "metadata": {},
127
+ "outputs": [],
128
+ "source": [
129
+ "unigramD = defaultdict(int)\n",
130
+ "bigramD = defaultdict(int)\n",
131
+ "\n",
132
+ "N = 0 # Wordcount\n",
133
+ "for line in lines:\n",
134
+ " \n",
135
+ " tokens = [i for i in word_tokenize(line.lower()) if i not in set(stopwords.words(\"english\")) and i not in string.punctuation]\n",
136
+ " \n",
137
+ " for j in tokens:\n",
138
+ " unigramD[j] += 1\n",
139
+ " N+= 1\n",
140
+ " for j in list(bigrams(tokens)):\n",
141
+ " bigramD[j] += 1\n"
142
+ ]
143
+ },
144
+ {
145
+ "cell_type": "code",
146
+ "execution_count": null,
147
+ "metadata": {},
148
+ "outputs": [],
149
+ "source": []
150
+ },
151
+ {
152
+ "cell_type": "markdown",
153
+ "metadata": {},
154
+ "source": [
155
+ "4. Input words, critical value"
156
+ ]
157
+ },
158
+ {
159
+ "cell_type": "code",
160
+ "execution_count": 5,
161
+ "metadata": {},
162
+ "outputs": [],
163
+ "source": [
164
+ "w1 = \"sastra\"\n",
165
+ "w2 = \"university\"\n",
166
+ "c = 2.0"
167
+ ]
168
+ },
169
+ {
170
+ "cell_type": "markdown",
171
+ "metadata": {},
172
+ "source": [
173
+ "5. O,E"
174
+ ]
175
+ },
176
+ {
177
+ "cell_type": "code",
178
+ "execution_count": 6,
179
+ "metadata": {},
180
+ "outputs": [],
181
+ "source": [
182
+ "import math"
183
+ ]
184
+ },
185
+ {
186
+ "cell_type": "code",
187
+ "execution_count": 7,
188
+ "metadata": {},
189
+ "outputs": [
190
+ {
191
+ "data": {
192
+ "text/plain": [
193
+ "(0.08401084010840108, 0.011875647211756669, 12.715450067040848)"
194
+ ]
195
+ },
196
+ "execution_count": 7,
197
+ "metadata": {},
198
+ "output_type": "execute_result"
199
+ }
200
+ ],
201
+ "source": [
202
+ "O = bigramD[(w1,w2)]/N \n",
203
+ "E = unigramD[(w1)]/N * unigramD[(w2)]/N \n",
204
+ "variance = E\n",
205
+ "\n",
206
+ "score = (O-E)/math.sqrt(variance/N)\n",
207
+ "O,E,score"
208
+ ]
209
+ },
210
+ {
211
+ "cell_type": "code",
212
+ "execution_count": 8,
213
+ "metadata": {},
214
+ "outputs": [
215
+ {
216
+ "name": "stdout",
217
+ "output_type": "stream",
218
+ "text": [
219
+ "Reject Ho\n"
220
+ ]
221
+ }
222
+ ],
223
+ "source": [
224
+ "if score > c:\n",
225
+ " print(\"Reject Ho\")\n",
226
+ "else:\n",
227
+ " print(\"Accept Ho\")"
228
+ ]
229
+ }
230
+ ],
231
+ "metadata": {
232
+ "kernelspec": {
233
+ "display_name": "Python 3",
234
+ "language": "python",
235
+ "name": "python3"
236
+ },
237
+ "language_info": {
238
+ "codemirror_mode": {
239
+ "name": "ipython",
240
+ "version": 3
241
+ },
242
+ "file_extension": ".py",
243
+ "mimetype": "text/x-python",
244
+ "name": "python",
245
+ "nbconvert_exporter": "python",
246
+ "pygments_lexer": "ipython3",
247
+ "version": "3.12.7"
248
+ }
249
+ },
250
+ "nbformat": 4,
251
+ "nbformat_minor": 2
252
+ }
@@ -0,0 +1,171 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {
7
+ "colab": {
8
+ "base_uri": "https://localhost:8080/"
9
+ },
10
+ "id": "n1DJ41rw1B0J",
11
+ "outputId": "ba654967-ee56-4040-e68f-4a54e3bb8dbb"
12
+ },
13
+ "outputs": [
14
+ {
15
+ "name": "stdout",
16
+ "output_type": "stream",
17
+ "text": [
18
+ "Training with Bag of Words (BoW)...\n"
19
+ ]
20
+ },
21
+ {
22
+ "name": "stderr",
23
+ "output_type": "stream",
24
+ "text": [
25
+ "/usr/local/lib/python3.10/dist-packages/keras/src/layers/core/dense.py:87: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.\n",
26
+ " super().__init__(activity_regularizer=activity_regularizer, **kwargs)\n"
27
+ ]
28
+ },
29
+ {
30
+ "name": "stdout",
31
+ "output_type": "stream",
32
+ "text": [
33
+ "Epoch 1/10\n",
34
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m3s\u001b[0m 16ms/step - accuracy: 0.6667 - loss: 0.6975\n",
35
+ "Epoch 2/10\n",
36
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 10ms/step - accuracy: 0.8333 - loss: 0.6899\n",
37
+ "Epoch 3/10\n",
38
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.8333 - loss: 0.6867 \n",
39
+ "Epoch 4/10\n",
40
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 9ms/step - accuracy: 0.6667 - loss: 0.7099 \n",
41
+ "Epoch 5/10\n",
42
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.6667 - loss: 0.7057 \n",
43
+ "Epoch 6/10\n",
44
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.6667 - loss: 0.6741 \n",
45
+ "Epoch 7/10\n",
46
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.6667 - loss: 0.6983 \n",
47
+ "Epoch 8/10\n",
48
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 6ms/step - accuracy: 0.6667 - loss: 0.6652 \n",
49
+ "Epoch 9/10\n",
50
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 8ms/step - accuracy: 0.8333 - loss: 0.6382 \n",
51
+ "Epoch 10/10\n",
52
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.8333 - loss: 0.6347 \n",
53
+ "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 292ms/step - accuracy: 1.0000 - loss: 0.6350\n",
54
+ "BoW Model Accuracy: 1.00\n",
55
+ "Training with TF-IDF...\n",
56
+ "Epoch 1/10\n",
57
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 8ms/step - accuracy: 0.3333 - loss: 0.7130\n",
58
+ "Epoch 2/10\n",
59
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.3333 - loss: 0.7099 \n",
60
+ "Epoch 3/10\n",
61
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.3333 - loss: 0.7071 \n",
62
+ "Epoch 4/10\n",
63
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.1667 - loss: 0.7102 \n",
64
+ "Epoch 5/10\n",
65
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 6ms/step - accuracy: 0.3333 - loss: 0.7016 \n",
66
+ "Epoch 6/10\n",
67
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.3333 - loss: 0.7002 \n",
68
+ "Epoch 7/10\n",
69
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.5000 - loss: 0.6964 \n",
70
+ "Epoch 8/10\n",
71
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 6ms/step - accuracy: 0.6667 - loss: 0.6923 \n",
72
+ "Epoch 9/10\n",
73
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 7ms/step - accuracy: 0.6667 - loss: 0.6900 \n",
74
+ "Epoch 10/10\n",
75
+ "\u001b[1m2/2\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 6ms/step - accuracy: 0.6667 - loss: 0.6914 \n",
76
+ "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 283ms/step - accuracy: 0.0000e+00 - loss: 0.7002\n",
77
+ "TF-IDF Model Accuracy: 0.00\n"
78
+ ]
79
+ }
80
+ ],
81
+ "source": [
82
+ "#Text Classification using Bag of Words and TF-IDF with TensorFlow.\n",
83
+ "\n",
84
+ "import numpy as np\n",
85
+ "import pandas as pd\n",
86
+ "from sklearn.model_selection import train_test_split\n",
87
+ "from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer\n",
88
+ "from sklearn.preprocessing import LabelEncoder\n",
89
+ "import tensorflow as tf\n",
90
+ "from tensorflow.keras import Sequential\n",
91
+ "from tensorflow.keras.layers import Dense\n",
92
+ "\n",
93
+ "data = {'text': ['I love programming', 'Python is great', 'I enjoy machine learning',\n",
94
+ " 'TensorFlow is a powerful tool', 'AI is the future'],\n",
95
+ " 'label': ['positive', 'positive', 'positive', 'positive', 'neutral']}\n",
96
+ "\n",
97
+ "df = pd.DataFrame(data)\n",
98
+ "label_encoder = LabelEncoder()\n",
99
+ "df['label'] = label_encoder.fit_transform(df['label'])\n",
100
+ "X_train, X_test, y_train, y_test = train_test_split(df['text'], df['label'], test_size=0.2, random_state=42)\n",
101
+ "\n",
102
+ "# Option 1: Bag of Words (BoW)\n",
103
+ "vectorizer_bow = CountVectorizer()\n",
104
+ "X_train_bow = vectorizer_bow.fit_transform(X_train).toarray()\n",
105
+ "X_test_bow = vectorizer_bow.transform(X_test).toarray()\n",
106
+ "\n",
107
+ "# Option 2: TF-IDF\n",
108
+ "vectorizer_tfidf = TfidfVectorizer()\n",
109
+ "X_train_tfidf = vectorizer_tfidf.fit_transform(X_train).toarray()\n",
110
+ "X_test_tfidf = vectorizer_tfidf.transform(X_test).toarray()\n",
111
+ "\n",
112
+ "# Build a simple neural network with TensorFlow\n",
113
+ "def build_model(input_dim):\n",
114
+ " model = Sequential()\n",
115
+ " model.add(Dense(16, activation='relu', input_dim=input_dim))\n",
116
+ " model.add(Dense(8, activation='relu'))\n",
117
+ " model.add(Dense(1, activation='sigmoid')) # Binary classification (positive or neutral)\n",
118
+ " model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])\n",
119
+ " return model\n",
120
+ "\n",
121
+ "\n",
122
+ "print(\"Training with Bag of Words (BoW)...\")\n",
123
+ "model_bow = build_model(X_train_bow.shape[1])\n",
124
+ "model_bow.fit(X_train_bow, y_train, epochs=10, batch_size=2, verbose=1)\n",
125
+ "\n",
126
+ "loss, accuracy = model_bow.evaluate(X_test_bow, y_test)\n",
127
+ "print(f'BoW Model Accuracy: {accuracy:.2f}')\n",
128
+ "\n",
129
+ "print(\"Training with TF-IDF...\")\n",
130
+ "model_tfidf = build_model(X_train_tfidf.shape[1])\n",
131
+ "model_tfidf.fit(X_train_tfidf, y_train, epochs=10, batch_size=2, verbose=1)\n",
132
+ "\n",
133
+ "\n",
134
+ "loss, accuracy = model_tfidf.evaluate(X_test_tfidf, y_test)\n",
135
+ "print(f'TF-IDF Model Accuracy: {accuracy:.2f}')\n"
136
+ ]
137
+ },
138
+ {
139
+ "cell_type": "markdown",
140
+ "metadata": {
141
+ "id": "0aZKJeRc2JQz"
142
+ },
143
+ "source": []
144
+ },
145
+ {
146
+ "cell_type": "code",
147
+ "execution_count": null,
148
+ "metadata": {
149
+ "id": "ZjkrZu5411-K"
150
+ },
151
+ "outputs": [],
152
+ "source": []
153
+ }
154
+ ],
155
+ "metadata": {
156
+ "accelerator": "GPU",
157
+ "colab": {
158
+ "gpuType": "T4",
159
+ "provenance": []
160
+ },
161
+ "kernelspec": {
162
+ "display_name": "Python 3",
163
+ "name": "python3"
164
+ },
165
+ "language_info": {
166
+ "name": "python"
167
+ }
168
+ },
169
+ "nbformat": 4,
170
+ "nbformat_minor": 0
171
+ }