├── Alphabet GAN ├── bangla-gan.gif ├── eng-gan.gif ├── english-alphabet-gan.ipynb └── readme.md ├── Created with MANIM ├── README.md └── bayesian_classifiers_explained.py ├── Introduction to NLP ├── Bag of Words + TF-IDF.ipynb ├── Bag of Words.ipynb ├── GloVe.ipynb ├── How to train custom word vectors.ipynb ├── How to use pre-trained word vectors (GloVe+Word2Vec).ipynb ├── Sarcasm is very easy to detect GloVe+LSTM.ipynb ├── Summarization & Keyword Extraction.ipynb ├── Text Cleaning + Preprocessing.ipynb ├── Word2Vec.ipynb ├── amazon_cells_labelled.txt ├── cleaned_hm.csv ├── hound.txt ├── imdb_labelled.txt ├── readme.md └── yelp_labelled.txt ├── Miscellaneous ├── 0.png ├── Markov_Chain_Simulation.ipynb ├── Text_Generation_Tutorial.ipynb ├── mat2.png └── monte_carlo.py ├── Pandas Tricks └── 11_pandas_tricks.ipynb ├── Python Tutorials └── Multiprocessing │ ├── downloader.py │ ├── multi.py │ └── prime.py ├── README.md ├── Scikit-Learn-Videos └── GridSearchCV │ ├── GridSearchCV.ipynb │ └── concrete_data.csv └── Sklearn-Evaluation Metrics ├── 1.png ├── 2.png ├── 3.png ├── 4.jpg ├── 5.png └── Evaluation Metrics.ipynb /Alphabet GAN/bangla-gan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Alphabet GAN/bangla-gan.gif -------------------------------------------------------------------------------- /Alphabet GAN/eng-gan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Alphabet GAN/eng-gan.gif -------------------------------------------------------------------------------- /Alphabet GAN/readme.md: -------------------------------------------------------------------------------- 1 | # AlphabetGAN 2 | I tied to generate English and Bengali alphabets with generative adversarial networks. 3 | 4 | ## Evolution of generated Bengali alphabets 5 | ![bengali alphabets](https://github.com/Suji04/NormalizedNerd/blob/master/Alphabet%20GAN/bangla-gan.gif) 6 | ## Evolution of generated English alphabets 7 | ![english alphabets](https://github.com/Suji04/NormalizedNerd/blob/master/Alphabet%20GAN/eng-gan.gif) 8 | 9 | ## Video 10 | [![video](https://i.ytimg.com/vi/RzcXri2eJrI/mqdefault.jpg)](https://youtu.be/RzcXri2eJrI) 11 | 12 | ## Data Source 13 | https://www.kaggle.com/sachinpatel21/az-handwritten-alphabets-in-csv-format 14 | -------------------------------------------------------------------------------- /Created with MANIM/README.md: -------------------------------------------------------------------------------- 1 | # Source codes of the videos created with manim 2 | Here you'll find the source codes of the videos that I've created with an awesome library called manim. 3 | #### Caution: Messy codes ahead! 4 | 5 | ## Videos 6 | [![bayesian classifiers explained](https://i.ytimg.com/vi/lFJbZ6LVxN8/mqdefault.jpg)](https://youtu.be/lFJbZ6LVxN8) 7 | 8 | ## MANIM 9 | https://github.com/3b1b/manim 10 | -------------------------------------------------------------------------------- /Created with MANIM/bayesian_classifiers_explained.py: -------------------------------------------------------------------------------- 1 | from manimlib.imports import * 2 | 3 | class Scene1(Scene): 4 | def construct(self): 5 | 6 | line1 = TexMobject("\\text{features: }", "X = (X_1, X_2,...,X_n)") 7 | line2 = TexMobject("\\text{label: }", "Y") 8 | self.play(Write(line1)) 9 | self.wait() 10 | self.play(ApplyMethod(line1.shift,.5*UP)) 11 | line2.shift(.5*DOWN) 12 | self.play(Write(line2)) 13 | self.wait() 14 | gr=VGroup(line1,line2) 15 | self.play(FadeOut(gr)) 16 | self.wait() 17 | line3 = TexMobject("P(Y=y | X = (x_1, x_2,...,x_n))") 18 | self.play(Write(line3)) 19 | self.wait() 20 | line4 = TextMobject("for what value of ", "$y$") 21 | line4.shift(UP) 22 | line5 = TextMobject("is maximum") 23 | line5.shift(DOWN) 24 | self.play(Write(line4)) 25 | self.play(Write(line5)) 26 | self.wait() 27 | gr=VGroup(line3,line4,line5) 28 | self.play(FadeOut(gr)) 29 | line1 = TexMobject("\\text{but...}", "P(Y|X)", "\\text{ is hard to find!}") 30 | self.play(Write(line1)) 31 | self.wait() 32 | self.play(FadeOut(line1)) 33 | line1 = TexMobject("P(Y|X) = ", "{P(X|Y)", "P(Y)", "\\over", "P(X)}") 34 | line1[0].set_color(GREEN) 35 | line1[2].set_color(BLUE) 36 | line1[4].set_color(YELLOW) 37 | line1[1].set_color(RED) 38 | self.play(Write(line1)) 39 | ptr1 = CurvedArrow(5*LEFT+1*UP, 3*LEFT) 40 | txt1 = TextMobject("Posterior").set_color(GREEN) 41 | txt1.shift(5*LEFT+1.5*UP) 42 | ptr2 = CurvedArrow(2*UP+4*RIGHT, 2.5*RIGHT+.8*UP) 43 | txt2 = TextMobject("Prior").set_color(BLUE) 44 | txt2.shift(2*UP+5*RIGHT) 45 | ptr3 = CurvedArrow(3.5*RIGHT+2*DOWN, 1.5*RIGHT+.8*DOWN, angle=-PI/2) 46 | txt3 = TextMobject("Evidence").set_color(YELLOW) 47 | txt3.shift(5*RIGHT+2*DOWN) 48 | ptr4 = CurvedArrow(1*LEFT+2*UP, .25*LEFT+.6*UP) 49 | txt4 = TextMobject("Likelihood").set_color(RED) 50 | txt4.shift(1*LEFT+2.5*UP) 51 | self.play(Write(ptr1)) 52 | self.play(Write(txt1)) 53 | self.wait() 54 | self.play(Write(ptr2)) 55 | self.play(Write(txt2)) 56 | self.wait() 57 | self.play(Write(ptr3)) 58 | self.play(Write(txt3)) 59 | self.wait() 60 | self.play(Write(ptr4)) 61 | self.play(Write(txt4)) 62 | self.wait() 63 | self.play(ApplyMethod(line1[4].set_color, GREY)) 64 | self.wait() 65 | 66 | 67 | 68 | class Scene2(Scene): 69 | def construct(self): 70 | tabledict={ 71 | "X_1":['0', '0', '1', '0', '2', '1', '0', '2', '2', '1'], 72 | "X_2":['0', '1', '2', '0', '2', '1', '2' ,'0', '1', '0'], 73 | "Y ":['0', '1', '1', '1', '0', '0', '1', '0', '0', '0'], 74 | } 75 | 76 | table=Table.get_table(tabledict) 77 | table.move_to(ORIGIN) 78 | table.scale(.6) 79 | self.play(Write(table), run_time=3) 80 | self.wait() 81 | 82 | descx = TexMobject("X_1, X_2 \\in \\{0, 1, 2\\}") 83 | descy = TexMobject("Y \\in \\{0, 1\\}").next_to(descx, DOWN) 84 | 85 | gdesc = VGroup(descx, descy) 86 | gdesc.scale(.6) 87 | gdesc.shift(3.5*RIGHT) 88 | self.play(Write(gdesc)) 89 | self.wait() 90 | 91 | self.play(FadeOut(gdesc)) 92 | 93 | self.play(ApplyMethod(table.shift,5*RIGHT)) 94 | self.wait() 95 | 96 | prob = TexMobject("\\text{Estimate the value of }", "Y", "\\text{given that }", "X = (0, 2)") 97 | prob.scale(.7) 98 | prob.shift(3*LEFT) 99 | self.play(Write(prob)) 100 | self.wait() 101 | self.play(FadeOut(prob)) 102 | self.wait() 103 | 104 | line1 = TexMobject("\\text{Let's compute }", "P(Y=0|X=(0, 2))", "\\text{ and }", "P(Y=1|X=(0, 2))", "\\text{ ... }") 105 | line1.to_edge(UP, buff=.2) 106 | line1.shift(2.8*LEFT) 107 | line1.scale(.6) 108 | self.play(Write(line1)) 109 | self.wait() 110 | 111 | line2 = TexMobject("P(Y=0) = ", "{\#Y=0", "\\over", "\#Y=0", "+", "\#Y=1}") 112 | line2.next_to(line1, DOWN) 113 | line2.scale(.6) 114 | self.play(Write(line2)) 115 | self.wait() 116 | 117 | gr = VGroup(table[23],table[27],table[28], table[30], table[31], table[32]) 118 | self.play(ApplyMethod(gr.set_color, RED)) 119 | g = VGroup(line2[1], line2[3]) 120 | self.play(ApplyMethod(g.set_color, RED)) 121 | self.wait() 122 | 123 | gr1 = VGroup(table[24],table[25],table[26], table[29]) 124 | self.play(ApplyMethod(gr1.set_color, BLUE)) 125 | self.play(ApplyMethod(line2[5].set_color, BLUE)) 126 | self.wait() 127 | 128 | line3 = TexMobject("= \\frac{6}{10}") 129 | line3.scale(.6) 130 | line3.next_to(line2) 131 | self.play(Write(line3)) 132 | self.wait() 133 | line4 = TexMobject("P(Y=1) = ", "{\#Y=1", "\\over", "\#Y=0", "+", "\#Y=1}") 134 | line4.next_to(line2, DOWN) 135 | line4.scale(.6) 136 | self.play(Write(line4)) 137 | self.wait() 138 | 139 | gr2 = VGroup(line4[1], line4[5]) 140 | self.play(ApplyMethod(gr2.set_color, BLUE)) 141 | self.play(ApplyMethod(line4[3].set_color, RED)) 142 | self.wait() 143 | line5 = TexMobject("= \\frac{4}{10}") 144 | line5.scale(.6) 145 | line5.next_to(line4) 146 | self.play(Write(line5)) 147 | self.wait() 148 | 149 | line6 = TexMobject("P(X=(0,2)|Y=1)") 150 | line6.scale(.6) 151 | line6.next_to(line4.get_corner(DOWN+LEFT),DOWN, buff=.7) 152 | self.play(Write(line6)) 153 | self.wait() 154 | 155 | gr3 = VGroup(table[9], table[19], table[29]) 156 | framebox1 = SurroundingRectangle(gr3, buff=.1) 157 | self.play(Write(framebox1)) 158 | self.wait() 159 | 160 | 161 | line7 = TexMobject("= \\frac{1}{4}") 162 | line7.scale(.6) 163 | line7.next_to(line6) 164 | self.play(Write(line7)) 165 | self.play(FadeOut(framebox1)) 166 | self.wait() 167 | 168 | line8 = TexMobject("P(X=(0,2)|Y=0)") 169 | line8.scale(.6) 170 | line8.next_to(line6, DOWN, buff=.5) 171 | self.play(Write(line8)) 172 | self.wait() 173 | 174 | line9 = TexMobject("= 0") 175 | line9.scale(.6) 176 | line9.next_to(line8) 177 | self.play(Write(line9)) 178 | self.wait() 179 | 180 | line10 = TexMobject("P(X=(0,2)|Y=0) * P(Y=0)") 181 | line10.scale(.6) 182 | line10.next_to(line8, DOWN, buff=.7) 183 | line10.shift(.71*RIGHT) 184 | self.play(Write(line10)) 185 | self.wait() 186 | 187 | line11 = TexMobject("P(X=(0,2)|Y=1) * P(Y=1)") 188 | line11.scale(.6) 189 | line11.next_to(line10, DOWN, buff=.5) 190 | self.play(Write(line11)) 191 | self.wait() 192 | 193 | line12 = TexMobject("= 0* \\frac{6}{10} =", "0") 194 | line12[1].set_color(GREEN) 195 | line12.scale(.6) 196 | line12.next_to(line10) 197 | self.play(Write(line12)) 198 | self.wait() 199 | 200 | line13 = TexMobject("= \\frac{1}{4} * \\frac{4}{10} =", "\\frac{1}{10}") 201 | line13[1].set_color(ORANGE) 202 | line13.scale(.6) 203 | line13.next_to(line11) 204 | self.play(Write(line13)) 205 | self.wait() 206 | 207 | gr4 = VGroup(line10, line11, line12, line13) 208 | 209 | line14 = TexMobject("\\text{Estimated value of }", "Y", "\\text{ is }", "1", "\\text{ given }", "X=(0,2)") 210 | line14.scale(.7) 211 | line14.next_to(line8, DOWN, buff=.7) 212 | line14.move_to(gr4) 213 | self.play(Transform(gr4, line14)) 214 | self.wait() 215 | 216 | line15 = TexMobject("\\text{Let's assume }", "X_1, X_2", "\\text{ are independant! }") 217 | line15.scale(.8) 218 | line15.move_to(line14) 219 | self.play(Transform(gr4, line15)) 220 | self.wait() 221 | 222 | self.play(FadeOut(gr4)) 223 | 224 | line16 = TexMobject("= P(X_1=0|Y=1) * P(X_2=2|Y=1)").set_color(GREEN) 225 | line16.scale(.6) 226 | line16.next_to(line6) 227 | self.play(FadeOut(line7)) 228 | self.play(Write(line16)) 229 | self.wait() 230 | 231 | line17 = TexMobject("= P(X_1=0|Y=0) * P(X_2=2|Y=0)").set_color(PURPLE) 232 | line17.scale(.6) 233 | line17.next_to(line8) 234 | self.play(FadeOut(line9)) 235 | self.play(Write(line17)) 236 | self.wait() 237 | 238 | arrow1 = Arrow(LEFT,RIGHT) 239 | arrow1.scale(.5) 240 | arrow1.next_to(table[6], LEFT) 241 | arrow2 = Arrow(LEFT,RIGHT) 242 | arrow2.scale(.5) 243 | arrow2.next_to(table[4], LEFT) 244 | arrow3 = Arrow(LEFT,RIGHT) 245 | arrow3.scale(.5) 246 | arrow3.next_to(table[9], LEFT) 247 | gr5 = VGroup(arrow2, arrow1, arrow3) 248 | gr5.set_color(YELLOW) 249 | self.play(Write(gr5)) 250 | self.wait() 251 | 252 | line18 = TexMobject("= \\frac{3}{4}").set_color(GREEN) 253 | line18.scale(.6) 254 | line18.next_to(line16) 255 | self.play(Transform(gr5, line18)) 256 | self.wait() 257 | 258 | arrow1 = Arrow(LEFT,RIGHT) 259 | arrow1.scale(.5) 260 | arrow1.next_to(table[15], LEFT) 261 | arrow2 = Arrow(LEFT,RIGHT) 262 | arrow2.scale(.5) 263 | arrow2.next_to(table[19], LEFT) 264 | gr6 = VGroup(arrow1, arrow2) 265 | gr6.set_color(YELLOW) 266 | self.play(Write(gr6)) 267 | self.wait() 268 | 269 | line19 = TexMobject(" \\frac{2}{4}").set_color(GREEN) 270 | line19.scale(.6) 271 | line19.next_to(gr5) 272 | self.play(Transform(gr6, line19)) 273 | self.wait() 274 | 275 | arrow1 = Arrow(LEFT,RIGHT) 276 | arrow1.scale(.5) 277 | arrow1.next_to(table[3], LEFT) 278 | arrow1.set_color(YELLOW) 279 | self.play(Write(arrow1)) 280 | self.wait() 281 | 282 | line20 = TexMobject("= \\frac{1}{6}").set_color(PURPLE) 283 | line20.scale(.6) 284 | line20.next_to(line17) 285 | self.play(Transform(arrow1, line20)) 286 | self.wait() 287 | 288 | arrow2 = Arrow(LEFT,RIGHT) 289 | arrow2.scale(.5) 290 | arrow2.next_to(table[17], LEFT) 291 | arrow2.set_color(YELLOW) 292 | self.play(Write(arrow2)) 293 | self.wait() 294 | 295 | line21 = TexMobject(" \\frac{1}{6}").set_color(PURPLE) 296 | line21.scale(.6) 297 | line21.next_to(line20) 298 | self.play(Transform(arrow2, line21)) 299 | self.wait() 300 | 301 | line22 = TexMobject(" \\frac{3}{4} * \\frac{2}{4}", ">", "\\frac{1}{6} * \\frac{1}{6}") 302 | line22[0].set_color(GREEN) 303 | line22[2].set_color(PURPLE) 304 | line22.scale(.6) 305 | line22.shift(1.6*DOWN+2*LEFT) 306 | self.play(Write(line22)) 307 | self.wait() 308 | 309 | line23 = TexMobject("\\text{So, the estimated value of }", "Y", "\\text{ is }", "1") 310 | line23.scale(.6) 311 | line23.next_to(line22, DOWN) 312 | self.play(Write(line23)) 313 | self.wait(2) 314 | 315 | 316 | 317 | class Scene3(Scene): 318 | def construct(self): 319 | line = TextMobject("Dealing with Continuous features").set_color(RED) 320 | line.to_corner(LEFT+UP) 321 | self.play(Write(line)) 322 | self.wait() 323 | line1 = TextMobject("1. Discretization").scale(.7).next_to(line, DOWN, buff=.6) 324 | self.play(Write(line1)) 325 | self.wait() 326 | line3 = TexMobject("age \\in (11, 50)", "\\longrightarrow", "age \\in \\{1, 2, 3, 4\\}").scale(.7).next_to(line1, DOWN) 327 | line3[0].set_color(GREEN) 328 | line3[2].set_color(BLUE) 329 | self.play(Write(line3[0])) 330 | self.wait() 331 | self.play(Write(line3[1])) 332 | self.play(Write(line3[2])) 333 | self.wait() 334 | line2 = TextMobject("2. Fit a known Distribution").scale(.7).next_to(line1, DOWN, buff=3) 335 | self.play(Write(line2)) 336 | self.wait() 337 | line4 = TexMobject("P(X=(x_1, x_2,...,x_n)|Y=y)", "=", "\\prod{}{} f(X_i=x_i|Y=y)").scale(.7).next_to(line2, DOWN) 338 | line4[0].set_color(GREEN) 339 | line4[2].set_color(BLUE) 340 | line4.shift(RIGHT) 341 | self.play(Write(line4[0])) 342 | self.wait() 343 | self.play(Write(line4[1])) 344 | self.play(Write(line4[2])) 345 | self.wait() 346 | -------------------------------------------------------------------------------- /Introduction to NLP/GloVe.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "GloVe.ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "accelerator": "GPU" 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "metadata": { 31 | "id": "v2goQ7zZ6Jky", 32 | "colab_type": "code", 33 | "colab": {} 34 | }, 35 | "source": [ 36 | "import numpy as np\n", 37 | "from sklearn.manifold import TSNE\n", 38 | "import matplotlib.pyplot as plt" 39 | ], 40 | "execution_count": 0, 41 | "outputs": [] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": { 46 | "id": "e8kSUsoO1Z3U", 47 | "colab_type": "text" 48 | }, 49 | "source": [ 50 | "## download the word vectors" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "metadata": { 56 | "id": "9WbgU0u66nw4", 57 | "colab_type": "code", 58 | "outputId": "e1fe8a71-77ad-4ee2-c641-25c0fe842995", 59 | "colab": { 60 | "base_uri": "https://localhost:8080/", 61 | "height": 88 62 | } 63 | }, 64 | "source": [ 65 | "import gensim.downloader as api\n", 66 | "glove_model = api.load('glove-wiki-gigaword-300')" 67 | ], 68 | "execution_count": 2, 69 | "outputs": [ 70 | { 71 | "output_type": "stream", 72 | "text": [ 73 | "[=================================================-] 99.9% 375.7/376.1MB downloaded\n" 74 | ], 75 | "name": "stdout" 76 | }, 77 | { 78 | "output_type": "stream", 79 | "text": [ 80 | "/usr/local/lib/python3.6/dist-packages/smart_open/smart_open_lib.py:402: UserWarning: This function is deprecated, use smart_open.open instead. See the migration notes for details: https://github.com/RaRe-Technologies/smart_open/blob/master/README.rst#migrating-to-the-new-open-function\n", 81 | " 'See the migration notes for details: %s' % _MIGRATION_NOTES_URL\n" 82 | ], 83 | "name": "stderr" 84 | } 85 | ] 86 | }, 87 | { 88 | "cell_type": "markdown", 89 | "metadata": { 90 | "id": "EAnppTlU1foo", 91 | "colab_type": "text" 92 | }, 93 | "source": [ 94 | "## vector representation of a word" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "metadata": { 100 | "id": "5a3DLDARgOBS", 101 | "colab_type": "code", 102 | "outputId": "ccb30731-42bb-432a-f193-6fc41f880b1a", 103 | "colab": { 104 | "base_uri": "https://localhost:8080/", 105 | "height": 1000 106 | } 107 | }, 108 | "source": [ 109 | "glove_model[\"beautiful\"]" 110 | ], 111 | "execution_count": 3, 112 | "outputs": [ 113 | { 114 | "output_type": "execute_result", 115 | "data": { 116 | "text/plain": [ 117 | "array([-2.3852e-01, -3.3704e-01, -2.6531e-01, -3.4693e-01, -1.2875e-01,\n", 118 | " 1.0698e-01, -2.4669e-02, 2.6829e-02, -1.0024e-01, -9.1494e-01,\n", 119 | " 4.8989e-01, -1.0362e-01, -2.4535e-01, 5.7003e-01, -3.5189e-02,\n", 120 | " -3.7690e-01, -6.9177e-02, -2.5942e-01, 2.2511e-01, 5.1855e-01,\n", 121 | " -3.9326e-01, 1.2665e+00, -4.4396e-01, 7.6827e-01, -1.0909e-02,\n", 122 | " -2.4237e-01, -1.0275e-01, -4.9712e-01, -8.0183e-02, 4.0611e-01,\n", 123 | " 2.1275e-01, 6.5182e-01, -1.1487e+00, 4.6080e-03, -6.8265e-01,\n", 124 | " 9.6941e-01, -7.6194e-02, -4.1590e-01, -2.7069e-01, -5.3364e-02,\n", 125 | " -7.9631e-02, -2.6670e-01, -2.1544e-02, 2.2392e-01, 5.5741e-02,\n", 126 | " 8.4611e-02, 8.6011e-01, 4.8927e-01, 4.7428e-01, -2.4446e-01,\n", 127 | " -2.1553e-01, 1.4370e-01, 5.0683e-01, -5.8435e-01, -5.6243e-01,\n", 128 | " -6.3757e-02, -2.2861e-01, -6.9374e-02, 5.6618e-01, -8.7813e-02,\n", 129 | " -2.1272e-01, -1.6319e-01, 3.3545e-01, 1.3707e-01, -1.1920e-03,\n", 130 | " 9.7461e-02, 3.2382e-01, -2.2693e-01, -1.7767e-01, 4.0166e-02,\n", 131 | " -5.3029e-01, -4.5809e-01, -2.3483e-01, 3.1453e-01, 1.7206e-01,\n", 132 | " -6.9996e-02, 2.1818e-01, -1.3370e-01, 7.0031e-02, -5.1293e-01,\n", 133 | " -5.9242e-01, 2.6683e-01, 3.4211e-02, -2.3073e-01, 9.2629e-02,\n", 134 | " 9.7956e-01, -1.7105e-01, 3.4766e-01, 1.5655e-01, 1.6473e-01,\n", 135 | " -4.8657e-02, -3.3195e-01, 4.0701e-02, -3.6882e-01, 3.8325e-02,\n", 136 | " 1.4471e-01, 4.5228e-01, -5.3237e-01, 1.6001e-01, 9.1856e-02,\n", 137 | " -3.3670e-02, -2.8456e-01, 2.7661e-01, 2.5678e-01, -5.0600e-01,\n", 138 | " 9.0557e-02, 2.3590e-01, -2.3907e-01, -1.0190e-01, -4.3150e-01,\n", 139 | " -1.9739e-01, 3.4452e-01, 3.3246e-01, -8.2128e-02, 2.3898e-01,\n", 140 | " 2.8935e-02, 3.4182e-01, 6.4785e-01, 4.4846e-02, 2.3185e-01,\n", 141 | " -9.0600e-02, 3.2501e-01, -1.1690e-01, 6.3490e-01, -3.9302e-02,\n", 142 | " -1.9762e-01, -1.1636e-01, 6.4526e-01, -6.8176e-01, -2.7499e-01,\n", 143 | " 2.3495e-01, 3.8022e-01, -7.2129e-02, 3.2216e-01, -6.3217e-01,\n", 144 | " -1.3036e-01, -7.2367e-02, -1.8482e-01, -7.8929e-02, 1.2480e-01,\n", 145 | " 9.6149e-02, 4.8628e-02, -5.9320e-02, -1.5919e-01, -2.1533e-01,\n", 146 | " -3.8724e-01, 3.5391e-01, 3.4231e-01, -3.9314e-01, -1.1976e-01,\n", 147 | " -3.7050e-01, -1.2089e-01, -5.8203e-03, -3.3442e-01, 6.4367e-01,\n", 148 | " -2.2489e-01, -4.5688e-01, 1.8812e-02, 1.7772e-01, -1.5363e-01,\n", 149 | " 4.2730e-02, -3.4811e-01, 6.1017e-01, 3.0632e-01, -4.0521e-01,\n", 150 | " 1.1642e-02, 8.0483e-05, 1.9665e-01, 2.7749e-01, -2.7826e-01,\n", 151 | " -2.8165e-01, -1.7904e-01, -3.9776e-01, 2.9140e-01, 8.6537e-02,\n", 152 | " -5.2711e-02, -2.4818e-01, 1.3174e-01, -5.0422e-01, -1.7553e-01,\n", 153 | " -5.0302e-02, -6.6879e-01, 4.8007e-01, 2.3588e-02, 3.8455e-01,\n", 154 | " -2.0443e-01, 3.2373e-01, -2.6863e-01, -1.1948e-03, 4.1770e-01,\n", 155 | " -2.8839e-01, -5.8236e-02, -1.5103e-01, -5.2364e-02, -4.4363e-01,\n", 156 | " 1.8137e-01, -4.0447e-01, -4.2684e-01, -3.0427e-01, 3.6178e-01,\n", 157 | " 1.5595e+00, -3.3639e-01, -9.7822e-02, -1.7268e-02, 6.5117e-02,\n", 158 | " -3.8777e-01, 5.7876e-02, 4.3497e-01, -3.1166e-01, -2.7618e-01,\n", 159 | " -1.7773e-01, 3.3641e-01, -1.0508e-01, -3.1227e-01, 3.9182e-01,\n", 160 | " -3.7915e-02, 2.5229e-01, -6.6904e-01, 1.0371e-01, 1.7643e-01,\n", 161 | " 2.5485e-01, -3.6815e-02, 1.7848e-01, 8.2182e-02, -6.1077e-01,\n", 162 | " 2.0832e-01, 4.1189e-01, -2.0953e-01, -5.2351e-01, -4.5922e-02,\n", 163 | " 1.0356e-01, -1.1626e-01, -2.3241e-01, -4.1366e-01, -5.6315e-02,\n", 164 | " 4.5747e-01, -2.9707e-01, -1.6137e-01, -3.3410e-01, -3.1331e-01,\n", 165 | " 3.3484e-01, 1.7417e-01, -4.1686e-01, 4.8983e-01, -1.7848e-01,\n", 166 | " 4.7937e-01, -3.0127e-01, 4.2611e-01, 1.9762e-01, 3.4076e-01,\n", 167 | " 2.6479e-01, -5.3770e-01, -1.0298e-01, -3.8824e-02, 7.3822e-01,\n", 168 | " 3.3278e-02, 1.1207e-01, 7.8605e-02, 1.3025e-01, -3.6788e-01,\n", 169 | " -3.6885e-01, -4.0836e-01, -1.6628e-01, -2.1534e-01, -7.3451e-02,\n", 170 | " -3.4754e-01, -8.6115e-03, -2.1517e-01, 4.9213e-01, 2.8894e-01,\n", 171 | " 1.9182e-01, -5.3703e-01, 1.5176e-02, -1.9287e-02, 1.2511e-01,\n", 172 | " 2.9509e-01, -1.0003e+00, 1.0112e-01, -1.3583e-01, -3.6766e-01,\n", 173 | " -3.1532e-01, 3.9986e-01, -7.4484e-02, -1.6293e-01, -6.4623e-01,\n", 174 | " 1.8405e-01, -2.3892e-01, 3.5487e-01, -2.8264e-01, -3.4756e-01,\n", 175 | " 1.9120e-01, 7.6232e-02, -4.6812e-01, 3.9841e-01, 1.2330e-01,\n", 176 | " -2.5784e-01, 4.5218e-01, 3.2891e-01, 3.7239e-02, 2.3779e-01],\n", 177 | " dtype=float32)" 178 | ] 179 | }, 180 | "metadata": { 181 | "tags": [] 182 | }, 183 | "execution_count": 3 184 | } 185 | ] 186 | }, 187 | { 188 | "cell_type": "markdown", 189 | "metadata": { 190 | "id": "E9qfbMxS1qDa", 191 | "colab_type": "text" 192 | }, 193 | "source": [ 194 | "## word vectors understand the meanings of words\n" 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "metadata": { 200 | "id": "zR3zzQUrfEXe", 201 | "colab_type": "code", 202 | "outputId": "970f2f60-a145-480b-cdb1-ef4962e5bcc3", 203 | "colab": { 204 | "base_uri": "https://localhost:8080/", 205 | "height": 241 206 | } 207 | }, 208 | "source": [ 209 | "glove_model.most_similar(\"girl\")" 210 | ], 211 | "execution_count": 4, 212 | "outputs": [ 213 | { 214 | "output_type": "stream", 215 | "text": [ 216 | "/usr/local/lib/python3.6/dist-packages/gensim/matutils.py:737: FutureWarning: Conversion of the second argument of issubdtype from `int` to `np.signedinteger` is deprecated. In future, it will be treated as `np.int64 == np.dtype(int).type`.\n", 217 | " if np.issubdtype(vec.dtype, np.int):\n" 218 | ], 219 | "name": "stderr" 220 | }, 221 | { 222 | "output_type": "execute_result", 223 | "data": { 224 | "text/plain": [ 225 | "[('boy', 0.8272891044616699),\n", 226 | " ('woman', 0.729641854763031),\n", 227 | " ('girls', 0.7227291464805603),\n", 228 | " ('teenager', 0.650977373123169),\n", 229 | " ('teenage', 0.6492719650268555),\n", 230 | " ('mother', 0.6417974829673767),\n", 231 | " ('boys', 0.6283578872680664),\n", 232 | " ('child', 0.6229295134544373),\n", 233 | " ('teen', 0.612524151802063),\n", 234 | " ('daughter', 0.6050207614898682)]" 235 | ] 236 | }, 237 | "metadata": { 238 | "tags": [] 239 | }, 240 | "execution_count": 4 241 | } 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": { 247 | "id": "_Go8rwIO1RXU", 248 | "colab_type": "text" 249 | }, 250 | "source": [ 251 | "## queen - girl + boy = king" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "metadata": { 257 | "id": "DVNmvmnyw-9h", 258 | "colab_type": "code", 259 | "outputId": "d4aa347b-402a-448c-b916-27975155a403", 260 | "colab": { 261 | "base_uri": "https://localhost:8080/", 262 | "height": 88 263 | } 264 | }, 265 | "source": [ 266 | "glove_model.most_similar(positive=['boy', 'queen'], negative=['girl'], topn=1)" 267 | ], 268 | "execution_count": 5, 269 | "outputs": [ 270 | { 271 | "output_type": "stream", 272 | "text": [ 273 | "/usr/local/lib/python3.6/dist-packages/gensim/matutils.py:737: FutureWarning: Conversion of the second argument of issubdtype from `int` to `np.signedinteger` is deprecated. In future, it will be treated as `np.int64 == np.dtype(int).type`.\n", 274 | " if np.issubdtype(vec.dtype, np.int):\n" 275 | ], 276 | "name": "stderr" 277 | }, 278 | { 279 | "output_type": "execute_result", 280 | "data": { 281 | "text/plain": [ 282 | "[('king', 0.6770139336585999)]" 283 | ] 284 | }, 285 | "metadata": { 286 | "tags": [] 287 | }, 288 | "execution_count": 5 289 | } 290 | ] 291 | }, 292 | { 293 | "cell_type": "code", 294 | "metadata": { 295 | "id": "R9Tn9a3zjISS", 296 | "colab_type": "code", 297 | "outputId": "312881fb-f594-4037-dd87-0b8bae605536", 298 | "colab": { 299 | "base_uri": "https://localhost:8080/", 300 | "height": 483 301 | } 302 | }, 303 | "source": [ 304 | "vocab = [\"boy\", \"girl\", \"man\", \"woman\", \"king\", \"queen\", \"banana\", \"apple\", \"mango\", \"fruit\", \"coconut\", \"orange\"]\n", 305 | "\n", 306 | "def tsne_plot(model):\n", 307 | " labels = []\n", 308 | " wordvecs = []\n", 309 | "\n", 310 | " for word in vocab:\n", 311 | " wordvecs.append(model[word])\n", 312 | " labels.append(word)\n", 313 | " \n", 314 | " tsne_model = TSNE(perplexity=3, n_components=2, init='pca', random_state=42)\n", 315 | " coordinates = tsne_model.fit_transform(wordvecs)\n", 316 | "\n", 317 | " x = []\n", 318 | " y = []\n", 319 | " for value in coordinates:\n", 320 | " x.append(value[0])\n", 321 | " y.append(value[1])\n", 322 | " \n", 323 | " plt.figure(figsize=(8,8)) \n", 324 | " for i in range(len(x)):\n", 325 | " plt.scatter(x[i],y[i])\n", 326 | " plt.annotate(labels[i],\n", 327 | " xy=(x[i], y[i]),\n", 328 | " xytext=(2, 2),\n", 329 | " textcoords='offset points',\n", 330 | " ha='right',\n", 331 | " va='bottom')\n", 332 | " plt.show()\n", 333 | "\n", 334 | "tsne_plot(glove_model)" 335 | ], 336 | "execution_count": 6, 337 | "outputs": [ 338 | { 339 | "output_type": "display_data", 340 | "data": { 341 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAe8AAAHSCAYAAADFbUO+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0\ndHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO3deZRU5Z3/8fdDg+AAggoiAtrogCxN\nszW4EAQlgxgXRIPLEAIuMC6JjhN1NE7UKDHOgeOCW0J+xt2I445LFAETMBho9q0Rgq2IqKDSytJI\nw/P7o4tONzYi9lJ96ffrnDp97/c+t+p77/H44d56qirEGJEkSclRJ90NSJKkvWN4S5KUMIa3JEkJ\nY3hLkpQwhrckSQljeEuSlDB1093Ad9GsWbOYmZmZ7jYkSao2c+bMWR9jbF7etkSEd2ZmJrm5uelu\nQ5KkahNCeH9327xtLklSwhjekiQljOEtSVLCGN6SJCVMpYR3CCE/hLAohDA/hJCb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2LGxX79+cfbs2THGGNetWxePOOKIGGOMv//97+Ott94aY4yxsLAw9uzZM65a\ntSq+/vrrcdSoUXHHjh1x+/bt8dRTT41/+ctf4nvvvRczMjLivHnzYowxDh06ND722GNVcixAbtxN\nLnrlLYmxY8cyfvx4AK666ipOOukkAKZOncqwYcP405/+RJcuXcjKyuK///u/S/Zr1KgR11xzDZ07\nd+aHP/whs2bNon///hx55JG89NJLQPGVSt++fenRowc9evTgb3/7GwBvvfUW/fv358c//jEdOnRg\n2LBhFP//quZ6ZdUrDHxmINmPZDPwmYG8suqVdLekXUyfPp0hQ4bwL//yLxxwwAGcccYZ3zr+jTfe\n4NFHH6Vbt24cc8wxfPbZZ6xYsYI33niDN954g+7du9OjRw/y8vJYsWIFUDzxsVu3bgD07NmT/Pz8\nqj6sbzC8JdG3b1+mT58OQG5uLhs3bmTbtm1Mnz6d9u3b89///d9MnTqV+fPnM3v2bF544QUANm3a\nxEknncSSJUto3Lgx//M//8PkyZN5/vnnufHGGwE45JBDmDx5MnPnzmXixIlcccUVJa87b9487rrr\nLpYuXcqqVat4++23q//gv6NXVr3CzX+7mbWb1hKJrN20lpv/drMBnhB169Zlx44dAGUmIsYYueee\ne5g/fz7z58/nvffeY+DAgcQYuf7660vqK1eu5KKLLgJqxuRFw1sSPXv2ZM6cOXz55ZfUr1+f4447\njtzcXKZPn07Tpk3p378/zZs3p27dugwbNoy//vWvAOy3334MGjQIgC5dutCvXz/q1atX8tErgG3b\ntjFq1Ci6dOnC0KFDWbp0acnr9u7dm9atW1OnTh26deuWliuY7+ruuXdTuL2wTK1weyF3z707TR2p\nPCeccAIvvPACW7Zs4auvvmLSpEkAZGZmMmfOHACeeeaZkvEnn3wyDzzwQMnHAt999102bdrEySef\nzB//+Ec2btwIwJo1a/j000+r+Wh2z895S6JevXq0bduWhx9+mOOPP57s7GymTZvGypUry/xPr7z9\nQghA+R+9Arjzzjtp0aIFCxYsYMeOHTRo0KBk/5pwBfNdfbzp472qKz169OjBueeeS9eu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4BvFiq/tPUjOhjgYJSt35V\njlB8if0gsCzGeEepTYk4x1551xz3AvWByanbNu/EGC+JMS4JITwNLKX4dvrlMcbtACGEnwGvAxnA\nH2OMS9LTes0XQhgC3AM0B14JIcyPMZ7s+a18McYiz13FhRD+BPQHmoUQPgRuAm4Hng4hXETxLy2e\nkxr+KvAjiidcbgYuqPaGk6cPMBxYFEKYn6r9koScY79hTZKkhPG2uSRJCWN4S5KUMIa3JEkJY3hL\nkpQwhrckSQljeEuSlDCGtyRJCWN4S5KUMP8fpoZFfnKQutkAAAAASUVORK5CYII=\n", 342 | "text/plain": [ 343 | "
" 344 | ] 345 | }, 346 | "metadata": { 347 | "tags": [] 348 | } 349 | } 350 | ] 351 | } 352 | ] 353 | } 354 | -------------------------------------------------------------------------------- /Introduction to NLP/Summarization & Keyword Extraction.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from gensim.summarization.summarizer import summarize\n", 10 | "from gensim.summarization import keywords" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "# *Text 1*" 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "
\n", 25 | "

Hello, people from the future! Welcome to Normalized Nerd! I love to create educational videos on Machine Learning and Creative Coding. Machine learning and Data Science have changed our world dramatically and will continue to do so. But how they exactly work?...Find out with me. If you like my videos please subscribe to my channel.

" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 2, 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "text1 = \"Hello, people from the future! Welcome to Normalized Nerd! I love to create educational videos on Machine Learning and Creative Coding. Machine learning and Data Science have changed our world dramatically and will continue to do so. But how they exactly work?...Find out with me. If you like my videos please subscribe to my channel.\"" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 3, 40 | "metadata": {}, 41 | "outputs": [ 42 | { 43 | "name": "stdout", 44 | "output_type": "stream", 45 | "text": [ 46 | "I love to create educational videos on Machine Learning and Creative Coding.\n", 47 | "Machine learning and Data Science have changed our world dramatically and will continue to do so.\n", 48 | "If you like my videos please subscribe to my channel.\n" 49 | ] 50 | } 51 | ], 52 | "source": [ 53 | "print(summarize(text1, ratio=0.5))" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 4, 59 | "metadata": {}, 60 | "outputs": [ 61 | { 62 | "name": "stdout", 63 | "output_type": "stream", 64 | "text": [ 65 | "['I love to create educational videos on Machine Learning and Creative Coding.', 'Machine learning and Data Science have changed our world dramatically and will continue to do so.', 'If you like my videos please subscribe to my channel.']\n" 66 | ] 67 | } 68 | ], 69 | "source": [ 70 | "print(summarize(text1, split=True, ratio=0.5))" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": 5, 76 | "metadata": {}, 77 | "outputs": [ 78 | { 79 | "name": "stdout", 80 | "output_type": "stream", 81 | "text": [ 82 | "educational\n", 83 | "machine\n", 84 | "coding\n", 85 | "future\n", 86 | "exactly\n" 87 | ] 88 | } 89 | ], 90 | "source": [ 91 | "print(keywords(text1, words=5))" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "# *Text 2*" 99 | ] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "metadata": {}, 104 | "source": [ 105 | "
\n", 106 | "

It was the end of November, and Holmes and I sat, upon a raw and foggy night, on either side of a blazing fire in our sitting-room in Baker Street. Since the tragic upshot of our visit to Devonshire he had been engaged in two affairs of the utmost importance, in the first of which he had exposed the atrocious conduct of Colonel Upwood in connection with the famous card scandal of the Nonpareil Club, while in the second he had defended the unfortunate Mme.\n", 107 | "
\n", 108 | "
\n", 109 | " ...\n", 110 | "
\n", 111 | "
\n", 112 | "I have a box for Les Huguenots. Have you heard the De Reszkes? Might I trouble you then to be ready in half an hour, and we can stop at Marcini’s for a little dinner on the way?”

" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": 6, 118 | "metadata": {}, 119 | "outputs": [], 120 | "source": [ 121 | "with open('hound.txt', 'r', encoding=\"utf8\") as file:\n", 122 | " text2 = file.read().replace('\\n', '')" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 7, 128 | "metadata": {}, 129 | "outputs": [ 130 | { 131 | "name": "stdout", 132 | "output_type": "stream", 133 | "text": [ 134 | "They had called upon us that very afternoon, so that it was natural that the subject should come up for discussion.“The whole course of events,” said Holmes, “from the point of view of the man who called himself Stapleton was simple and direct, although to us, who had no means in the beginning of knowing the motives of his actions and could only learn part of the facts, it all appeared exceedingly complex.\n", 135 | "So far as the case of the hound goes, however, I will give you the course of events as nearly as I can, and you will suggest anything which I may have forgotten.“My inquiries show beyond all question that the family portrait did not lie, and that this fellow was indeed a Baskerville.\n", 136 | "His first act was to establish himself as near to his ancestral home as he could, and his second was to cultivate a friendship with Sir Charles Baskerville and with the neighbours.“The baronet himself told him about the family hound, and so prepared the way for his own death.\n", 137 | "His ingenious mind instantly suggested a way by which the baronet could be done to death, and yet it would be hardly possible to bring home the guilt to the real murderer.“Having conceived the idea he proceeded to carry it out with considerable finesse.\n", 138 | "She would have nothing to do with it, and for a time Stapleton was at a deadlock.“He found a way out of his difficulties through the chance that Sir Charles, who had conceived a friendship for him, made him the minister of his charity in the case of this unfortunate woman, Mrs. Laura Lyons.\n", 139 | "The hound was called off and hurried away to its lair in the Grimpen Mire, and a mystery was left which puzzled the authorities, alarmed the countryside, and finally brought the case within the scope of our observation.“So much for the death of Sir Charles Baskerville.\n", 140 | "Mrs. Stapleton knew that he had designs upon the old man, and also of the existence of the hound.\n", 141 | "In any case he would very soon learn it from his friend Dr. Mortimer, and he was told by the latter all details about the arrival of Henry Baskerville.\n", 142 | "It reached the baronet, and gave him the first warning of his danger.“It was very essential for Stapleton to get some article of Sir Henry’s attire so that, in case he was driven to use the dog, he might always have the means of setting him upon his track.\n", 143 | "It is very probable, therefore, that in the absence of his master it was he who cared for the hound, though he may never have known the purpose for which the beast was used.“The Stapletons then went down to Devonshire, whither they were soon followed by Sir Henry and you.\n", 144 | "This also you cleared up in a very effective way, though I had already come to the same conclusions from my own observations.“By the time that you discovered me upon the moor I had a complete knowledge of the whole business, but I had not a case which could go to a jury.\n", 145 | "Even Stapleton’s attempt upon Sir Henry that night which ended in the death of the unfortunate convict did not help us much in proving murder against our man.\n", 146 | "She had learned something of the death of the convict, and she knew that the hound was being kept in the outhouse on the evening that Sir Henry was coming to dinner.\n", 147 | "I do not know that anything essential has been left unexplained.”“He could not hope to frighten Sir Henry to death as he had done the old uncle with his bogie hound.”“The beast was savage and half-starved.\n" 148 | ] 149 | } 150 | ], 151 | "source": [ 152 | "print(summarize(text2, ratio=0.1))" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": 8, 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "name": "stdout", 162 | "output_type": "stream", 163 | "text": [ 164 | "They had called upon us that very afternoon, so that it was natural that the subject should come up for discussion.“The whole course of events,” said Holmes, “from the point of view of the man who called himself Stapleton was simple and direct, although to us, who had no means in the beginning of knowing the motives of his actions and could only learn part of the facts, it all appeared exceedingly complex.\n", 165 | "His first act was to establish himself as near to his ancestral home as he could, and his second was to cultivate a friendship with Sir Charles Baskerville and with the neighbours.“The baronet himself told him about the family hound, and so prepared the way for his own death.\n", 166 | "She would have nothing to do with it, and for a time Stapleton was at a deadlock.“He found a way out of his difficulties through the chance that Sir Charles, who had conceived a friendship for him, made him the minister of his charity in the case of this unfortunate woman, Mrs. Laura Lyons.\n", 167 | "The hound was called off and hurried away to its lair in the Grimpen Mire, and a mystery was left which puzzled the authorities, alarmed the countryside, and finally brought the case within the scope of our observation.“So much for the death of Sir Charles Baskerville.\n" 168 | ] 169 | } 170 | ], 171 | "source": [ 172 | "print(summarize(text2, word_count=200))" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": 9, 178 | "metadata": {}, 179 | "outputs": [ 180 | { 181 | "name": "stdout", 182 | "output_type": "stream", 183 | "text": [ 184 | "stapleton\n", 185 | "stapletons\n", 186 | "baskerville\n", 187 | "sir\n", 188 | "mrs\n", 189 | "hound\n", 190 | "turn\n", 191 | "considerable\n", 192 | "considerably\n", 193 | "exceedingly\n", 194 | "old\n", 195 | "cases\n", 196 | "case\n", 197 | "man\n", 198 | "turned away\n", 199 | "mind\n", 200 | "complete\n", 201 | "completing\n", 202 | "possible\n", 203 | "possibly\n", 204 | "dog\n", 205 | "great\n", 206 | "unfortunate\n", 207 | "authority\n", 208 | "authorities\n", 209 | "means\n", 210 | "said\n", 211 | "master\n", 212 | "black\n", 213 | "home\n", 214 | "country\n", 215 | "countries\n", 216 | "blood\n", 217 | "followed\n", 218 | "having\n", 219 | "instantly\n", 220 | "proved\n", 221 | "proving\n" 222 | ] 223 | } 224 | ], 225 | "source": [ 226 | "print(keywords(text2, words=30, lemmatize=False))" 227 | ] 228 | }, 229 | { 230 | "cell_type": "code", 231 | "execution_count": 10, 232 | "metadata": {}, 233 | "outputs": [ 234 | { 235 | "name": "stdout", 236 | "output_type": "stream", 237 | "text": [ 238 | "stapletons\n", 239 | "baskerville\n", 240 | "sir\n", 241 | "mrs\n", 242 | "hound\n", 243 | "exceedingly\n", 244 | "considerably\n", 245 | "old\n", 246 | "case\n", 247 | "man\n", 248 | "turned away\n", 249 | "mind\n", 250 | "dog\n", 251 | "great\n", 252 | "possibly\n", 253 | "completing\n", 254 | "unfortunate\n", 255 | "black\n", 256 | "means\n", 257 | "authorities\n", 258 | "said\n", 259 | "home\n", 260 | "blood\n", 261 | "countries\n", 262 | "followed\n", 263 | "having\n", 264 | "instantly\n", 265 | "proving\n" 266 | ] 267 | } 268 | ], 269 | "source": [ 270 | "print(keywords(text2, words=30, lemmatize=True))" 271 | ] 272 | } 273 | ], 274 | "metadata": { 275 | "kernelspec": { 276 | "display_name": "Python 3", 277 | "language": "python", 278 | "name": "python3" 279 | }, 280 | "language_info": { 281 | "codemirror_mode": { 282 | "name": "ipython", 283 | "version": 3 284 | }, 285 | "file_extension": ".py", 286 | "mimetype": "text/x-python", 287 | "name": "python", 288 | "nbconvert_exporter": "python", 289 | "pygments_lexer": "ipython3", 290 | "version": "3.7.6" 291 | } 292 | }, 293 | "nbformat": 4, 294 | "nbformat_minor": 4 295 | } 296 | -------------------------------------------------------------------------------- /Introduction to NLP/Text Cleaning + Preprocessing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

Text Cleaning & Pre-processing

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 2, 13 | "metadata": { 14 | "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", 15 | "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5" 16 | }, 17 | "outputs": [], 18 | "source": [ 19 | "import numpy as np \n", 20 | "import pandas as pd " 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 3, 26 | "metadata": { 27 | "_cell_guid": "79c7e3d0-c299-4dcb-8224-4455121ee9b0", 28 | "_uuid": "d629ff2d2480ee46fbb7e2d37f6b5fab8052498a" 29 | }, 30 | "outputs": [ 31 | { 32 | "data": { 33 | "text/html": [ 34 | "
\n", 35 | "\n", 48 | "\n", 49 | " \n", 50 | " \n", 51 | " \n", 52 | " \n", 53 | " \n", 54 | " \n", 55 | " \n", 56 | " \n", 57 | " \n", 58 | " \n", 59 | " \n", 60 | " \n", 61 | " \n", 62 | " \n", 63 | " \n", 64 | " \n", 65 | " \n", 66 | " \n", 67 | " \n", 68 | " \n", 69 | " \n", 70 | " \n", 71 | " \n", 72 | " \n", 73 | " \n", 74 | " \n", 75 | " \n", 76 | " \n", 77 | " \n", 78 | " \n", 79 | " \n", 80 | " \n", 81 | " \n", 82 | " \n", 83 | " \n", 84 | " \n", 85 | " \n", 86 | " \n", 87 | " \n", 88 | " \n", 89 | " \n", 90 | " \n", 91 | " \n", 92 | " \n", 93 | " \n", 94 | " \n", 95 | " \n", 96 | " \n", 97 | " \n", 98 | " \n", 99 | " \n", 100 | " \n", 101 | " \n", 102 | " \n", 103 | " \n", 104 | " \n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | "
Review_textReview_class
0A very, very, very slow-moving, aimless movie ...0
1Not sure who was more lost - the flat characte...0
2Attempting artiness with black & white and cle...0
3Very little music or anything to speak of.0
4The best scene in the movie was when Gerardo i...1
5The rest of the movie lacks art, charm, meanin...0
6Wasted two hours.0
7Saw the movie today and thought it was a good ...1
8A bit predictable.0
9Loved the casting of Jimmy Buffet as the scien...1
10And those baby owls were adorable.1
11The movie showed a lot of Florida at it's best...1
12The Songs Were The Best And The Muppets Were S...1
13It Was So Cool.1
14This is a very \"right on case\" movie that deli...1
15It had some average acting from the main perso...0
16This review is long overdue, since I consider ...1
17I'll put this gem up against any movie in term...1
18It's practically perfect in all of them – a tr...1
19The structure of this film is easily the most...0
20This if the first movie I've given a 10 to in ...1
21If there was ever a movie that needed word-of-...1
22Overall, the film is interesting and thought-p...1
23Plus, it was well-paced and suited its relativ...1
24Give this one a look.1
25I gave it a 101
26The Wind and the Lion is well written and supe...1
27It is a true classic.1
28It actually turned out to be pretty decent as ...1
29Definitely worth checking out.1
.........
970I immediately said I wanted to talk to the man...0
971The ambiance isn't much better.0
972Unfortunately, it only set us up for disapppoi...0
973The food wasn't good.0
974Your servers suck, wait, correction, our serve...0
975What happened next was pretty....off putting.0
976too bad cause I know it's family owned, I real...0
977Overpriced for what you are getting.0
978I vomited in the bathroom mid lunch.0
979I kept looking at the time and it had soon bec...0
980I have been to very few places to eat that und...0
981We started with the tuna sashimi which was bro...0
982Food was below average.0
983It sure does beat the nachos at the movies but...0
984All in all, Ha Long Bay was a bit of a flop.0
985The problem I have is that they charge $11.99 ...0
986Shrimp- When I unwrapped it (I live only 1/2 a...0
987It lacked flavor, seemed undercooked, and dry.0
988It really is impressive that the place hasn't ...0
989I would avoid this place if you are staying in...0
990The refried beans that came with my meal were ...0
991Spend your money and time some place else.0
992A lady at the table next to us found a live gr...0
993the presentation of the food was awful.0
994I can't tell you how disappointed I was.0
995I think food should have flavor and texture an...0
996Appetite instantly gone.0
997Overall I was not impressed and would not go b...0
998The whole experience was underwhelming, and I ...0
999Then, as if I hadn't wasted enough of my life ...0
\n", 364 | "

2748 rows × 2 columns

\n", 365 | "
" 366 | ], 367 | "text/plain": [ 368 | " Review_text Review_class\n", 369 | "0 A very, very, very slow-moving, aimless movie ... 0\n", 370 | "1 Not sure who was more lost - the flat characte... 0\n", 371 | "2 Attempting artiness with black & white and cle... 0\n", 372 | "3 Very little music or anything to speak of. 0\n", 373 | "4 The best scene in the movie was when Gerardo i... 1\n", 374 | "5 The rest of the movie lacks art, charm, meanin... 0\n", 375 | "6 Wasted two hours. 0\n", 376 | "7 Saw the movie today and thought it was a good ... 1\n", 377 | "8 A bit predictable. 0\n", 378 | "9 Loved the casting of Jimmy Buffet as the scien... 1\n", 379 | "10 And those baby owls were adorable. 1\n", 380 | "11 The movie showed a lot of Florida at it's best... 1\n", 381 | "12 The Songs Were The Best And The Muppets Were S... 1\n", 382 | "13 It Was So Cool. 1\n", 383 | "14 This is a very \"right on case\" movie that deli... 1\n", 384 | "15 It had some average acting from the main perso... 0\n", 385 | "16 This review is long overdue, since I consider ... 1\n", 386 | "17 I'll put this gem up against any movie in term... 1\n", 387 | "18 It's practically perfect in all of them – a tr... 1\n", 388 | "19 The structure of this film is easily the most... 0\n", 389 | "20 This if the first movie I've given a 10 to in ... 1\n", 390 | "21 If there was ever a movie that needed word-of-... 1\n", 391 | "22 Overall, the film is interesting and thought-p... 1\n", 392 | "23 Plus, it was well-paced and suited its relativ... 1\n", 393 | "24 Give this one a look. 1\n", 394 | "25 I gave it a 10 1\n", 395 | "26 The Wind and the Lion is well written and supe... 1\n", 396 | "27 It is a true classic. 1\n", 397 | "28 It actually turned out to be pretty decent as ... 1\n", 398 | "29 Definitely worth checking out. 1\n", 399 | ".. ... ...\n", 400 | "970 I immediately said I wanted to talk to the man... 0\n", 401 | "971 The ambiance isn't much better. 0\n", 402 | "972 Unfortunately, it only set us up for disapppoi... 0\n", 403 | "973 The food wasn't good. 0\n", 404 | "974 Your servers suck, wait, correction, our serve... 0\n", 405 | "975 What happened next was pretty....off putting. 0\n", 406 | "976 too bad cause I know it's family owned, I real... 0\n", 407 | "977 Overpriced for what you are getting. 0\n", 408 | "978 I vomited in the bathroom mid lunch. 0\n", 409 | "979 I kept looking at the time and it had soon bec... 0\n", 410 | "980 I have been to very few places to eat that und... 0\n", 411 | "981 We started with the tuna sashimi which was bro... 0\n", 412 | "982 Food was below average. 0\n", 413 | "983 It sure does beat the nachos at the movies but... 0\n", 414 | "984 All in all, Ha Long Bay was a bit of a flop. 0\n", 415 | "985 The problem I have is that they charge $11.99 ... 0\n", 416 | "986 Shrimp- When I unwrapped it (I live only 1/2 a... 0\n", 417 | "987 It lacked flavor, seemed undercooked, and dry. 0\n", 418 | "988 It really is impressive that the place hasn't ... 0\n", 419 | "989 I would avoid this place if you are staying in... 0\n", 420 | "990 The refried beans that came with my meal were ... 0\n", 421 | "991 Spend your money and time some place else. 0\n", 422 | "992 A lady at the table next to us found a live gr... 0\n", 423 | "993 the presentation of the food was awful. 0\n", 424 | "994 I can't tell you how disappointed I was. 0\n", 425 | "995 I think food should have flavor and texture an... 0\n", 426 | "996 Appetite instantly gone. 0\n", 427 | "997 Overall I was not impressed and would not go b... 0\n", 428 | "998 The whole experience was underwhelming, and I ... 0\n", 429 | "999 Then, as if I hadn't wasted enough of my life ... 0\n", 430 | "\n", 431 | "[2748 rows x 2 columns]" 432 | ] 433 | }, 434 | "execution_count": 3, 435 | "metadata": {}, 436 | "output_type": "execute_result" 437 | } 438 | ], 439 | "source": [ 440 | "data_imdb = pd.read_csv(\"imdb_labelled.txt\", delimiter='\\t', header=None)\n", 441 | "data_imdb.columns = [\"Review_text\", \"Review_class\"]\n", 442 | "\n", 443 | "data_amazon = pd.read_csv(\"amazon_cells_labelled.txt\", delimiter='\\t', header=None)\n", 444 | "data_amazon.columns = [\"Review_text\", \"Review_class\"]\n", 445 | "\n", 446 | "data_yelp = pd.read_csv(\"yelp_labelled.txt\", delimiter='\\t', header=None)\n", 447 | "data_yelp.columns = [\"Review_text\", \"Review_class\"]\n", 448 | "\n", 449 | "data = pd.concat([data_imdb, data_amazon, data_yelp])\n", 450 | "data" 451 | ] 452 | }, 453 | { 454 | "cell_type": "code", 455 | "execution_count": 4, 456 | "metadata": {}, 457 | "outputs": [], 458 | "source": [ 459 | "import re\n", 460 | "import nltk\n", 461 | "import string\n", 462 | "from nltk.tokenize import word_tokenize\n", 463 | "from nltk.corpus import stopwords\n", 464 | "from nltk.stem.porter import PorterStemmer" 465 | ] 466 | }, 467 | { 468 | "cell_type": "code", 469 | "execution_count": 12, 470 | "metadata": {}, 471 | "outputs": [ 472 | { 473 | "data": { 474 | "text/plain": [ 475 | "['a very very very slowmoving aimless movie about a distressed drifting young man',\n", 476 | " 'not sure who was more lost the flat characters or the audience nearly half of whom walked out',\n", 477 | " 'attempting artiness with black white and clever camera angles the movie disappointed became even more ridiculous as the acting was poor and the plot and lines almost nonexistent',\n", 478 | " 'very little music or anything to speak of',\n", 479 | " 'the best scene in the movie was when gerardo is trying to find a song that keeps running through his head',\n", 480 | " 'the rest of the movie lacks art charm meaning if it is about emptiness it works i guess because it is empty',\n", 481 | " 'wasted two hours',\n", 482 | " 'saw the movie today and thought it was a good effort good messages for kids',\n", 483 | " 'a bit predictable',\n", 484 | " 'loved the casting of jimmy buffet as the science teacher',\n", 485 | " 'and those baby owls were adorable',\n", 486 | " 'the movie showed a lot of florida at it is best made it look very appealing',\n", 487 | " 'the songs were the best and the muppets were so hilarious',\n", 488 | " 'it was so cool',\n", 489 | " 'this is a very right on case movie that delivers everything almost right in your face',\n", 490 | " 'it had some average acting from the main person and it was a low budget as you clearly can see',\n", 491 | " 'this review is long overdue since i consider a tale of two sisters to be the single greatest film ever made',\n", 492 | " 'i will put this gem up against any movie in terms of screenplay cinematography acting postproduction editing directing or any other aspect of filmmaking',\n", 493 | " 'it is practically perfect in all of them a true masterpiece in a sea of faux masterpieces',\n", 494 | " 'the structure of this film is easily the most tightly constructed in the history of cinema i can think of no other film where something vitally important occurs every other minute in other words the content level of this film is enough to easily fill a dozen other films how can anyone in their right mind ask for anything more from a movie than this it is quite simply the highest most superlative form of cinema imaginable yes this film does require a rather significant amount of puzzlesolving but the pieces fit together to create a beautiful picture this short film certainly pulls no punches graphics is far from the best part of the game this is the number one best th game in the series it deserves strong love it is an insane game there are massive levels massive unlockable characters it is just a massive game waste your money on this game this is the kind of money that is wasted properly actually the graphics were good at the time today the graphics are crap as they say in canada this is the fun game aye this game rocks buy it play it enjoy it love it it is pure brilliance this was a flick doomed from its conception the very idea of it was lame take a minor character from a mediocre film and make a complete nonsequel while changing its tone to a pgrated family movie i was nt the least bit interested not only did it only confirm that the film would be unfunny and generic but it also managed to give away the entire movie and i am not exaggerating every moment every plot point every joke is told in the trailer but it is just not funny but even the talented carrell can not save this his costars do not fare much better with people like morgan freeman jonah hill and ed helms just wasted the story itself is just predictable and lazy the only real effects work is the presence of all the animals and the integration of those into the scenes is some of the worst and most obvious bluegreenscreen work i have ever seen but whatever it was that cost them so much it did nt translate to quality that is for sure the film succeeds despite or perhaps because of an obviously meagre budget i am glad the film did nt go for the most obvious choice as a lesser film certainly would have in addition to having one of the most lovely songs ever written french cancan also boasts one of the cutest leading ladies ever to grace the screen it is hard not to fall headoverheels in love with that girl on the negative it is insipid enough to cause regret for another hours of life wasted in front of the screen long whiny and pointless but i recommend waiting for their future efforts let this one go excellent cast story line performances totally believable anne heche was utterly convincing sam shepard s portrayal of a gung ho marine was sobering i sat riveted to the tv screen all in all i give this one a resounding out of i do think tom hanks is a good actor i enjoyed reading this book to my children when they were little i was very disappointed in the movie one character is totally annoying with a voice that gives me the feeling of fingernails on a chalkboard there is a totally unnecessary trainroller coaster scene there was absolutely no warmth or charm to these scenes or characters this movie totally grates on my nerves the performances are not improved by improvisation because the actors now have twice as much to worry about not only whether they are delivering the line well but whether the line itself is any good and quite honestly often its not very good often the dialogue does nt really follow from one line to another or fit the surroundings it crackles with an unpredictable youthful energy but honestly i found it hard to follow and concentrate on it meanders so badly there are some generally great things in it i would nt say they are worth hours of your time though the suspense builders were good just cross the line from g to pg i especially liked the noncliche choices with the parents in other movies i could predict the dialog verbatim but the writing in this movie made better selections if you want a movie that is not gross but gives you some chills this is a great choice alexander nevsky is a great film he is an amazing film artist one of the most important whoever lived i am glad this pretentious piece of s did nt do as planned by the dodge stratus big shots it is gon na help movie makers who are nt in the very restrained movie business of québec']" 495 | ] 496 | }, 497 | "execution_count": 12, 498 | "metadata": {}, 499 | "output_type": "execute_result" 500 | } 501 | ], 502 | "source": [ 503 | "def clean_text(df):\n", 504 | " all_reviews = list()\n", 505 | " lines = df[\"Review_text\"].values.tolist()\n", 506 | " for text in lines:\n", 507 | " text = text.lower()\n", 508 | " \n", 509 | " pattern = re.compile('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+')\n", 510 | " text = pattern.sub('', text)\n", 511 | " \n", 512 | " emoji = re.compile(\"[\"\n", 513 | " u\"\\U0001F600-\\U0001FFFF\" # emoticons\n", 514 | " u\"\\U0001F300-\\U0001F5FF\" # symbols & pictographs\n", 515 | " u\"\\U0001F680-\\U0001F6FF\" # transport & map symbols\n", 516 | " u\"\\U0001F1E0-\\U0001F1FF\" # flags (iOS)\n", 517 | " u\"\\U00002702-\\U000027B0\"\n", 518 | " u\"\\U000024C2-\\U0001F251\"\n", 519 | " \"]+\", flags=re.UNICODE)\n", 520 | " text = emoji.sub(r'', text)\n", 521 | " \n", 522 | " text = re.sub(r\"i'm\", \"i am\", text)\n", 523 | " text = re.sub(r\"he's\", \"he is\", text)\n", 524 | " text = re.sub(r\"she's\", \"she is\", text)\n", 525 | " text = re.sub(r\"that's\", \"that is\", text) \n", 526 | " text = re.sub(r\"what's\", \"what is\", text)\n", 527 | " text = re.sub(r\"where's\", \"where is\", text) \n", 528 | " text = re.sub(r\"\\'ll\", \" will\", text) \n", 529 | " text = re.sub(r\"\\'ve\", \" have\", text) \n", 530 | " text = re.sub(r\"\\'re\", \" are\", text)\n", 531 | " text = re.sub(r\"\\'d\", \" would\", text)\n", 532 | " text = re.sub(r\"\\'ve\", \" have\", text)\n", 533 | " text = re.sub(r\"won't\", \"will not\", text)\n", 534 | " text = re.sub(r\"don't\", \"do not\", text)\n", 535 | " text = re.sub(r\"did't\", \"did not\", text)\n", 536 | " text = re.sub(r\"can't\", \"can not\", text)\n", 537 | " text = re.sub(r\"it's\", \"it is\", text)\n", 538 | " text = re.sub(r\"couldn't\", \"could not\", text)\n", 539 | " text = re.sub(r\"have't\", \"have not\", text)\n", 540 | " \n", 541 | " text = re.sub(r\"[,.\\\"!@#$%^&*(){}?/;`~:<>+=-]\", \"\", text)\n", 542 | " tokens = word_tokenize(text)\n", 543 | " table = str.maketrans('', '', string.punctuation)\n", 544 | " stripped = [w.translate(table) for w in tokens]\n", 545 | " words = [word for word in stripped if word.isalpha()]\n", 546 | "# stop_words = set(stopwords.words(\"english\"))\n", 547 | "# stop_words.discard(\"not\")\n", 548 | "# words = [w for w in words if not w in stop_words]\n", 549 | " words = ' '.join(words)\n", 550 | " all_reviews.append(words)\n", 551 | " return all_reviews\n", 552 | "\n", 553 | "all_reviews = clean_text(data)\n", 554 | "all_reviews[0:20]" 555 | ] 556 | }, 557 | { 558 | "cell_type": "code", 559 | "execution_count": 14, 560 | "metadata": {}, 561 | "outputs": [ 562 | { 563 | "data": { 564 | "text/plain": [ 565 | "['i will suggest you to open and search nerdy wits']" 566 | ] 567 | }, 568 | "execution_count": 14, 569 | "metadata": {}, 570 | "output_type": "execute_result" 571 | } 572 | ], 573 | "source": [ 574 | "df = pd.DataFrame([\"I'll suggest you to open https://www.google.com/ and search NERDY WITS\"])\n", 575 | "df.columns = [\"Review_text\"]\n", 576 | "cleaned_text = clean_text(df)\n", 577 | "cleaned_text" 578 | ] 579 | } 580 | ], 581 | "metadata": { 582 | "kernelspec": { 583 | "display_name": "Python 3", 584 | "language": "python", 585 | "name": "python3" 586 | }, 587 | "language_info": { 588 | "codemirror_mode": { 589 | "name": "ipython", 590 | "version": 3 591 | }, 592 | "file_extension": ".py", 593 | "mimetype": "text/x-python", 594 | "name": "python", 595 | "nbconvert_exporter": "python", 596 | "pygments_lexer": "ipython3", 597 | "version": "3.6.5" 598 | } 599 | }, 600 | "nbformat": 4, 601 | "nbformat_minor": 1 602 | } 603 | -------------------------------------------------------------------------------- /Introduction to NLP/Word2Vec.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Word2Vec.ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "accelerator": "GPU" 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "metadata": { 31 | "id": "v2goQ7zZ6Jky", 32 | "colab_type": "code", 33 | "colab": {} 34 | }, 35 | "source": [ 36 | "import numpy as np\n", 37 | "from sklearn.manifold import TSNE\n", 38 | "import matplotlib.pyplot as plt" 39 | ], 40 | "execution_count": 0, 41 | "outputs": [] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": { 46 | "id": "e8kSUsoO1Z3U", 47 | "colab_type": "text" 48 | }, 49 | "source": [ 50 | "## download the word vectors" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "metadata": { 56 | "id": "9WbgU0u66nw4", 57 | "colab_type": "code", 58 | "outputId": "90996d31-cb87-4b37-ca58-23be0f446f92", 59 | "colab": { 60 | "base_uri": "https://localhost:8080/", 61 | "height": 88 62 | } 63 | }, 64 | "source": [ 65 | "import gensim.downloader as api\n", 66 | "word2vec_model = api.load('word2vec-google-news-300')" 67 | ], 68 | "execution_count": 0, 69 | "outputs": [ 70 | { 71 | "output_type": "stream", 72 | "text": [ 73 | "[=================================================-] 99.6% 1656.8/1662.8MB downloaded\n" 74 | ], 75 | "name": "stdout" 76 | }, 77 | { 78 | "output_type": "stream", 79 | "text": [ 80 | "/usr/local/lib/python3.6/dist-packages/smart_open/smart_open_lib.py:402: UserWarning: This function is deprecated, use smart_open.open instead. See the migration notes for details: https://github.com/RaRe-Technologies/smart_open/blob/master/README.rst#migrating-to-the-new-open-function\n", 81 | " 'See the migration notes for details: %s' % _MIGRATION_NOTES_URL\n" 82 | ], 83 | "name": "stderr" 84 | } 85 | ] 86 | }, 87 | { 88 | "cell_type": "markdown", 89 | "metadata": { 90 | "id": "EAnppTlU1foo", 91 | "colab_type": "text" 92 | }, 93 | "source": [ 94 | "## vector representation of a word" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "metadata": { 100 | "id": "5a3DLDARgOBS", 101 | "colab_type": "code", 102 | "outputId": "b20fa3e6-73d7-48da-cf20-a2867b2a36ce", 103 | "colab": { 104 | "base_uri": "https://localhost:8080/", 105 | "height": 1000 106 | } 107 | }, 108 | "source": [ 109 | "word2vec_model[\"beautiful\"]" 110 | ], 111 | "execution_count": 0, 112 | "outputs": [ 113 | { 114 | "output_type": "execute_result", 115 | "data": { 116 | "text/plain": [ 117 | "array([-0.01831055, 0.05566406, -0.01153564, 0.07275391, 0.15136719,\n", 118 | " -0.06176758, 0.20605469, -0.15332031, -0.05908203, 0.22851562,\n", 119 | " -0.06445312, -0.22851562, -0.09472656, -0.03344727, 0.24707031,\n", 120 | " 0.05541992, -0.00921631, 0.1328125 , -0.15429688, 0.08105469,\n", 121 | " -0.07373047, 0.24316406, 0.12353516, -0.09277344, 0.08203125,\n", 122 | " 0.06494141, 0.15722656, 0.11279297, -0.0612793 , -0.296875 ,\n", 123 | " -0.13378906, 0.234375 , 0.09765625, 0.17773438, 0.06689453,\n", 124 | " -0.27539062, 0.06445312, -0.13867188, -0.08886719, 0.171875 ,\n", 125 | " 0.07861328, -0.10058594, 0.23925781, 0.03808594, 0.18652344,\n", 126 | " -0.11279297, 0.22558594, 0.10986328, -0.11865234, 0.02026367,\n", 127 | " 0.11376953, 0.09570312, 0.29492188, 0.08251953, -0.05444336,\n", 128 | " -0.0090332 , -0.0625 , -0.17578125, -0.08154297, 0.01062012,\n", 129 | " -0.04736328, -0.08544922, -0.19042969, -0.30273438, 0.07617188,\n", 130 | " 0.125 , -0.05932617, 0.03833008, -0.03564453, 0.2421875 ,\n", 131 | " 0.36132812, 0.04760742, 0.00631714, -0.03088379, -0.13964844,\n", 132 | " 0.22558594, -0.06298828, -0.02636719, 0.1171875 , 0.33398438,\n", 133 | " -0.07666016, -0.06689453, 0.04150391, -0.15136719, -0.22460938,\n", 134 | " 0.03320312, -0.15332031, 0.07128906, 0.16992188, 0.11572266,\n", 135 | " -0.13085938, 0.12451172, -0.20410156, 0.04736328, -0.296875 ,\n", 136 | " -0.17480469, 0.00872803, -0.04638672, 0.10791016, -0.203125 ,\n", 137 | " -0.27539062, 0.2734375 , 0.02563477, -0.11035156, 0.0625 ,\n", 138 | " 0.1953125 , 0.16015625, -0.13769531, -0.09863281, -0.1953125 ,\n", 139 | " -0.22851562, 0.25390625, 0.00915527, -0.03857422, 0.3984375 ,\n", 140 | " -0.1796875 , 0.03833008, -0.24804688, 0.03515625, 0.03881836,\n", 141 | " 0.03442383, -0.04101562, 0.20214844, -0.03015137, -0.09619141,\n", 142 | " 0.11669922, -0.06738281, 0.0625 , 0.10742188, 0.25585938,\n", 143 | " -0.21777344, 0.05639648, -0.0065918 , 0.16113281, 0.11865234,\n", 144 | " -0.03088379, -0.11572266, 0.02685547, 0.03100586, 0.09863281,\n", 145 | " 0.05883789, 0.00634766, 0.11914062, 0.07324219, -0.01586914,\n", 146 | " 0.18457031, 0.05322266, 0.19824219, -0.22363281, -0.25195312,\n", 147 | " 0.15039062, 0.22753906, 0.05737305, 0.16992188, -0.22558594,\n", 148 | " 0.06494141, 0.11914062, -0.06640625, -0.10449219, -0.07226562,\n", 149 | " -0.16992188, 0.0625 , 0.14648438, 0.27148438, -0.02172852,\n", 150 | " -0.12695312, 0.18457031, -0.27539062, -0.36523438, -0.03491211,\n", 151 | " -0.18554688, 0.23828125, -0.13867188, 0.00296021, 0.04272461,\n", 152 | " 0.13867188, 0.12207031, 0.05957031, -0.22167969, -0.18945312,\n", 153 | " -0.23242188, -0.28710938, -0.00866699, -0.16113281, -0.24316406,\n", 154 | " 0.05712891, -0.06982422, 0.00053406, -0.10302734, -0.13378906,\n", 155 | " -0.16113281, 0.11621094, 0.31640625, -0.02697754, -0.01574707,\n", 156 | " 0.11425781, -0.04174805, 0.05908203, 0.02661133, -0.08642578,\n", 157 | " 0.140625 , 0.09228516, -0.25195312, -0.31445312, -0.05688477,\n", 158 | " 0.01031494, 0.0234375 , -0.02331543, -0.08056641, 0.01269531,\n", 159 | " -0.34179688, 0.17285156, -0.16015625, 0.07763672, -0.03088379,\n", 160 | " 0.11962891, 0.11767578, 0.20117188, -0.01940918, 0.02172852,\n", 161 | " 0.23046875, 0.28125 , -0.17675781, 0.02978516, 0.08740234,\n", 162 | " -0.06176758, 0.00939941, -0.09277344, -0.203125 , 0.13085938,\n", 163 | " -0.13671875, -0.00500488, -0.04296875, 0.12988281, 0.3515625 ,\n", 164 | " 0.0402832 , -0.12988281, -0.03173828, 0.28515625, 0.18261719,\n", 165 | " 0.13867188, -0.16503906, -0.26171875, -0.04345703, 0.0100708 ,\n", 166 | " 0.08740234, 0.00421143, -0.1328125 , -0.17578125, -0.04321289,\n", 167 | " -0.015625 , 0.16894531, 0.25 , 0.37109375, 0.19921875,\n", 168 | " -0.36132812, -0.10302734, -0.20800781, -0.20117188, -0.01519775,\n", 169 | " -0.12207031, -0.12011719, -0.07421875, -0.04345703, 0.14160156,\n", 170 | " 0.15527344, -0.03027344, -0.09326172, -0.04589844, 0.16796875,\n", 171 | " -0.03027344, 0.09179688, -0.10058594, 0.20703125, 0.11376953,\n", 172 | " -0.12402344, 0.04003906, 0.06933594, -0.34570312, 0.03881836,\n", 173 | " 0.16210938, 0.05761719, -0.12792969, -0.05810547, 0.03857422,\n", 174 | " -0.11328125, -0.1953125 , -0.28125 , -0.13183594, 0.15722656,\n", 175 | " -0.09765625, 0.09619141, -0.09960938, -0.00285339, -0.03637695,\n", 176 | " 0.15429688, 0.06152344, -0.34570312, 0.11083984, 0.03344727],\n", 177 | " dtype=float32)" 178 | ] 179 | }, 180 | "metadata": { 181 | "tags": [] 182 | }, 183 | "execution_count": 3 184 | } 185 | ] 186 | }, 187 | { 188 | "cell_type": "markdown", 189 | "metadata": { 190 | "id": "E9qfbMxS1qDa", 191 | "colab_type": "text" 192 | }, 193 | "source": [ 194 | "## word vectors understand the meanings of words\n" 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "metadata": { 200 | "id": "zR3zzQUrfEXe", 201 | "colab_type": "code", 202 | "outputId": "fc73e93d-e337-497e-b570-f171a219a5b8", 203 | "colab": { 204 | "base_uri": "https://localhost:8080/", 205 | "height": 241 206 | } 207 | }, 208 | "source": [ 209 | "word2vec_model.most_similar(\"girl\")" 210 | ], 211 | "execution_count": 0, 212 | "outputs": [ 213 | { 214 | "output_type": "stream", 215 | "text": [ 216 | "/usr/local/lib/python3.6/dist-packages/gensim/matutils.py:737: FutureWarning: Conversion of the second argument of issubdtype from `int` to `np.signedinteger` is deprecated. In future, it will be treated as `np.int64 == np.dtype(int).type`.\n", 217 | " if np.issubdtype(vec.dtype, np.int):\n" 218 | ], 219 | "name": "stderr" 220 | }, 221 | { 222 | "output_type": "execute_result", 223 | "data": { 224 | "text/plain": [ 225 | "[('boy', 0.8543272018432617),\n", 226 | " ('teenage_girl', 0.7927976250648499),\n", 227 | " ('woman', 0.7494640946388245),\n", 228 | " ('teenager', 0.717249870300293),\n", 229 | " ('schoolgirl', 0.7075953483581543),\n", 230 | " ('teenaged_girl', 0.6650916337966919),\n", 231 | " ('daughter', 0.6489864587783813),\n", 232 | " ('mother', 0.6478164196014404),\n", 233 | " ('toddler', 0.6473966836929321),\n", 234 | " ('girls', 0.6154742240905762)]" 235 | ] 236 | }, 237 | "metadata": { 238 | "tags": [] 239 | }, 240 | "execution_count": 4 241 | } 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": { 247 | "id": "_Go8rwIO1RXU", 248 | "colab_type": "text" 249 | }, 250 | "source": [ 251 | "## queen - girl + boy = king" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "metadata": { 257 | "id": "DVNmvmnyw-9h", 258 | "colab_type": "code", 259 | "outputId": "eb37e502-7def-4f1e-a5d8-1a0ba19bb387", 260 | "colab": { 261 | "base_uri": "https://localhost:8080/", 262 | "height": 88 263 | } 264 | }, 265 | "source": [ 266 | "word2vec_model.most_similar(positive=['boy', 'queen'], negative=['girl'], topn=1)" 267 | ], 268 | "execution_count": 0, 269 | "outputs": [ 270 | { 271 | "output_type": "stream", 272 | "text": [ 273 | "/usr/local/lib/python3.6/dist-packages/gensim/matutils.py:737: FutureWarning: Conversion of the second argument of issubdtype from `int` to `np.signedinteger` is deprecated. In future, it will be treated as `np.int64 == np.dtype(int).type`.\n", 274 | " if np.issubdtype(vec.dtype, np.int):\n" 275 | ], 276 | "name": "stderr" 277 | }, 278 | { 279 | "output_type": "execute_result", 280 | "data": { 281 | "text/plain": [ 282 | "[('king', 0.7298422455787659)]" 283 | ] 284 | }, 285 | "metadata": { 286 | "tags": [] 287 | }, 288 | "execution_count": 12 289 | } 290 | ] 291 | }, 292 | { 293 | "cell_type": "code", 294 | "metadata": { 295 | "id": "R9Tn9a3zjISS", 296 | "colab_type": "code", 297 | "outputId": "31c75d2c-d73d-484a-f2b2-bb33f4e2d052", 298 | "colab": { 299 | "base_uri": "https://localhost:8080/", 300 | "height": 483 301 | } 302 | }, 303 | "source": [ 304 | "vocab = [\"boy\", \"girl\", \"man\", \"woman\", \"king\", \"queen\", \"banana\", \"apple\", \"mango\", \"fruit\", \"coconut\", \"orange\"]\n", 305 | "\n", 306 | "def tsne_plot(model):\n", 307 | " labels = []\n", 308 | " wordvecs = []\n", 309 | "\n", 310 | " for word in vocab:\n", 311 | " wordvecs.append(model[word])\n", 312 | " labels.append(word)\n", 313 | " \n", 314 | " tsne_model = TSNE(perplexity=3, n_components=2, init='pca', random_state=42)\n", 315 | " coordinates = tsne_model.fit_transform(wordvecs)\n", 316 | "\n", 317 | " x = []\n", 318 | " y = []\n", 319 | " for value in coordinates:\n", 320 | " x.append(value[0])\n", 321 | " y.append(value[1])\n", 322 | " \n", 323 | " plt.figure(figsize=(8,8)) \n", 324 | " for i in range(len(x)):\n", 325 | " plt.scatter(x[i],y[i])\n", 326 | " plt.annotate(labels[i],\n", 327 | " xy=(x[i], y[i]),\n", 328 | " xytext=(2, 2),\n", 329 | " textcoords='offset points',\n", 330 | " ha='right',\n", 331 | " va='bottom')\n", 332 | " plt.show()\n", 333 | "\n", 334 | "tsne_plot(word2vec_model)" 335 | ], 336 | "execution_count": 0, 337 | "outputs": [ 338 | { 339 | "output_type": "display_data", 340 | "data": { 341 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfYAAAHSCAYAAAAe1umcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0\ndHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO3deXRV9bn/8c9DgIQLGlAiIFCDXuYk\nkBBQxAiSFtCqUAW1Fx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OztbkjR16lTdeuutIesDAHBqCHacUOvWrdWrVy9J0o033qhFixapTZs2\nateunSRp2LBh+uijj2Rmuummm/Tqq69q7969WrZsmS6//PJwtg4AtRJ/x44TMrMy840bN9bu3buP\nue4tt9yiq666SlFRURoyZIjq1uWfFwBUNa7YcUJbtmzRsmXLJBV/aE5ycrKysrKUmZkpSZo+fbp6\n9+4tSTr33HN17rnn6qmnntItt9wStp4BoDYj2HFC7du313PPPaeOHTtqz549Gj16tKZOnaohQ4Yo\nPj5ederU0e9///uS9YcOHarWrVurY8eOYewaAGovvgQGIXXF9cP1VUFTFba9TOc2bqD7+rfXoMSW\n4W4LAGocvgQGYXdBxwTt2O8Uc91fZJK27z2oh976UpIIdwCoIgQ7Qqb5sHEq3Fv2c+sP5hfqmfc3\nEewAUEV4xo6Q+e6IUD9ZHQAQegQ7Qubcxg3KVQcAhB7BjpC5r397NagXUabWoF6E7uvfPkwdAUDt\nwzN2hMzh5+jPvL9J3+09yKh4AAgDgh0hNSixJUEOAGHErXgAADxSo4P9mWee0YQJEyRJo0ePVt++\nfSVJH3zwgYYOHaoZM2YoPj5ecXFxeuCBB0q2a9Soke677z517txZv/zlL7VixQr16dNH559/vt55\n5x1JUlZWllJSUpSUlKSkpCR9+umnkqQlS5aoT58+Gjx4sDp06KChQ4eqJnzIDwCgdghJsJtZlpl9\naWbpZpYW1M4yswVmlhH8bBLUzcwmmFmmma0xs6TTPW5KSoqWLl0qSUpLS1Nubq7y8/O1dOlStWvX\nTg888IA++OADpaena+XKlZo7d64kaf/+/erbt6/WrVunM844Q3/+85+1YMECzZkzR48++qgk6Zxz\nztGCBQv0+eefa+bMmbr77rtLjrt69WqNGzdO69ev1+bNm/XJJ5+c7lsAACCkQnnFfplzrmupj797\nUNIi51xbSYuCeUm6XFLb4DVS0uTTPWC3bt20atUq7du3T5GRkerZs6fS0tK0dOlSNW7cWH369FFM\nTIzq1q2roUOH6qOPPpIk1a9fXwMGDJAkxcfHq3fv3qpXr57i4+OVlZU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uZ8lvRGsi/LjXFYS\n59xHkn48ojxQ0svB9MuSBpWqv+KKLZfU2MxaVE2nfnDO7XDOfR5M/yRpg6SW4pxXiuC85Qaz9YKX\nk9RX0qygfuT5Pvx7mCUp1czsRMcg2P3UUtLWUvPbgtrx6ig/zmXVauac2xFM75TULJjm9xBCwW3e\nREmfiXNeaYI7qOmSfpC0QNLXkvY65wqCVUqf05LzHSzPkXT2ifZftzKaRuiY2UJJzY+x6GHn3NtV\n3Q8Qbs45Z2b8OU+ImVkjSbMl/cE5t6/0RSHnPLScc4WSuppZY0lzJHUI5f4J9mrOOffL09hsu6TW\npeZbBTWdoI7yOdE5Ruh9b2YtnHM7gtu+PwR1fg8hYGb1VBzqrznn3grKnPNK5pzba2aLJfVU8SON\nusFVeelzevh8bzOzupKiJe0+0X65Fe+ndyTdEIymbKPiQS4rJK2U1DYYfVlfxQPs3gljnzUZ57Jq\nvSNpWDA9TNLbpeo3ByO1L5KUU+r2MU5B8Lz2RUkbnHPPllrEOa8EZhYTXKnLzBpI+pWKxzUsljQ4\nWO3I83349zBY0gfuZB9A45zjVUNfkn6j4mcxhyR9L+n9UsseVvFzm02SLi9Vv0LSV8Gyh8P9Hmry\ni3NZaed1hqQdkvKDf9+3qfiZ4iJJGZIWSjorWNdU/NcJX0v6UlJyuPuvaS9Jl6h48NYaSenB6wrO\neaWd7wRJq4PzvVbSo0H9fBVfgGVK+h9JkUE9KpjPDJaff7Jj8MlzAAB4hFvxAAB4hGAHAMAjBDsA\nAB4h2AEA8AjBDgCARwh2AAA8QrADAOARgh0AAI/8fxM7FoOhHtnJAAAAAElFTkSuQmCC\n", 342 | "text/plain": [ 343 | "
" 344 | ] 345 | }, 346 | "metadata": { 347 | "tags": [] 348 | } 349 | } 350 | ] 351 | } 352 | ] 353 | } 354 | -------------------------------------------------------------------------------- /Introduction to NLP/hound.txt: -------------------------------------------------------------------------------- 1 | It was the end of November, and Holmes and I sat, upon a raw and foggy night, on either side of a blazing fire in our sitting-room in Baker Street. Since the tragic upshot of our visit to Devonshire he had been engaged in two affairs of the utmost importance, in the first of which he had exposed the atrocious conduct of Colonel Upwood in connection with the famous card scandal of the Nonpareil Club, while in the second he had defended the unfortunate Mme. Montpensier from the charge of murder which hung over her in connection with the death of her step-daughter, Mlle. Carére, the young lady who, as it will be remembered, was found six months later alive and married in New York. My friend was in excellent spirits over the success which had attended a succession of difficult and important cases, so that I was able to induce him to discuss the details of the Baskerville mystery. I had waited patiently for the opportunity for I was aware that he would never permit cases to overlap, and that his clear and logical mind would not be drawn from its present work to dwell upon memories of the past. Sir Henry and Dr. Mortimer were, however, in London, on their way to that long voyage which had been recommended for the restoration of his shattered nerves. They had called upon us that very afternoon, so that it was natural that the subject should come up for discussion. 2 | 3 | “The whole course of events,” said Holmes, “from the point of view of the man who called himself Stapleton was simple and direct, although to us, who had no means in the beginning of knowing the motives of his actions and could only learn part of the facts, it all appeared exceedingly complex. I have had the advantage of two conversations with Mrs. Stapleton, and the case has now been so entirely cleared up that I am not aware that there is anything which has remained a secret to us. You will find a few notes upon the matter under the heading B in my indexed list of cases.” 4 | 5 | “Perhaps you would kindly give me a sketch of the course of events from memory.” 6 | 7 | “Certainly, though I cannot guarantee that I carry all the facts in my mind. Intense mental concentration has a curious way of blotting out what has passed. The barrister who has his case at his fingers’ ends and is able to argue with an expert upon his own subject finds that a week or two of the courts will drive it all out of his head once more. So each of my cases displaces the last, and Mlle. Carére has blurred my recollection of Baskerville Hall. Tomorrow some other little problem may be submitted to my notice which will in turn dispossess the fair French lady and the infamous Upwood. So far as the case of the hound goes, however, I will give you the course of events as nearly as I can, and you will suggest anything which I may have forgotten. 8 | 9 | “My inquiries show beyond all question that the family portrait did not lie, and that this fellow was indeed a Baskerville. He was a son of that Rodger Baskerville, the younger brother of Sir Charles, who fled with a sinister reputation to South America, where he was said to have died unmarried. He did, as a matter of fact, marry, and had one child, this fellow, whose real name is the same as his father’s. He married Beryl Garcia, one of the beauties of Costa Rica, and, having purloined a considerable sum of public money, he changed his name to Vandeleur and fled to England, where he established a school in the east of Yorkshire. His reason for attempting this special line of business was that he had struck up an acquaintance with a consumptive tutor upon the voyage home, and that he had used this man’s ability to make the undertaking a success. Fraser, the tutor, died however, and the school which had begun well sank from disrepute into infamy. The Vandeleurs found it convenient to change their name to Stapleton, and he brought the remains of his fortune, his schemes for the future, and his taste for entomology to the south of England. I learned at the British Museum that he was a recognized authority upon the subject, and that the name of Vandeleur has been permanently attached to a certain moth which he had, in his Yorkshire days, been the first to describe. 10 | 11 | “We now come to that portion of his life which has proved to be of such intense interest to us. The fellow had evidently made inquiry and found that only two lives intervened between him and a valuable estate. When he went to Devonshire his plans were, I believe, exceedingly hazy, but that he meant mischief from the first is evident from the way in which he took his wife with him in the character of his sister. The idea of using her as a decoy was clearly already in his mind, though he may not have been certain how the details of his plot were to be arranged. He meant in the end to have the estate, and he was ready to use any tool or run any risk for that end. His first act was to establish himself as near to his ancestral home as he could, and his second was to cultivate a friendship with Sir Charles Baskerville and with the neighbours. 12 | 13 | “The baronet himself told him about the family hound, and so prepared the way for his own death. Stapleton, as I will continue to call him, knew that the old man’s heart was weak and that a shock would kill him. So much he had learned from Dr. Mortimer. He had heard also that Sir Charles was superstitious and had taken this grim legend very seriously. His ingenious mind instantly suggested a way by which the baronet could be done to death, and yet it would be hardly possible to bring home the guilt to the real murderer. 14 | 15 | “Having conceived the idea he proceeded to carry it out with considerable finesse. An ordinary schemer would have been content to work with a savage hound. The use of artificial means to make the creature diabolical was a flash of genius upon his part. The dog he bought in London from Ross and Mangles, the dealers in Fulham Road. It was the strongest and most savage in their possession. He brought it down by the North Devon line and walked a great distance over the moor so as to get it home without exciting any remarks. He had already on his insect hunts learned to penetrate the Grimpen Mire, and so had found a safe hiding-place for the creature. Here he kennelled it and waited his chance. 16 | 17 | “But it was some time coming. The old gentleman could not be decoyed outside of his grounds at night. Several times Stapleton lurked about with his hound, but without avail. It was during these fruitless quests that he, or rather his ally, was seen by peasants, and that the legend of the demon dog received a new confirmation. He had hoped that his wife might lure Sir Charles to his ruin, but here she proved unexpectedly independent. She would not endeavour to entangle the old gentleman in a sentimental attachment which might deliver him over to his enemy. Threats and even, I am sorry to say, blows refused to move her. She would have nothing to do with it, and for a time Stapleton was at a deadlock. 18 | 19 | “He found a way out of his difficulties through the chance that Sir Charles, who had conceived a friendship for him, made him the minister of his charity in the case of this unfortunate woman, Mrs. Laura Lyons. By representing himself as a single man he acquired complete influence over her, and he gave her to understand that in the event of her obtaining a divorce from her husband he would marry her. His plans were suddenly brought to a head by his knowledge that Sir Charles was about to leave the Hall on the advice of Dr. Mortimer, with whose opinion he himself pretended to coincide. He must act at once, or his victim might get beyond his power. He therefore put pressure upon Mrs. Lyons to write this letter, imploring the old man to give her an interview on the evening before his departure for London. He then, by a specious argument, prevented her from going, and so had the chance for which he had waited. 20 | 21 | “Driving back in the evening from Coombe Tracey he was in time to get his hound, to treat it with his infernal paint, and to bring the beast round to the gate at which he had reason to expect that he would find the old gentleman waiting. The dog, incited by its master, sprang over the wicket-gate and pursued the unfortunate baronet, who fled screaming down the yew alley. In that gloomy tunnel it must indeed have been a dreadful sight to see that huge black creature, with its flaming jaws and blazing eyes, bounding after its victim. He fell dead at the end of the alley from heart disease and terror. The hound had kept upon the grassy border while the baronet had run down the path, so that no track but the man’s was visible. On seeing him lying still the creature had probably approached to sniff at him, but finding him dead had turned away again. It was then that it left the print which was actually observed by Dr. Mortimer. The hound was called off and hurried away to its lair in the Grimpen Mire, and a mystery was left which puzzled the authorities, alarmed the countryside, and finally brought the case within the scope of our observation. 22 | 23 | “So much for the death of Sir Charles Baskerville. You perceive the devilish cunning of it, for really it would be almost impossible to make a case against the real murderer. His only accomplice was one who could never give him away, and the grotesque, inconceivable nature of the device only served to make it more effective. Both of the women concerned in the case, Mrs. Stapleton and Mrs. Laura Lyons, were left with a strong suspicion against Stapleton. Mrs. Stapleton knew that he had designs upon the old man, and also of the existence of the hound. Mrs. Lyons knew neither of these things, but had been impressed by the death occurring at the time of an uncancelled appointment which was only known to him. However, both of them were under his influence, and he had nothing to fear from them. The first half of his task was successfully accomplished but the more difficult still remained. 24 | 25 | “It is possible that Stapleton did not know of the existence of an heir in Canada. In any case he would very soon learn it from his friend Dr. Mortimer, and he was told by the latter all details about the arrival of Henry Baskerville. Stapleton’s first idea was that this young stranger from Canada might possibly be done to death in London without coming down to Devonshire at all. He distrusted his wife ever since she had refused to help him in laying a trap for the old man, and he dared not leave her long out of his sight for fear he should lose his influence over her. It was for this reason that he took her to London with him. They lodged, I find, at the Mexborough Private Hotel, in Craven Street, which was actually one of those called upon by my agent in search of evidence. Here he kept his wife imprisoned in her room while he, disguised in a beard, followed Dr. Mortimer to Baker Street and afterwards to the station and to the Northumberland Hotel. His wife had some inkling of his plans; but she had such a fear of her husband—a fear founded upon brutal ill-treatment—that she dare not write to warn the man whom she knew to be in danger. If the letter should fall into Stapleton’s hands her own life would not be safe. Eventually, as we know, she adopted the expedient of cutting out the words which would form the message, and addressing the letter in a disguised hand. It reached the baronet, and gave him the first warning of his danger. 26 | 27 | “It was very essential for Stapleton to get some article of Sir Henry’s attire so that, in case he was driven to use the dog, he might always have the means of setting him upon his track. With characteristic promptness and audacity he set about this at once, and we cannot doubt that the boots or chamber-maid of the hotel was well bribed to help him in his design. By chance, however, the first boot which was procured for him was a new one and, therefore, useless for his purpose. He then had it returned and obtained another—a most instructive incident, since it proved conclusively to my mind that we were dealing with a real hound, as no other supposition could explain this anxiety to obtain an old boot and this indifference to a new one. The more outré and grotesque an incident is the more carefully it deserves to be examined, and the very point which appears to complicate a case is, when duly considered and scientifically handled, the one which is most likely to elucidate it. 28 | 29 | “Then we had the visit from our friends next morning, shadowed always by Stapleton in the cab. From his knowledge of our rooms and of my appearance, as well as from his general conduct, I am inclined to think that Stapleton’s career of crime has been by no means limited to this single Baskerville affair. It is suggestive that during the last three years there have been four considerable burglaries in the west country, for none of which was any criminal ever arrested. The last of these, at Folkestone Court, in May, was remarkable for the cold-blooded pistolling of the page, who surprised the masked and solitary burglar. I cannot doubt that Stapleton recruited his waning resources in this fashion, and that for years he has been a desperate and dangerous man. 30 | 31 | “We had an example of his readiness of resource that morning when he got away from us so successfully, and also of his audacity in sending back my own name to me through the cabman. From that moment he understood that I had taken over the case in London, and that therefore there was no chance for him there. He returned to Dartmoor and awaited the arrival of the baronet.” 32 | 33 | “One moment!” said I. “You have, no doubt, described the sequence of events correctly, but there is one point which you have left unexplained. What became of the hound when its master was in London?” 34 | 35 | “I have given some attention to this matter and it is undoubtedly of importance. There can be no question that Stapleton had a confidant, though it is unlikely that he ever placed himself in his power by sharing all his plans with him. There was an old manservant at Merripit House, whose name was Anthony. His connection with the Stapletons can be traced for several years, as far back as the school-mastering days, so that he must have been aware that his master and mistress were really husband and wife. This man has disappeared and has escaped from the country. It is suggestive that Anthony is not a common name in England, while Antonio is so in all Spanish or Spanish-American countries. The man, like Mrs. Stapleton herself, spoke good English, but with a curious lisping accent. I have myself seen this old man cross the Grimpen Mire by the path which Stapleton had marked out. It is very probable, therefore, that in the absence of his master it was he who cared for the hound, though he may never have known the purpose for which the beast was used. 36 | 37 | “The Stapletons then went down to Devonshire, whither they were soon followed by Sir Henry and you. One word now as to how I stood myself at that time. It may possibly recur to your memory that when I examined the paper upon which the printed words were fastened I made a close inspection for the water-mark. In doing so I held it within a few inches of my eyes, and was conscious of a faint smell of the scent known as white jessamine. There are seventy-five perfumes, which it is very necessary that a criminal expert should be able to distinguish from each other, and cases have more than once within my own experience depended upon their prompt recognition. The scent suggested the presence of a lady, and already my thoughts began to turn towards the Stapletons. Thus I had made certain of the hound, and had guessed at the criminal before ever we went to the west country. 38 | 39 | “It was my game to watch Stapleton. It was evident, however, that I could not do this if I were with you, since he would be keenly on his guard. I deceived everybody, therefore, yourself included, and I came down secretly when I was supposed to be in London. My hardships were not so great as you imagined, though such trifling details must never interfere with the investigation of a case. I stayed for the most part at Coombe Tracey, and only used the hut upon the moor when it was necessary to be near the scene of action. Cartwright had come down with me, and in his disguise as a country boy he was of great assistance to me. I was dependent upon him for food and clean linen. When I was watching Stapleton, Cartwright was frequently watching you, so that I was able to keep my hand upon all the strings. 40 | 41 | “I have already told you that your reports reached me rapidly, being forwarded instantly from Baker Street to Coombe Tracey. They were of great service to me, and especially that one incidentally truthful piece of biography of Stapleton’s. I was able to establish the identity of the man and the woman and knew at last exactly how I stood. The case had been considerably complicated through the incident of the escaped convict and the relations between him and the Barrymores. This also you cleared up in a very effective way, though I had already come to the same conclusions from my own observations. 42 | 43 | “By the time that you discovered me upon the moor I had a complete knowledge of the whole business, but I had not a case which could go to a jury. Even Stapleton’s attempt upon Sir Henry that night which ended in the death of the unfortunate convict did not help us much in proving murder against our man. There seemed to be no alternative but to catch him red-handed, and to do so we had to use Sir Henry, alone and apparently unprotected, as a bait. We did so, and at the cost of a severe shock to our client we succeeded in completing our case and driving Stapleton to his destruction. That Sir Henry should have been exposed to this is, I must confess, a reproach to my management of the case, but we had no means of foreseeing the terrible and paralyzing spectacle which the beast presented, nor could we predict the fog which enabled him to burst upon us at such short notice. We succeeded in our object at a cost which both the specialist and Dr. Mortimer assure me will be a temporary one. A long journey may enable our friend to recover not only from his shattered nerves but also from his wounded feelings. His love for the lady was deep and sincere, and to him the saddest part of all this black business was that he should have been deceived by her. 44 | 45 | “It only remains to indicate the part which she had played throughout. There can be no doubt that Stapleton exercised an influence over her which may have been love or may have been fear, or very possibly both, since they are by no means incompatible emotions. It was, at least, absolutely effective. At his command she consented to pass as his sister, though he found the limits of his power over her when he endeavoured to make her the direct accessory to murder. She was ready to warn Sir Henry so far as she could without implicating her husband, and again and again she tried to do so. Stapleton himself seems to have been capable of jealousy, and when he saw the baronet paying court to the lady, even though it was part of his own plan, still he could not help interrupting with a passionate outburst which revealed the fiery soul which his self-contained manner so cleverly concealed. By encouraging the intimacy he made it certain that Sir Henry would frequently come to Merripit House and that he would sooner or later get the opportunity which he desired. On the day of the crisis, however, his wife turned suddenly against him. She had learned something of the death of the convict, and she knew that the hound was being kept in the outhouse on the evening that Sir Henry was coming to dinner. She taxed her husband with his intended crime, and a furious scene followed in which he showed her for the first time that she had a rival in his love. Her fidelity turned in an instant to bitter hatred, and he saw that she would betray him. He tied her up, therefore, that she might have no chance of warning Sir Henry, and he hoped, no doubt, that when the whole countryside put down the baronet’s death to the curse of his family, as they certainly would do, he could win his wife back to accept an accomplished fact and to keep silent upon what she knew. In this I fancy that in any case he made a miscalculation, and that, if we had not been there, his doom would none the less have been sealed. A woman of Spanish blood does not condone such an injury so lightly. And now, my dear Watson, without referring to my notes, I cannot give you a more detailed account of this curious case. I do not know that anything essential has been left unexplained.” 46 | 47 | “He could not hope to frighten Sir Henry to death as he had done the old uncle with his bogie hound.” 48 | 49 | “The beast was savage and half-starved. If its appearance did not frighten its victim to death, at least it would paralyze the resistance which might be offered.” 50 | 51 | “No doubt. There only remains one difficulty. If Stapleton came into the succession, how could he explain the fact that he, the heir, had been living unannounced under another name so close to the property? How could he claim it without causing suspicion and inquiry?” 52 | 53 | “It is a formidable difficulty, and I fear that you ask too much when you expect me to solve it. The past and the present are within the field of my inquiry, but what a man may do in the future is a hard question to answer. Mrs. Stapleton has heard her husband discuss the problem on several occasions. There were three possible courses. He might claim the property from South America, establish his identity before the British authorities there and so obtain the fortune without ever coming to England at all, or he might adopt an elaborate disguise during the short time that he need be in London; or, again, he might furnish an accomplice with the proofs and papers, putting him in as heir, and retaining a claim upon some proportion of his income. We cannot doubt from what we know of him that he would have found some way out of the difficulty. And now, my dear Watson, we have had some weeks of severe work, and for one evening, I think, we may turn our thoughts into more pleasant channels. I have a box for Les Huguenots. Have you heard the De Reszkes? Might I trouble you then to be ready in half an hour, and we can stop at Marcini’s for a little dinner on the way?” -------------------------------------------------------------------------------- /Introduction to NLP/readme.md: -------------------------------------------------------------------------------- 1 | ## Videos 2 | 3 | [![part 1](https://i.ytimg.com/vi/8Mlc4-3tgzc/mqdefault.jpg)](https://youtu.be/8Mlc4-3tgzc) 4 | [![part 2](https://i.ytimg.com/vi/aOIHiclLDrc/mqdefault.jpg)](https://youtu.be/aOIHiclLDrc) 5 | [![part 3](https://i.ytimg.com/vi/p6yvuST_6oQ/mqdefault.jpg)](https://youtu.be/p6yvuST_6oQ) 6 | [![part 4](https://i.ytimg.com/vi/_Rt4LjasO34/mqdefault.jpg)](https://youtu.be/_Rt4LjasO34) 7 | [![part 5](https://i.ytimg.com/vi/Fn_U2OG1uqI/mqdefault.jpg)](https://youtu.be/Fn_U2OG1uqI) 8 | [![part 6](https://i.ytimg.com/vi/oMd7sMlxYFk/mqdefault.jpg)](https://youtu.be/oMd7sMlxYFk) 9 | [![part 7](https://i.ytimg.com/vi/-Y_tldJX9jk/mqdefault.jpg)](https://youtu.be/-Y_tldJX9jk) 10 | [![part 8](https://i.ytimg.com/vi/pMjT8GIX0co/mqdefault.jpg)](https://youtu.be/pMjT8GIX0co) 11 | [![part 9](https://i.ytimg.com/vi/XO97Uon83Os/mqdefault.jpg)](https://youtu.be/XO97Uon83Os) 12 | -------------------------------------------------------------------------------- /Miscellaneous/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Miscellaneous/0.png -------------------------------------------------------------------------------- /Miscellaneous/Markov_Chain_Simulation.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "language_info": { 4 | "codemirror_mode": { 5 | "name": "ipython", 6 | "version": 3 7 | }, 8 | "file_extension": ".py", 9 | "mimetype": "text/x-python", 10 | "name": "python", 11 | "nbconvert_exporter": "python", 12 | "pygments_lexer": "ipython3", 13 | "version": "3.8.5" 14 | }, 15 | "orig_nbformat": 2, 16 | "kernelspec": { 17 | "name": "python3", 18 | "display_name": "Python 3.8.5 64-bit ('base': conda)", 19 | "metadata": { 20 | "interpreter": { 21 | "hash": "2c81527b5a4384cf19648bf8d6f513a12814ed111bcfa0a54163f8e293289c46" 22 | } 23 | } 24 | } 25 | }, 26 | "nbformat": 4, 27 | "nbformat_minor": 2, 28 | "cells": [ 29 | { 30 | "cell_type": "code", 31 | "execution_count": 1, 32 | "metadata": {}, 33 | "outputs": [], 34 | "source": [ 35 | "import numpy as np" 36 | ] 37 | }, 38 | { 39 | "source": [ 40 | "

A delicious Markov Chain

\n", 41 | "\n", 42 | "" 43 | ], 44 | "cell_type": "markdown", 45 | "metadata": {} 46 | }, 47 | { 48 | "source": [ 49 | "## Burger : 0, Pizza : 1, Hotdog : 2" 50 | ], 51 | "cell_type": "markdown", 52 | "metadata": {} 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 2, 57 | "metadata": {}, 58 | "outputs": [ 59 | { 60 | "output_type": "execute_result", 61 | "data": { 62 | "text/plain": [ 63 | "{0: 'Burger', 1: 'Pizza', 2: 'Hotdog'}" 64 | ] 65 | }, 66 | "metadata": {}, 67 | "execution_count": 2 68 | } 69 | ], 70 | "source": [ 71 | "state = {\n", 72 | " 0 : \"Burger\",\n", 73 | " 1 : \"Pizza\",\n", 74 | " 2 : \"Hotdog\"\n", 75 | "}\n", 76 | "state" 77 | ] 78 | }, 79 | { 80 | "source": [ 81 | "

Transition Matrix

\n", 82 | "\n", 83 | "\n", 84 | "## A_ij = P(X_n = j | X_n-1 = i)" 85 | ], 86 | "cell_type": "markdown", 87 | "metadata": {} 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": 3, 92 | "metadata": {}, 93 | "outputs": [ 94 | { 95 | "output_type": "execute_result", 96 | "data": { 97 | "text/plain": [ 98 | "array([[0.2, 0.6, 0.2],\n", 99 | " [0.3, 0. , 0.7],\n", 100 | " [0.5, 0. , 0.5]])" 101 | ] 102 | }, 103 | "metadata": {}, 104 | "execution_count": 3 105 | } 106 | ], 107 | "source": [ 108 | "A = np.array([[0.2, 0.6, 0.2], [0.3, 0.0, 0.7], [0.5, 0.0, 0.5]])\n", 109 | "A" 110 | ] 111 | }, 112 | { 113 | "source": [ 114 | "

Random Walk on Markov Chain

" 115 | ], 116 | "cell_type": "markdown", 117 | "metadata": {} 118 | }, 119 | { 120 | "source": [ 121 | "n = 15\n", 122 | "start_state = 0\n", 123 | "curr_state = start_state\n", 124 | "print(state[curr_state], \"--->\", end=\" \")\n", 125 | "\n", 126 | "while n-1:\n", 127 | " curr_state = np.random.choice([0, 1, 2], p=A[curr_state])\n", 128 | " print(state[curr_state], \"--->\", end=\" \")\n", 129 | " n-=1\n", 130 | "print(\"stop\")" 131 | ], 132 | "cell_type": "code", 133 | "metadata": {}, 134 | "execution_count": 4, 135 | "outputs": [ 136 | { 137 | "output_type": "stream", 138 | "name": "stdout", 139 | "text": [ 140 | "Burger ---> Hotdog ---> Burger ---> Pizza ---> Hotdog ---> Burger ---> Pizza ---> Burger ---> Hotdog ---> Hotdog ---> Hotdog ---> Hotdog ---> Hotdog ---> Hotdog ---> Burger ---> stop\n" 141 | ] 142 | } 143 | ] 144 | }, 145 | { 146 | "source": [ 147 | "

Approach 1 : Monte Carlo

" 148 | ], 149 | "cell_type": "markdown", 150 | "metadata": {} 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": 5, 155 | "metadata": {}, 156 | "outputs": [ 157 | { 158 | "output_type": "stream", 159 | "name": "stdout", 160 | "text": [ 161 | "π = [0.351828 0.211508 0.436665]\n" 162 | ] 163 | } 164 | ], 165 | "source": [ 166 | "steps = 10**6\n", 167 | "start_state = 0\n", 168 | "curr_state = start_state\n", 169 | "pi = np.array([0, 0, 0])\n", 170 | "pi[start_state] = 1\n", 171 | "\n", 172 | "i = 0\n", 173 | "while iApproach 2 : Repeated Matrix Multiplication" 184 | ], 185 | "cell_type": "markdown", 186 | "metadata": {} 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 6, 191 | "metadata": {}, 192 | "outputs": [ 193 | { 194 | "output_type": "stream", 195 | "name": "stdout", 196 | "text": [ 197 | "A^n = \n [[0.35211268 0.21126761 0.43661972]\n [0.35211268 0.21126761 0.43661972]\n [0.35211268 0.21126761 0.43661972]] \n\nπ = [0.35211268 0.21126761 0.43661972]\n" 198 | ] 199 | } 200 | ], 201 | "source": [ 202 | "steps = 10**3\n", 203 | "A_n = A\n", 204 | "\n", 205 | "i=0\n", 206 | "while iApproach 3 : Finding Left Eigen Vectors" 217 | ], 218 | "cell_type": "markdown", 219 | "metadata": {} 220 | }, 221 | { 222 | "cell_type": "code", 223 | "execution_count": 7, 224 | "metadata": {}, 225 | "outputs": [ 226 | { 227 | "output_type": "stream", 228 | "name": "stdout", 229 | "text": [ 230 | "left eigen vectors = \n", 231 | " [[-0.58746336+0.j 0.16984156+0.35355339j 0.16984156-0.35355339j]\n", 232 | " [-0.35247801+0.j -0.67936622+0.j -0.67936622-0.j ]\n", 233 | " [-0.72845456+0.j 0.50952467-0.35355339j 0.50952467+0.35355339j]] \n", 234 | "\n", 235 | "eigen values = \n", 236 | " [ 1. +0.j -0.15+0.3122499j -0.15-0.3122499j]\n" 237 | ] 238 | } 239 | ], 240 | "source": [ 241 | "import scipy.linalg\n", 242 | "values, left = scipy.linalg.eig(A, right = False, left = True)\n", 243 | "\n", 244 | "print(\"left eigen vectors = \\n\", left, \"\\n\")\n", 245 | "print(\"eigen values = \\n\", values)" 246 | ] 247 | }, 248 | { 249 | "cell_type": "code", 250 | "execution_count": 8, 251 | "metadata": {}, 252 | "outputs": [ 253 | { 254 | "output_type": "execute_result", 255 | "data": { 256 | "text/plain": [ 257 | "[0.3521126760563379, 0.21126760563380304, 0.4366197183098591]" 258 | ] 259 | }, 260 | "metadata": {}, 261 | "execution_count": 8 262 | } 263 | ], 264 | "source": [ 265 | "pi = left[:,0]\n", 266 | "pi_normalized = [(x/np.sum(pi)).real for x in pi]\n", 267 | "pi_normalized" 268 | ] 269 | }, 270 | { 271 | "source": [ 272 | "

P(Pizza --> Hotdog --> Hotdog --> Burger) = ?

\n", 273 | "
\n", 274 | "\n", 275 | "## => P(X_0 = Pizza, X_1 = Hotdog, X_2 = Hotdog, X_3 = Burger)\n", 276 | "## => P(X_0 = Pizza) P(X_1 = Hotdog | X_0 = Pizza) P(X_2 = Hotdog | X_1 = Hotdog) P(X_3 = Burger | X_2 = Hotdog)" 277 | ], 278 | "cell_type": "markdown", 279 | "metadata": {} 280 | }, 281 | { 282 | "cell_type": "code", 283 | "execution_count": 9, 284 | "metadata": {}, 285 | "outputs": [ 286 | { 287 | "output_type": "stream", 288 | "name": "stdout", 289 | "text": [ 290 | "0.03697183098591553\n" 291 | ] 292 | } 293 | ], 294 | "source": [ 295 | "def find_prob(seq, A, pi):\n", 296 | " start_state = seq[0]\n", 297 | " prob = pi[start_state]\n", 298 | " prev_state, curr_state = start_state, start_state\n", 299 | " for i in range(1, len(seq)):\n", 300 | " curr_state = seq[i]\n", 301 | " prob *= A[prev_state][curr_state]\n", 302 | " prev_state = curr_state\n", 303 | " return prob\n", 304 | "\n", 305 | "print(find_prob([1, 2, 2, 0], A, pi_normalized))" 306 | ] 307 | } 308 | ] 309 | } -------------------------------------------------------------------------------- /Miscellaneous/Text_Generation_Tutorial.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "colab": { 8 | "base_uri": "https://localhost:8080/" 9 | }, 10 | "id": "vpmXygg_yoY_", 11 | "outputId": "c4275555-4203-450b-a95a-05ee272949e4" 12 | }, 13 | "outputs": [], 14 | "source": [ 15 | "from transformers import AutoTokenizer, AutoModelForCausalLM\n", 16 | "import torch\n", 17 | "from huggingface_hub import login\n", 18 | "login(token='YOUR_HF_TOKEN')" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": { 24 | "id": "AL7xsdMpvzNa" 25 | }, 26 | "source": [ 27 | "## Load model and tokenizer" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "metadata": { 34 | "colab": { 35 | "base_uri": "https://localhost:8080/", 36 | "height": 176, 37 | "referenced_widgets": [ 38 | "de7c64f08ac44d6c99440b0715946a95", 39 | "16cc667f790b404c998429efd29f3c3b", 40 | "44c66b45fbc143f69087b4186d707686", 41 | "bb953d96938947f59bcedb09d9da265d", 42 | "2d8c7f728e6a46fc9ec33dc8bcf46403", 43 | "a61dfba2af6345abb338698f39921d4b", 44 | "31b7978c8707428684ac4248ff851a81", 45 | "cd84083292304a21a053ef1aad860ae1", 46 | "18fd7e2110a548ff9da6ce1f558dcf29", 47 | "b3eaa6296a7846f7880c1ad79c49ba50", 48 | "7b9fdb818bee4f5f86b2c0e890967622" 49 | ] 50 | }, 51 | "id": "VYBfqmRbv2NS", 52 | "outputId": "7f451803-8f09-48bf-e799-51df4aae3cd0" 53 | }, 54 | "outputs": [], 55 | "source": [ 56 | "# change this to any decoder only LLM\n", 57 | "device = 'cuda:0'\n", 58 | "model = AutoModelForCausalLM.from_pretrained(\"mistralai/Mistral-7B-v0.1\").to(device)\n", 59 | "tokenizer = AutoTokenizer.from_pretrained(\"mistralai/Mistral-7B-v0.1\")" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": { 65 | "id": "8-ZqAx9qzDqb" 66 | }, 67 | "source": [ 68 | "## Greedy Search Decoding" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": 3, 74 | "metadata": { 75 | "id": "NMtTjm24y_dS" 76 | }, 77 | "outputs": [], 78 | "source": [ 79 | "def greedy_decoding(model, text, max_length=10):\n", 80 | " # tokenize the input text\n", 81 | " input_ids = tokenizer.encode(text, return_tensors='pt', add_special_tokens=False).to(device)\n", 82 | "\n", 83 | " with torch.no_grad():\n", 84 | " # loop until the maximum length is reached\n", 85 | " for _ in range(max_length):\n", 86 | " # feed X_{1...t} and get token logits for t+1 th step\n", 87 | " outputs = model(input_ids)\n", 88 | " logits = outputs.logits[:, -1, :]\n", 89 | "\n", 90 | " # find the most likely token\n", 91 | " next_token_id = torch.argmax(logits, dim=-1, keepdim=True).to(device)\n", 92 | "\n", 93 | " # append X_{t+1} to the input sequence\n", 94 | " input_ids = torch.cat((input_ids, next_token_id), dim=-1)\n", 95 | "\n", 96 | " # break if token is generated\n", 97 | " if next_token_id == tokenizer.eos_token_id:\n", 98 | " break\n", 99 | "\n", 100 | " # decode the generated tokens and return the text\n", 101 | " generated_text = tokenizer.decode(input_ids[0], skip_special_tokens=False)\n", 102 | " return generated_text" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 4, 108 | "metadata": { 109 | "colab": { 110 | "base_uri": "https://localhost:8080/" 111 | }, 112 | "id": "K1sx1L2ifHFk", 113 | "outputId": "5c6c2632-639b-461e-be4c-ea7e37de6eb2" 114 | }, 115 | "outputs": [ 116 | { 117 | "name": "stderr", 118 | "output_type": "stream", 119 | "text": [ 120 | "We detected that you are passing `past_key_values` as a tuple and this is deprecated and will be removed in v4.43. Please use an appropriate `Cache` class (https://huggingface.co/docs/transformers/v4.41.3/en/internal/generation_utils#transformers.Cache)\n" 121 | ] 122 | }, 123 | { 124 | "name": "stdout", 125 | "output_type": "stream", 126 | "text": [ 127 | "It rains a lot in the summer, and the weather is very humid.\n", 128 | "---\n", 129 | "Tell me about apples:\n", 130 | "\n", 131 | "- Apples are a good source of fiber, vitamin C, and antioxidants.\n", 132 | "- Apples are a good source of fiber, vitamin C, and antioxidants.\n", 133 | "- Apples are\n" 134 | ] 135 | } 136 | ], 137 | "source": [ 138 | "print(greedy_decoding(model, \"It rains a lot in the\"))\n", 139 | "print(\"---\")\n", 140 | "print(greedy_decoding(model, \"Tell me about apples:\", 50))" 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": { 146 | "id": "lgUsBVmAa5ku" 147 | }, 148 | "source": [ 149 | "## Decoding with Sampling: Top K" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": 5, 155 | "metadata": { 156 | "id": "482bEmmXSVZK" 157 | }, 158 | "outputs": [], 159 | "source": [ 160 | "def sampling_decoding_top_k(model, text, top_k=50, max_length=30):\n", 161 | " # tokenize the input text\n", 162 | " input_ids = tokenizer.encode(text, return_tensors='pt', add_special_tokens=False).to(device)\n", 163 | "\n", 164 | " with torch.no_grad():\n", 165 | " # loop until the maximum length is reached\n", 166 | " for _ in range(max_length):\n", 167 | " # feed X_{1...t} and get token logits for t+1 th step\n", 168 | " outputs = model(input_ids)\n", 169 | " logits = outputs.logits[:, -1, :]\n", 170 | "\n", 171 | " # find top_k tokens\n", 172 | " sorted_logits, sorted_indices = torch.sort(logits, descending=True)\n", 173 | " top_k_logits, top_k_indices = sorted_logits[:, :top_k], sorted_indices[:, :top_k]\n", 174 | "\n", 175 | " # redistribute the probability mass using softmax\n", 176 | " top_k_probs = torch.softmax(top_k_logits, dim=-1)\n", 177 | "\n", 178 | " # randomly sample a token based on the probability distribution\n", 179 | " chosen_idx = torch.multinomial(top_k_probs, num_samples=1).to(device)\n", 180 | " next_token_id = top_k_indices.gather(-1, chosen_idx)\n", 181 | "\n", 182 | " # append X_{t+1} to the input sequence\n", 183 | " input_ids = torch.cat((input_ids, next_token_id), dim=-1)\n", 184 | "\n", 185 | " # break if token is generated\n", 186 | " if next_token_id == tokenizer.eos_token_id:\n", 187 | " break\n", 188 | "\n", 189 | " # decode the generated tokens and return the text\n", 190 | " generated_text = tokenizer.decode(input_ids[0], skip_special_tokens=False)\n", 191 | " return generated_text" 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": 6, 197 | "metadata": { 198 | "colab": { 199 | "base_uri": "https://localhost:8080/" 200 | }, 201 | "id": "b_jZT3WYLRGR", 202 | "outputId": "77e1096a-2589-42c3-e05f-a425e828efd3" 203 | }, 204 | "outputs": [ 205 | { 206 | "name": "stdout", 207 | "output_type": "stream", 208 | "text": [ 209 | "It rains a lot in the monsoon season.\n", 210 | "\n", 211 | "How to wear traditional clothes in the Indian summer:\n", 212 | "\n", 213 | "To protect against the heat in monsoon and sum\n" 214 | ] 215 | } 216 | ], 217 | "source": [ 218 | "print(sampling_decoding_top_k(model, \"It rains a lot in the\"))" 219 | ] 220 | }, 221 | { 222 | "cell_type": "markdown", 223 | "metadata": { 224 | "id": "X8iU_HUtbJeE" 225 | }, 226 | "source": [ 227 | "## Decoding with Sampling: Top P" 228 | ] 229 | }, 230 | { 231 | "cell_type": "code", 232 | "execution_count": 7, 233 | "metadata": { 234 | "id": "xCf7xxqpWCt9" 235 | }, 236 | "outputs": [], 237 | "source": [ 238 | "def sampling_decoding_top_p(model, text, top_p=0.92, max_length=30):\n", 239 | " # tokenize the input text\n", 240 | " input_ids = tokenizer.encode(text, return_tensors='pt', add_special_tokens=False).to(device)\n", 241 | "\n", 242 | " with torch.no_grad():\n", 243 | " # loop until the maximum length is reached\n", 244 | " for _ in range(max_length):\n", 245 | " # feed X_{1...t} and get token logits for t+1 th step\n", 246 | " outputs = model(input_ids)\n", 247 | " logits = outputs.logits[:, -1, :]\n", 248 | "\n", 249 | " # find the minimum set of tokens whose cumulative probability is above the threshold\n", 250 | " sorted_logits, sorted_indices = torch.sort(logits, descending=True)\n", 251 | " sorted_probs = torch.softmax(sorted_logits, dim=-1)\n", 252 | "\n", 253 | " cumulative_prob = torch.cumsum(sorted_probs, dim=-1)\n", 254 | " top_p_num = (cumulative_prob > top_p).nonzero(as_tuple=True)[1][0].item() + 1\n", 255 | "\n", 256 | " top_p_logits, top_p_indices = sorted_logits[:, :top_p_num], sorted_indices[:, :top_p_num]\n", 257 | "\n", 258 | " # redistribute the probability mass using softmax\n", 259 | " top_p_probs = torch.softmax(top_p_logits, dim=-1)\n", 260 | "\n", 261 | " # randomly sample a token based on the probability distribution\n", 262 | " chosen_idx = torch.multinomial(top_p_probs, num_samples=1).to(device)\n", 263 | " next_token_id = top_p_indices.gather(-1, chosen_idx)\n", 264 | "\n", 265 | " # append X_{t+1} to the input sequence\n", 266 | " input_ids = torch.cat((input_ids, next_token_id), dim=-1)\n", 267 | "\n", 268 | " # break if token is generated\n", 269 | " if next_token_id == tokenizer.eos_token_id:\n", 270 | " break\n", 271 | "\n", 272 | " # decode the generated tokens and return the text\n", 273 | " generated_text = tokenizer.decode(input_ids[0], skip_special_tokens=False)\n", 274 | " return generated_text" 275 | ] 276 | }, 277 | { 278 | "cell_type": "code", 279 | "execution_count": 8, 280 | "metadata": { 281 | "colab": { 282 | "base_uri": "https://localhost:8080/" 283 | }, 284 | "id": "UBf9itTwTywB", 285 | "outputId": "8d89f388-8ab7-44a6-8b1c-fdf961e3ddf7" 286 | }, 287 | "outputs": [ 288 | { 289 | "name": "stdout", 290 | "output_type": "stream", 291 | "text": [ 292 | "It rains a lot in the winter and it’s getting worse. The trees\n" 293 | ] 294 | } 295 | ], 296 | "source": [ 297 | "print(sampling_decoding_top_p(model, \"It rains a lot in the\", 0.82, 10))" 298 | ] 299 | }, 300 | { 301 | "cell_type": "markdown", 302 | "metadata": { 303 | "id": "mJkbsxpFbKon" 304 | }, 305 | "source": [ 306 | "## Decoding with Sampling: Temperature" 307 | ] 308 | }, 309 | { 310 | "cell_type": "code", 311 | "execution_count": 9, 312 | "metadata": { 313 | "id": "v8Jf-rLGXWVE" 314 | }, 315 | "outputs": [], 316 | "source": [ 317 | "def sampling_decoding_temperature(model, text, temperature=1, max_length=30):\n", 318 | " # tokenize the input text\n", 319 | " input_ids = tokenizer.encode(text, return_tensors='pt', add_special_tokens=False).to(device)\n", 320 | "\n", 321 | " with torch.no_grad():\n", 322 | " # loop until the maximum length is reached\n", 323 | " for _ in range(max_length):\n", 324 | " # feed X_{1...t} and get token logits for t+1 th step\n", 325 | " outputs = model(input_ids)\n", 326 | " logits = outputs.logits[:, -1, :]\n", 327 | "\n", 328 | " # apply softmax with temperature\n", 329 | " logits = logits / temperature\n", 330 | " probs = torch.softmax(logits, dim=-1)\n", 331 | "\n", 332 | " # sample from the distribution\n", 333 | " next_token_id = torch.multinomial(probs, num_samples=1).to(device)\n", 334 | "\n", 335 | " # append X_{t+1} to the input sequence\n", 336 | " input_ids = torch.cat((input_ids, next_token_id), dim=-1)\n", 337 | "\n", 338 | " # break if token is generated\n", 339 | " if next_token_id == tokenizer.eos_token_id:\n", 340 | " break\n", 341 | "\n", 342 | " # decode the generated tokens and return the text\n", 343 | " generated_text = tokenizer.decode(input_ids[0], skip_special_tokens=False)\n", 344 | " return generated_text" 345 | ] 346 | }, 347 | { 348 | "cell_type": "code", 349 | "execution_count": 10, 350 | "metadata": { 351 | "colab": { 352 | "base_uri": "https://localhost:8080/" 353 | }, 354 | "id": "AWxu2ageYSA1", 355 | "outputId": "afa2c2dc-06c5-4867-b93d-7517964b672a" 356 | }, 357 | "outputs": [ 358 | { 359 | "name": "stdout", 360 | "output_type": "stream", 361 | "text": [ 362 | "It rains a lot in the summer, and the air is cool and moist.\n", 363 | "---\n", 364 | "Tell me about apples: there are more apple trees than can possibly deliver food to humans, yet with the selective breeding of the best trees, we have unlimited apple production. However, individual apples only remain good for a while. No matter what stresses they\n" 365 | ] 366 | } 367 | ], 368 | "source": [ 369 | "print(sampling_decoding_temperature(model, \"It rains a lot in the\", 0.2, 10))\n", 370 | "print(\"---\")\n", 371 | "print(sampling_decoding_temperature(model, \"Tell me about apples:\", 1.0, 50))" 372 | ] 373 | }, 374 | { 375 | "cell_type": "markdown", 376 | "metadata": { 377 | "id": "X-kx4MojcS9G" 378 | }, 379 | "source": [ 380 | "## Beam Search Decoding" 381 | ] 382 | }, 383 | { 384 | "cell_type": "code", 385 | "execution_count": 11, 386 | "metadata": { 387 | "id": "Iw6NgyCUcbsr" 388 | }, 389 | "outputs": [], 390 | "source": [ 391 | "def beam_search_decoding(model, text, num_beams=3, max_length=10):\n", 392 | " # tokenize the input text\n", 393 | " input_ids = tokenizer.encode(text, return_tensors='pt', add_special_tokens=False).to(device)\n", 394 | "\n", 395 | " # initialize the beams\n", 396 | " # list of tuples (token_ids, product of probabilities)\n", 397 | " beams = [(input_ids, 1)]\n", 398 | "\n", 399 | " with torch.no_grad():\n", 400 | " for _ in range(max_length):\n", 401 | " all_candidates = []\n", 402 | "\n", 403 | " for input_ids, prod_prob in beams:\n", 404 | " outputs = model(input_ids)\n", 405 | " logits = outputs.logits[:, -1, :]\n", 406 | "\n", 407 | " # get the probabilities\n", 408 | " probs = torch.softmax(logits, dim=-1)\n", 409 | "\n", 410 | " # select the top num_beams tokens and their probabilities\n", 411 | " top_probs, top_token_ids = torch.topk(probs, num_beams, dim=-1)\n", 412 | "\n", 413 | " for i in range(num_beams):\n", 414 | " next_token_id = top_token_ids[0, i].unsqueeze(0).unsqueeze(0).to(device)\n", 415 | " next_prob = top_probs[0, i].item()\n", 416 | "\n", 417 | " new_input_ids = torch.cat((input_ids, next_token_id), dim=-1)\n", 418 | " new_prod_prob = prod_prob * next_prob\n", 419 | "\n", 420 | " all_candidates.append((new_input_ids, new_prod_prob))\n", 421 | "\n", 422 | " # keep the top num_beams sequences\n", 423 | " beams = sorted(all_candidates, key=lambda x: x[1], reverse=True)[:num_beams]\n", 424 | "\n", 425 | " # break if all sequences in beams end with token\n", 426 | " if all(tokenizer.eos_token_id in beam[0][0] for beam in beams):\n", 427 | " break\n", 428 | "\n", 429 | " # decode the best sequence (the one with the highest prod probability)\n", 430 | " best_sequence = beams[0][0]\n", 431 | " generated_text = tokenizer.decode(best_sequence[0], skip_special_tokens=False)\n", 432 | " return generated_text" 433 | ] 434 | }, 435 | { 436 | "cell_type": "code", 437 | "execution_count": 12, 438 | "metadata": { 439 | "colab": { 440 | "base_uri": "https://localhost:8080/" 441 | }, 442 | "id": "188R_xVdusBx", 443 | "outputId": "b0283b5d-fa11-413d-d5c2-bfbe3e5757ba" 444 | }, 445 | "outputs": [ 446 | { 447 | "name": "stdout", 448 | "output_type": "stream", 449 | "text": [ 450 | "It rains a lot in the Pacific Northwest, so I’m used to\n" 451 | ] 452 | } 453 | ], 454 | "source": [ 455 | "print(beam_search_decoding(model, \"It rains a lot in the\", 3, 10))" 456 | ] 457 | }, 458 | { 459 | "cell_type": "markdown", 460 | "metadata": { 461 | "id": "fHbnCHbjeK43" 462 | }, 463 | "source": [ 464 | "*Note: Parts of the code were written with the help of a Generative AI*" 465 | ] 466 | } 467 | ], 468 | "metadata": { 469 | "accelerator": "GPU", 470 | "colab": { 471 | "gpuType": "A100", 472 | "machine_shape": "hm", 473 | "provenance": [] 474 | }, 475 | "kernelspec": { 476 | "display_name": "Python 3", 477 | "name": "python3" 478 | }, 479 | "language_info": { 480 | "name": "python" 481 | }, 482 | "widgets": { 483 | "application/vnd.jupyter.widget-state+json": { 484 | "16cc667f790b404c998429efd29f3c3b": { 485 | "model_module": "@jupyter-widgets/controls", 486 | "model_module_version": "1.5.0", 487 | "model_name": "HTMLModel", 488 | "state": { 489 | "_dom_classes": [], 490 | "_model_module": "@jupyter-widgets/controls", 491 | "_model_module_version": "1.5.0", 492 | "_model_name": "HTMLModel", 493 | "_view_count": null, 494 | "_view_module": "@jupyter-widgets/controls", 495 | "_view_module_version": "1.5.0", 496 | "_view_name": "HTMLView", 497 | "description": "", 498 | "description_tooltip": null, 499 | "layout": "IPY_MODEL_a61dfba2af6345abb338698f39921d4b", 500 | "placeholder": "​", 501 | "style": "IPY_MODEL_31b7978c8707428684ac4248ff851a81", 502 | "value": "Loading checkpoint shards: 100%" 503 | } 504 | }, 505 | "18fd7e2110a548ff9da6ce1f558dcf29": { 506 | "model_module": "@jupyter-widgets/controls", 507 | "model_module_version": "1.5.0", 508 | "model_name": "ProgressStyleModel", 509 | "state": { 510 | "_model_module": "@jupyter-widgets/controls", 511 | "_model_module_version": "1.5.0", 512 | "_model_name": "ProgressStyleModel", 513 | "_view_count": null, 514 | "_view_module": "@jupyter-widgets/base", 515 | "_view_module_version": "1.2.0", 516 | "_view_name": "StyleView", 517 | "bar_color": null, 518 | "description_width": "" 519 | } 520 | }, 521 | "2d8c7f728e6a46fc9ec33dc8bcf46403": { 522 | "model_module": "@jupyter-widgets/base", 523 | "model_module_version": "1.2.0", 524 | "model_name": "LayoutModel", 525 | "state": { 526 | "_model_module": "@jupyter-widgets/base", 527 | "_model_module_version": "1.2.0", 528 | "_model_name": "LayoutModel", 529 | "_view_count": null, 530 | "_view_module": "@jupyter-widgets/base", 531 | "_view_module_version": "1.2.0", 532 | "_view_name": "LayoutView", 533 | "align_content": null, 534 | "align_items": null, 535 | "align_self": null, 536 | "border": null, 537 | "bottom": null, 538 | "display": null, 539 | "flex": null, 540 | "flex_flow": null, 541 | "grid_area": null, 542 | "grid_auto_columns": null, 543 | "grid_auto_flow": null, 544 | "grid_auto_rows": null, 545 | "grid_column": null, 546 | "grid_gap": null, 547 | "grid_row": null, 548 | "grid_template_areas": null, 549 | "grid_template_columns": null, 550 | "grid_template_rows": null, 551 | "height": null, 552 | "justify_content": null, 553 | "justify_items": null, 554 | "left": null, 555 | "margin": null, 556 | "max_height": null, 557 | "max_width": null, 558 | "min_height": null, 559 | "min_width": null, 560 | "object_fit": null, 561 | "object_position": null, 562 | "order": null, 563 | "overflow": null, 564 | "overflow_x": null, 565 | "overflow_y": null, 566 | "padding": null, 567 | "right": null, 568 | "top": null, 569 | "visibility": null, 570 | "width": null 571 | } 572 | }, 573 | "31b7978c8707428684ac4248ff851a81": { 574 | "model_module": "@jupyter-widgets/controls", 575 | "model_module_version": "1.5.0", 576 | "model_name": "DescriptionStyleModel", 577 | "state": { 578 | "_model_module": "@jupyter-widgets/controls", 579 | "_model_module_version": "1.5.0", 580 | "_model_name": "DescriptionStyleModel", 581 | "_view_count": null, 582 | "_view_module": "@jupyter-widgets/base", 583 | "_view_module_version": "1.2.0", 584 | "_view_name": "StyleView", 585 | "description_width": "" 586 | } 587 | }, 588 | "44c66b45fbc143f69087b4186d707686": { 589 | "model_module": "@jupyter-widgets/controls", 590 | "model_module_version": "1.5.0", 591 | "model_name": "FloatProgressModel", 592 | "state": { 593 | "_dom_classes": [], 594 | "_model_module": "@jupyter-widgets/controls", 595 | "_model_module_version": "1.5.0", 596 | "_model_name": "FloatProgressModel", 597 | "_view_count": null, 598 | "_view_module": "@jupyter-widgets/controls", 599 | "_view_module_version": "1.5.0", 600 | "_view_name": "ProgressView", 601 | "bar_style": "success", 602 | "description": "", 603 | "description_tooltip": null, 604 | "layout": "IPY_MODEL_cd84083292304a21a053ef1aad860ae1", 605 | "max": 2, 606 | "min": 0, 607 | "orientation": "horizontal", 608 | "style": "IPY_MODEL_18fd7e2110a548ff9da6ce1f558dcf29", 609 | "value": 2 610 | } 611 | }, 612 | "7b9fdb818bee4f5f86b2c0e890967622": { 613 | "model_module": "@jupyter-widgets/controls", 614 | "model_module_version": "1.5.0", 615 | "model_name": "DescriptionStyleModel", 616 | "state": { 617 | "_model_module": "@jupyter-widgets/controls", 618 | "_model_module_version": "1.5.0", 619 | "_model_name": "DescriptionStyleModel", 620 | "_view_count": null, 621 | "_view_module": "@jupyter-widgets/base", 622 | "_view_module_version": "1.2.0", 623 | "_view_name": "StyleView", 624 | "description_width": "" 625 | } 626 | }, 627 | "a61dfba2af6345abb338698f39921d4b": { 628 | "model_module": "@jupyter-widgets/base", 629 | "model_module_version": "1.2.0", 630 | "model_name": "LayoutModel", 631 | "state": { 632 | "_model_module": "@jupyter-widgets/base", 633 | "_model_module_version": "1.2.0", 634 | "_model_name": "LayoutModel", 635 | "_view_count": null, 636 | "_view_module": "@jupyter-widgets/base", 637 | "_view_module_version": "1.2.0", 638 | "_view_name": "LayoutView", 639 | "align_content": null, 640 | "align_items": null, 641 | "align_self": null, 642 | "border": null, 643 | "bottom": null, 644 | "display": null, 645 | "flex": null, 646 | "flex_flow": null, 647 | "grid_area": null, 648 | "grid_auto_columns": null, 649 | "grid_auto_flow": null, 650 | "grid_auto_rows": null, 651 | "grid_column": null, 652 | "grid_gap": null, 653 | "grid_row": null, 654 | "grid_template_areas": null, 655 | "grid_template_columns": null, 656 | "grid_template_rows": null, 657 | "height": null, 658 | "justify_content": null, 659 | "justify_items": null, 660 | "left": null, 661 | "margin": null, 662 | "max_height": null, 663 | "max_width": null, 664 | "min_height": null, 665 | "min_width": null, 666 | "object_fit": null, 667 | "object_position": null, 668 | "order": null, 669 | "overflow": null, 670 | "overflow_x": null, 671 | "overflow_y": null, 672 | "padding": null, 673 | "right": null, 674 | "top": null, 675 | "visibility": null, 676 | "width": null 677 | } 678 | }, 679 | "b3eaa6296a7846f7880c1ad79c49ba50": { 680 | "model_module": "@jupyter-widgets/base", 681 | "model_module_version": "1.2.0", 682 | "model_name": "LayoutModel", 683 | "state": { 684 | "_model_module": "@jupyter-widgets/base", 685 | "_model_module_version": "1.2.0", 686 | "_model_name": "LayoutModel", 687 | "_view_count": null, 688 | "_view_module": "@jupyter-widgets/base", 689 | "_view_module_version": "1.2.0", 690 | "_view_name": "LayoutView", 691 | "align_content": null, 692 | "align_items": null, 693 | "align_self": null, 694 | "border": null, 695 | "bottom": null, 696 | "display": null, 697 | "flex": null, 698 | "flex_flow": null, 699 | "grid_area": null, 700 | "grid_auto_columns": null, 701 | "grid_auto_flow": null, 702 | "grid_auto_rows": null, 703 | "grid_column": null, 704 | "grid_gap": null, 705 | "grid_row": null, 706 | "grid_template_areas": null, 707 | "grid_template_columns": null, 708 | "grid_template_rows": null, 709 | "height": null, 710 | "justify_content": null, 711 | "justify_items": null, 712 | "left": null, 713 | "margin": null, 714 | "max_height": null, 715 | "max_width": null, 716 | "min_height": null, 717 | "min_width": null, 718 | "object_fit": null, 719 | "object_position": null, 720 | "order": null, 721 | "overflow": null, 722 | "overflow_x": null, 723 | "overflow_y": null, 724 | "padding": null, 725 | "right": null, 726 | "top": null, 727 | "visibility": null, 728 | "width": null 729 | } 730 | }, 731 | "bb953d96938947f59bcedb09d9da265d": { 732 | "model_module": "@jupyter-widgets/controls", 733 | "model_module_version": "1.5.0", 734 | "model_name": "HTMLModel", 735 | "state": { 736 | "_dom_classes": [], 737 | "_model_module": "@jupyter-widgets/controls", 738 | "_model_module_version": "1.5.0", 739 | "_model_name": "HTMLModel", 740 | "_view_count": null, 741 | "_view_module": "@jupyter-widgets/controls", 742 | "_view_module_version": "1.5.0", 743 | "_view_name": "HTMLView", 744 | "description": "", 745 | "description_tooltip": null, 746 | "layout": "IPY_MODEL_b3eaa6296a7846f7880c1ad79c49ba50", 747 | "placeholder": "​", 748 | "style": "IPY_MODEL_7b9fdb818bee4f5f86b2c0e890967622", 749 | "value": " 2/2 [00:04<00:00,  2.24s/it]" 750 | } 751 | }, 752 | "cd84083292304a21a053ef1aad860ae1": { 753 | "model_module": "@jupyter-widgets/base", 754 | "model_module_version": "1.2.0", 755 | "model_name": "LayoutModel", 756 | "state": { 757 | "_model_module": "@jupyter-widgets/base", 758 | "_model_module_version": "1.2.0", 759 | "_model_name": "LayoutModel", 760 | "_view_count": null, 761 | "_view_module": "@jupyter-widgets/base", 762 | "_view_module_version": "1.2.0", 763 | "_view_name": "LayoutView", 764 | "align_content": null, 765 | "align_items": null, 766 | "align_self": null, 767 | "border": null, 768 | "bottom": null, 769 | "display": null, 770 | "flex": null, 771 | "flex_flow": null, 772 | "grid_area": null, 773 | "grid_auto_columns": null, 774 | "grid_auto_flow": null, 775 | "grid_auto_rows": null, 776 | "grid_column": null, 777 | "grid_gap": null, 778 | "grid_row": null, 779 | "grid_template_areas": null, 780 | "grid_template_columns": null, 781 | "grid_template_rows": null, 782 | "height": null, 783 | "justify_content": null, 784 | "justify_items": null, 785 | "left": null, 786 | "margin": null, 787 | "max_height": null, 788 | "max_width": null, 789 | "min_height": null, 790 | "min_width": null, 791 | "object_fit": null, 792 | "object_position": null, 793 | "order": null, 794 | "overflow": null, 795 | "overflow_x": null, 796 | "overflow_y": null, 797 | "padding": null, 798 | "right": null, 799 | "top": null, 800 | "visibility": null, 801 | "width": null 802 | } 803 | }, 804 | "de7c64f08ac44d6c99440b0715946a95": { 805 | "model_module": "@jupyter-widgets/controls", 806 | "model_module_version": "1.5.0", 807 | "model_name": "HBoxModel", 808 | "state": { 809 | "_dom_classes": [], 810 | "_model_module": "@jupyter-widgets/controls", 811 | "_model_module_version": "1.5.0", 812 | "_model_name": "HBoxModel", 813 | "_view_count": null, 814 | "_view_module": "@jupyter-widgets/controls", 815 | "_view_module_version": "1.5.0", 816 | "_view_name": "HBoxView", 817 | "box_style": "", 818 | "children": [ 819 | "IPY_MODEL_16cc667f790b404c998429efd29f3c3b", 820 | "IPY_MODEL_44c66b45fbc143f69087b4186d707686", 821 | "IPY_MODEL_bb953d96938947f59bcedb09d9da265d" 822 | ], 823 | "layout": "IPY_MODEL_2d8c7f728e6a46fc9ec33dc8bcf46403" 824 | } 825 | } 826 | } 827 | } 828 | }, 829 | "nbformat": 4, 830 | "nbformat_minor": 0 831 | } 832 | -------------------------------------------------------------------------------- /Miscellaneous/mat2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Miscellaneous/mat2.png -------------------------------------------------------------------------------- /Miscellaneous/monte_carlo.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import random 3 | import copy 4 | 5 | org_deck = [ 6 | 'AS', '2S', '3S', '4S', '5S', '6S', '7S', '8S', '9S', '10S', 'JS', 'QS', 'KS', 7 | 'AD', '2D', '3D', '4D', '5D', '6D', '7D', '8D', '9D', '10D', 'JD', 'QD', 'KD', 8 | 'AC', '2C', '3C', '4C', '5C', '6C', '7C', '8C', '9C', '10C', 'JC', 'QC', 'KC', 9 | 'AH', '2H', '3H', '4H', '5H', '6H', '7H', '8H', '9H', '10H', 'JH', 'QH', 'KH', 10 | ] 11 | 12 | 13 | ''' Q1. What is the probability that at least 2 Kings will appear 14 | next to each other in the shuffled deck? ''' 15 | 16 | def KingKing(deck): 17 | for i in range(len(deck)-1): 18 | if deck[i][0] == 'K' and deck[i+1][0] == 'K': 19 | return True 20 | 21 | def MonteCarlo1(n): 22 | res = 0 23 | for _ in range(n): 24 | deck = copy.deepcopy(org_deck) 25 | random.shuffle(deck) 26 | if KingKing(deck): res += 1 27 | print(res*100/n) 28 | 29 | for i in range(1, 7): 30 | MonteCarlo(10**i) 31 | 32 | ''' 33 | output: 34 | 40.0 35 | 17.0 36 | 20.6 37 | 22.15 38 | 21.645 39 | 21.7206 40 | ''' 41 | 42 | 43 | ''' Q2. What is the probability that at least one King and one Queen 44 | will be next to each other or one card away? ''' 45 | 46 | def KingQueen(deck): 47 | n = len(deck) 48 | for i in range(n-1): 49 | if deck[i][0] + deck[i+1][0] in ['KQ', 'QK']: 50 | return True 51 | if i!=n-2: 52 | if deck[i][0] + deck[i+2][0] in ['KQ', 'QK']: 53 | return True 54 | 55 | def MonteCarlo2(n): 56 | res = 0 57 | for _ in range(n): 58 | deck = copy.deepcopy(org_deck) 59 | random.shuffle(deck) 60 | if KingQueen(deck): res += 1 61 | print(res*100/n) 62 | 63 | for i in range(1, 7): 64 | MonteCarlo2(10**i) 65 | 66 | ''' 67 | output: 68 | 40.0 69 | 73.0 70 | 71.7 71 | 73.35 72 | 73.510 73 | 73.5967 74 | ''' 75 | -------------------------------------------------------------------------------- /Python Tutorials/Multiprocessing/downloader.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import time 3 | import multiprocessing 4 | from PIL import Image 5 | from functools import partial 6 | 7 | url_list = ["https://cdn.pixabay.com/photo/2015/01/28/23/34/mountains-615428_960_720.jpg", 8 | "https://cdn.pixabay.com/photo/2013/08/28/00/54/field-176602_960_720.jpg", 9 | "https://cdn.pixabay.com/photo/2016/03/09/09/31/buildings-1245842_960_720.jpg", 10 | "https://cdn.pixabay.com/photo/2020/02/01/22/10/house-4811590_960_720.jpg", 11 | "https://cdn.pixabay.com/photo/2017/05/27/22/33/morocco-2349647_960_720.jpg", 12 | "https://cdn.pixabay.com/photo/2019/10/23/18/32/freudenberg-4572410_960_720.jpg", 13 | "https://cdn.pixabay.com/photo/2019/10/15/19/00/alpine-4552654_960_720.jpg", 14 | "https://cdn.pixabay.com/photo/2020/04/02/22/09/santorini-4996846_960_720.jpg", 15 | "https://cdn.pixabay.com/photo/2018/04/16/16/16/sunset-3325080_960_720.jpg", 16 | "https://cdn.pixabay.com/photo/2013/10/02/23/03/mountains-190055_960_720.jpg", 17 | "https://cdn.pixabay.com/photo/2016/01/08/18/00/antelope-canyon-1128815_960_720.jpg", 18 | "https://cdn.pixabay.com/photo/2018/01/14/23/12/nature-3082832_960_720.jpg", 19 | "https://cdn.pixabay.com/photo/2017/02/19/15/28/sunset-2080072_960_720.jpg", 20 | "https://cdn.pixabay.com/photo/2018/08/21/23/29/fog-3622519_960_720.jpg", 21 | "https://cdn.pixabay.com/photo/2017/03/29/15/18/tianjin-2185510_960_720.jpg", 22 | "https://cdn.pixabay.com/photo/2017/03/29/11/29/nepal-2184940_960_720.jpg", 23 | "https://cdn.pixabay.com/photo/2016/10/14/19/21/canyon-1740973_960_720.jpg", 24 | "https://cdn.pixabay.com/photo/2015/03/18/09/31/prairie-679014_960_720.jpg", 25 | "https://cdn.pixabay.com/photo/2013/10/09/02/26/bridge-192982_960_720.jpg", 26 | "https://cdn.pixabay.com/photo/2012/02/23/08/38/rocks-15712_960_720.jpg"] 27 | 28 | def download(url_list): 29 | for url in url_list: 30 | response = requests.get(url) 31 | file_name = url.split('/')[-1] 32 | file = open('images/'+file_name, "wb") 33 | file.write(response.content) 34 | file.close() 35 | 36 | image = Image.open('images/'+file_name) 37 | image = image.convert('L') 38 | image.save('images/'+file_name) 39 | print(file_name, "DONE!") 40 | 41 | def download_multi(url, dir_path=None): 42 | response = requests.get(url) 43 | file_name = url.split('/')[-1] 44 | file = open(dir_path+file_name, "wb") 45 | file.write(response.content) 46 | file.close() 47 | 48 | image = Image.open(dir_path+file_name) 49 | image = image.convert('L') 50 | image.save(dir_path+file_name) 51 | print(file_name, "DONE!") 52 | 53 | 54 | if __name__ == "__main__": 55 | # singleprocessing 56 | st = time.time() 57 | download(url_list) 58 | en = time.time() 59 | print("time taken = ", en-st, "\n") 60 | 61 | # multiprocessing 62 | st = time.time() 63 | results = None 64 | folder = "images/" 65 | with multiprocessing.Pool(processes=10) as pool: 66 | results = pool.map(partial(download_multi, dir_path = folder), url_list) 67 | pool.close() 68 | en = time.time() 69 | print("time taken = ", en-st, "\n") 70 | -------------------------------------------------------------------------------- /Python Tutorials/Multiprocessing/multi.py: -------------------------------------------------------------------------------- 1 | import multiprocessing 2 | import time 3 | 4 | def counter1(num): 5 | cnt = 0 6 | for _ in range(num): 7 | cnt += 1 8 | print("counter1 done!") 9 | 10 | def counter2(num): 11 | cnt = 0 12 | for _ in range(0, num, 2): 13 | cnt += 1 14 | print("counter2 done!") 15 | 16 | if __name__ == "__main__": 17 | N = 2 * 10**8 18 | 19 | # singleprocessing 20 | st = time.time() 21 | counter1(N) 22 | counter2(N) 23 | en = time.time() 24 | print("time taken = ", en-st) 25 | 26 | # multiprocessing 27 | st = time.time() 28 | p1 = multiprocessing.Process(target=counter1, args=(N, )) 29 | p2 = multiprocessing.Process(target=counter2, args=(N, )) 30 | 31 | p1.start() 32 | p2.start() 33 | 34 | p1.join() 35 | p2.join() 36 | en = time.time() 37 | print("time taken = ", en-st) 38 | -------------------------------------------------------------------------------- /Python Tutorials/Multiprocessing/prime.py: -------------------------------------------------------------------------------- 1 | import math 2 | import multiprocessing 3 | import time 4 | 5 | def check_prime(N): 6 | arr = [True]*N 7 | for num in range(N): 8 | if num<2: 9 | arr[num] = False 10 | elif num>2: 11 | for j in range(2, math.ceil(math.sqrt(num))+1): 12 | if num%j==0: 13 | arr[num] = False 14 | break 15 | return arr 16 | 17 | def check_prime_multi(num): 18 | if num<2: 19 | return num, False 20 | elif num==2: 21 | return num, True 22 | else: 23 | for j in range(2, math.ceil(math.sqrt(num))+1): 24 | if num%j==0: 25 | return num, False 26 | return num, True 27 | 28 | if __name__ == "__main__": 29 | N = 2 * 10**6 30 | 31 | # singleprocessing 32 | st = time.time() 33 | results = check_prime(N) 34 | print(results[:30]) 35 | en = time.time() 36 | print("time taken = ", en-st) 37 | 38 | # multiprocessing 39 | st = time.time() 40 | num_arr = range(N) 41 | results = [] 42 | with multiprocessing.Pool(processes=10) as pool: 43 | results = pool.map(check_prime_multi, num_arr) 44 | pool.close() 45 | print(results[:30]) 46 | en = time.time() 47 | print("time taken = ", en-st) 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NormalizedNerd 2 | Extrapolate your Machine Learning Abilities! 3 | 4 | ### *Click on the banner to visit my channel* 5 | [![IMAGE ALT TEXT HERE](https://pbs.twimg.com/profile_banners/1105409193572392960/1552386021/1500x500)](https://www.youtube.com/NormalizedNerd) 6 | -------------------------------------------------------------------------------- /Sklearn-Evaluation Metrics/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Sklearn-Evaluation Metrics/1.png -------------------------------------------------------------------------------- /Sklearn-Evaluation Metrics/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Sklearn-Evaluation Metrics/2.png -------------------------------------------------------------------------------- /Sklearn-Evaluation Metrics/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Sklearn-Evaluation Metrics/3.png -------------------------------------------------------------------------------- /Sklearn-Evaluation Metrics/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Sklearn-Evaluation Metrics/4.jpg -------------------------------------------------------------------------------- /Sklearn-Evaluation Metrics/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Suji04/NormalizedNerd/c494a92d831afe411c1a6867f772f435c2ff4255/Sklearn-Evaluation Metrics/5.png -------------------------------------------------------------------------------- /Sklearn-Evaluation Metrics/Evaluation Metrics.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

R-squared

\n", 8 | "\n", 9 | "

Adjusted R-squared

\n", 10 | "" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 1, 16 | "metadata": {}, 17 | "outputs": [ 18 | { 19 | "name": "stdout", 20 | "output_type": "stream", 21 | "text": [ 22 | " OLS Regression Results \n", 23 | "==============================================================================\n", 24 | "Dep. Variable: num_articles R-squared: 0.818\n", 25 | "Model: OLS Adj. R-squared: 0.792\n", 26 | "Method: Least Squares F-statistic: 31.55\n", 27 | "Date: Thu, 16 Jan 2020 Prob (F-statistic): 0.000802\n", 28 | "Time: 00:58:11 Log-Likelihood: -7.0819\n", 29 | "No. Observations: 9 AIC: 18.16\n", 30 | "Df Residuals: 7 BIC: 18.56\n", 31 | "Df Model: 1 \n", 32 | "Covariance Type: nonrobust \n", 33 | "==============================================================================\n", 34 | " coef std err t P>|t| [0.025 0.975]\n", 35 | "------------------------------------------------------------------------------\n", 36 | "const 2.7345 0.672 4.072 0.005 1.147 4.322\n", 37 | "free_time 0.0441 0.008 5.617 0.001 0.026 0.063\n", 38 | "==============================================================================\n", 39 | "Omnibus: 1.127 Durbin-Watson: 2.415\n", 40 | "Prob(Omnibus): 0.569 Jarque-Bera (JB): 0.791\n", 41 | "Skew: -0.450 Prob(JB): 0.673\n", 42 | "Kurtosis: 1.860 Cond. No. 286.\n", 43 | "==============================================================================\n", 44 | "\n", 45 | "Warnings:\n", 46 | "[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n" 47 | ] 48 | }, 49 | { 50 | "name": "stderr", 51 | "output_type": "stream", 52 | "text": [ 53 | "C:\\Users\\Admin\\Anaconda3\\lib\\site-packages\\scipy\\stats\\stats.py:1394: UserWarning: kurtosistest only valid for n>=20 ... continuing anyway, n=9\n", 54 | " \"anyway, n=%i\" % int(n))\n" 55 | ] 56 | }, 57 | { 58 | "data": { 59 | "text/plain": [ 60 | "0 8.022599\n", 61 | "1 7.581921\n", 62 | "2 7.141243\n", 63 | "3 6.700565\n", 64 | "4 6.259887\n", 65 | "5 6.480226\n", 66 | "6 5.378531\n", 67 | "7 4.937853\n", 68 | "8 4.497175\n", 69 | "dtype: float64" 70 | ] 71 | }, 72 | "execution_count": 1, 73 | "metadata": {}, 74 | "output_type": "execute_result" 75 | } 76 | ], 77 | "source": [ 78 | "from pandas import DataFrame\n", 79 | "import statsmodels.api as sm\n", 80 | "import numpy as np\n", 81 | "\n", 82 | "data = {\n", 83 | " 'month': [12,11,10,9,8,7,6,5,4],\n", 84 | " 'free_time': [120,110,100,90,80,85,60,50,40],\n", 85 | " 'num_videos': [8,8,7,6,6,7,6,4,5]\n", 86 | " }\n", 87 | "\n", 88 | "df = DataFrame(data, columns=['month','free_time', 'num_videos']) \n", 89 | "\n", 90 | "X = df[['free_time']] \n", 91 | "Y = df['num_videos']\n", 92 | "X = sm.add_constant(X) \n", 93 | "\n", 94 | "model = sm.OLS(Y, X).fit()\n", 95 | "predictions = model.predict(X) \n", 96 | "\n", 97 | "print_model = model.summary()\n", 98 | "print(print_model)\n", 99 | "predictions" 100 | ] 101 | }, 102 | { 103 | "cell_type": "markdown", 104 | "metadata": {}, 105 | "source": [ 106 | "
\n", 107 | "\n", 108 | "\n", 109 | "
\n", 110 | "\n", 111 | "
\n", 112 | "" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": 2, 118 | "metadata": {}, 119 | "outputs": [ 120 | { 121 | "name": "stdout", 122 | "output_type": "stream", 123 | "text": [ 124 | "MSE:0.28248587570621464\n", 125 | "RMSE:0.5314940034527338\n", 126 | "MSLE:0.007041391001511214\n", 127 | "RMSLE:0.08391299661858831\n", 128 | "MAE:0.45825486503452534\n" 129 | ] 130 | } 131 | ], 132 | "source": [ 133 | "from sklearn.metrics import mean_squared_error, mean_squared_log_error, mean_absolute_error\n", 134 | "print(\"MSE:\"+str(mean_squared_error(predictions, Y)))\n", 135 | "print(\"RMSE:\"+str(np.sqrt(mean_squared_error(predictions, Y))))\n", 136 | "print(\"MSLE:\"+str(mean_squared_log_error(predictions, Y)))\n", 137 | "print(\"RMSLE:\"+str(np.sqrt(mean_squared_log_error(predictions, Y))))\n", 138 | "print(\"MAE:\"+str(mean_absolute_error(predictions, Y)))" 139 | ] 140 | } 141 | ], 142 | "metadata": { 143 | "kernelspec": { 144 | "display_name": "Python 3", 145 | "language": "python", 146 | "name": "python3" 147 | }, 148 | "language_info": { 149 | "codemirror_mode": { 150 | "name": "ipython", 151 | "version": 3 152 | }, 153 | "file_extension": ".py", 154 | "mimetype": "text/x-python", 155 | "name": "python", 156 | "nbconvert_exporter": "python", 157 | "pygments_lexer": "ipython3", 158 | "version": "3.6.5" 159 | } 160 | }, 161 | "nbformat": 4, 162 | "nbformat_minor": 2 163 | } 164 | --------------------------------------------------------------------------------