<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tuyishimire claudine</title>
    <description>The latest articles on DEV Community by Tuyishimire claudine (@tuyishimire_claudine_a7c9).</description>
    <link>https://dev.to/tuyishimire_claudine_a7c9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4151843%2Fd009d1ba-4c66-42e9-a8f4-f0b85a62633f.jpg</url>
      <title>DEV Community: Tuyishimire claudine</title>
      <link>https://dev.to/tuyishimire_claudine_a7c9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tuyishimire_claudine_a7c9"/>
    <language>en</language>
    <item>
      <title>The First Time I Studied Computer Vision, a Computer Called My Jerrycan a Candle</title>
      <dc:creator>Tuyishimire claudine</dc:creator>
      <pubDate>Tue, 13 Oct 2026 12:43:59 +0000</pubDate>
      <link>https://dev.to/tuyishimire_claudine_a7c9/the-first-time-i-studied-computer-vision-a-computer-called-my-jerrycan-a-candle-3bnb</link>
      <guid>https://dev.to/tuyishimire_claudine_a7c9/the-first-time-i-studied-computer-vision-a-computer-called-my-jerrycan-a-candle-3bnb</guid>
      <description>&lt;p&gt;This was the first time I ever studied computer vision. I expected it to be simple: you show a computer a photo, and it tells you what is in it. I was so wrong, and honestly, I loved finding out why.&lt;/p&gt;

&lt;p&gt;I spent hours testing real models on market photos. The mistakes taught me far more than the right answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. A photo is only numbers
&lt;/h2&gt;

&lt;p&gt;I started with a photo of a vegetable stall. To me it was tomatoes, onions and little bowls. To the computer it was a grid of 400 rows and 600 columns, with three numbers (red, green and blue) in every square. That is 720,000 numbers for one photo. I stared at that number for a moment. It looks like a picture to us, and to the computer it is a very long list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7aqva7hy13bot8evimfg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7aqva7hy13bot8evimfg.png" alt="Photo of a vegetable stall, which the computer sees as 720,000 numbers" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One pixel I printed was &lt;code&gt;[70 71 37]&lt;/code&gt;. Low numbers mean dark, so it was dark olive. Then I switched off the red channel, and the white parts turned cyan while the red tomatoes almost vanished. That was my "ohhh" moment. Colour is just numbers, and you can change them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbtg8n5sl6oi6onohlauw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbtg8n5sl6oi6onohlauw.png" alt="The same market photo with the red channel removed, so the white parts look cyan" width="799" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. How a computer finds edges
&lt;/h2&gt;

&lt;p&gt;An edge is a place where brightness changes quickly. A small grid called a filter slides across the image and measures that change. Some filters find vertical edges, some find horizontal ones, and some only blur.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foryago77kphr83vg4oq3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foryago77kphr83vg4oq3.png" alt="Four versions of the market photo: grayscale, blur, vertical edges and all edges" width="798" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What impressed me most: in deep learning, nobody designs these filters by hand. The network learns them from data.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Sure and wrong at the same time
&lt;/h2&gt;

&lt;p&gt;Then I tried the classifier. It looked at my market photo and said "banana" with 38.3% confidence. The long green vegetables had fooled it. "Grocery store" came second at 33.3%, and that was the better answer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fur5ncjuol8chlns8dun6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fur5ncjuol8chlns8dun6.png" alt="Bar chart: the classifier's top guess for the market photo is banana at 38.3 percent" width="800" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next I tried something from home: a jerrycan. I searched the full list of 1,000 classes the model knows, and a jerrycan is not on it. I tried "jerrycan", then "jug", then "bucket", and I was curious what it would do. It said "candle". Its second guess, "water jug", was much closer, and I laughed out loud at the first one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgf51fkjb2tua4enexcuh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgf51fkjb2tua4enexcuh.png" alt="Bar chart: the classifier's top guess for the jerrycan photo is candle at 24.1 percent" width="799" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The lesson I will keep: being confident is not the same as being right. The model has to pick something from its list, even when the right answer is not there.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Detection, and the number you choose
&lt;/h2&gt;

&lt;p&gt;A detector draws boxes around objects. At a confidence threshold of 0.4, it found 12 bowls and 1 person in my photo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6mvw3a2bk1fx9692m970.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6mvw3a2bk1fx9692m970.png" alt=" Market photo with boxes around 12 bowls and 1 person at threshold 0.4" width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I lowered the threshold to 0.1, it found 41 objects, and many were wrong. It saw bananas on the green vegetables, and even a chair.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjh60n9rgk34aksy2sljx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjh60n9rgk34aksy2sljx.png" alt="Market photo with 41 boxes, many of them wrong, at threshold 0.1" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I raised it to 0.9, it found nothing at all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmkm6fb2bbw0mzz3so05i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmkm6fb2bbw0mzz3so05i.png" alt="Top part of the market photo with no boxes at threshold 0.9" width="799" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the number you choose changes what the model "sees". It is the same trade-off as in medical screening: catch more cases and accept false alarms, or be strict and miss real ones. The detector also ignored the big green vegetables completely, because it only knows 80 everyday classes.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. What the model outlines, and what it ignores
&lt;/h2&gt;

&lt;p&gt;Segmentation outlines the exact pixels of each object. In my photo, the objects covered only 7% of the image. The other 93% counted as background, because the model outlines only what it recognises.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft77sxwuz1a86ofllum19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft77sxwuz1a86ofllum19.png" alt="Segmentation masks on the bowls next to a black and white map covering 7 percent of the image" width="800" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. When the photo is not perfect
&lt;/h2&gt;

&lt;p&gt;I took a photo with five people and made it harder. In the dark, the detector found 3 people. Blurry, it found 1. Upside down, 1. Shrunk to a tiny size, none. Many of us take photos with phones in poor light, so this is not a rare case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9nyf0gs5oizcru3uaf3x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9nyf0gs5oizcru3uaf3x.png" alt="Five versions of a photo with people: original, very dark, upside down, low resolution and blurry" width="799" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7.My own small mistakes
&lt;/h2&gt;

&lt;p&gt;I also made a few mistakes of my own. For a while my results kept showing the bus from the example, because an earlier cell still held the old image. Waiting for cells to run felt endless some minutes, and once the notebook even refused to save. It was frustrating, but fixing each one taught me something. Now I always check which photo I am really working on.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. What this means for us in Rwanda
&lt;/h2&gt;

&lt;p&gt;Models like these learn mostly from photos from Europe, North America and Asia. Mine mistook a jerrycan for a candle. If we want tools that recognise our crops, our containers and our streets, we need local photos, labelled by people who know them. I find that exciting, because it means we can help build that data.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. What I still don't know
&lt;/h2&gt;

&lt;p&gt;I don't know yet how to train a model on my own photos, or how many photos are enough. I don't know how to tell whether a model is truly good, beyond checking a few examples. And I still can't see why it chose "banana", because I cannot look inside it.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Where I go next
&lt;/h2&gt;

&lt;p&gt;I want to start thinking about which local photos to collect, and teach a model to recognise them.&lt;/p&gt;

&lt;p&gt;If you have tried this too, I would love to hear what your model got wrong.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>computervision</category>
      <category>beginners</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>I Was Lost With Word Embeddings, So I Built My First Example</title>
      <dc:creator>Tuyishimire claudine</dc:creator>
      <pubDate>Wed, 30 Sep 2026 14:36:57 +0000</pubDate>
      <link>https://dev.to/tuyishimire_claudine_a7c9/i-was-lost-with-word-embeddings-so-i-built-my-first-example-3glh</link>
      <guid>https://dev.to/tuyishimire_claudine_a7c9/i-was-lost-with-word-embeddings-so-i-built-my-first-example-3glh</guid>
      <description>&lt;p&gt;When I started learning about Natural Language Processing (NLP), I came across the term word embedding. At first, I was confused about how a computer could understand words.&lt;/p&gt;

&lt;p&gt;As humans, we understand that words have meanings and relationships. For example, we know that king and queen are related, and that cat and dog are both animals. But computers work with numbers. So, how can we make a computer understand words?&lt;/p&gt;

&lt;p&gt;This is where word embeddings come in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a word embedding?
&lt;/h2&gt;

&lt;p&gt;A word embedding is a way of representing words as numbers (vectors) so that a computer can understand the relationships and meanings between words.&lt;/p&gt;

&lt;p&gt;The key idea is that words used in similar contexts get similar numbers. So king and queen end up close together, and cat and dog are close, while cat and table are far apart.&lt;/p&gt;

&lt;p&gt;This matters because older methods, like bag-of-words, treat every word as completely different from every other word. With those methods, "rain" is no closer to "storm" than it is to "table", so the computer misses the meaning. Word embeddings fix this by placing related words near each other, which helps in tasks like search, translation, and sentiment analysis.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does Word2Vec work?
&lt;/h2&gt;

&lt;p&gt;Word2Vec is a technique used to convert words into numerical vectors. It learns these vectors by looking at the context in which words appear.&lt;/p&gt;

&lt;p&gt;The main idea behind Word2Vec is that words used in similar contexts are likely to have similar meanings or relationships. For example, look at these sentences:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I drink coffee every morning.&lt;/p&gt;

&lt;p&gt;I drink tea every morning.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The words coffee and tea are different, but they appear in a very similar context. Both come after the word "drink" and before "every morning."&lt;/p&gt;

&lt;p&gt;Because coffee and tea appear in similar contexts, Word2Vec learns that they are related and gives them similar numerical representations (vectors). It learns this by reading a large amount of text, so nobody has to write the meanings by hand.&lt;/p&gt;

&lt;p&gt;GloVe is another embedding method. It also gives each word a vector, but it learns from how often words appear together across a whole text collection. I used GloVe in my example because a pre-trained version was small, quick to download, and easy to run. Glove allowed me to work with word embeddings in Google Colab and explore how words are represented as vectors and how their relationships can be measured.&lt;/p&gt;

&lt;h2&gt;
  
  
  My example
&lt;/h2&gt;

&lt;p&gt;To see word embeddings in action, I used the gensim library with GloVe, a pre-trained model where every word is a list of 50 numbers. I did not train it myself: I downloaded a version already trained on Wikipedia and news text. I asked it for the words closest to "rain":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;gensim.downloader&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;glove-wiki-gigaword-50&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;most_similar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rain&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;topn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rains: 0.878
torrential: 0.843
winds: 0.833
downpour: 0.801
snow: 0.795
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The scores are cosine similarity: the closer to 1, the more similar the two words are.&lt;/p&gt;

&lt;p&gt;Then I tried the famous analogy: king - man + woman. In the code, &lt;code&gt;positive&lt;/code&gt; words are added and &lt;code&gt;negative&lt;/code&gt; words are subtracted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;most_similar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;positive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;king&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;woman&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;negative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;man&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;topn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;queen&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.852&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I noticed
&lt;/h2&gt;

&lt;p&gt;The five words closest to "rain" were rains, torrential, winds, downpour, and snow. They all make sense, because they are about weather. Even "snow" appears, which shows the model groups words by how they are used, not by exact meaning: rain and snow are different, but they show up in very similar contexts. The model was never given a dictionary, so it learned this only from how words appear together in text.&lt;/p&gt;

&lt;p&gt;The analogy surprised me most. When I did king - man + woman, the model returned "queen," with a similarity score of about 0.85. Seeing a computer solve a word puzzle with math made the idea of word embeddings finally click for me. Not every analogy works this well, though, and embeddings can also pick up biases from the text they learn from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing it on my own field
&lt;/h2&gt;

&lt;p&gt;My research is on rainwater harvesting, so I tested three words from my field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;catchment&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cistern&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;runoff&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;most_similar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;topn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;  &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;catchment&lt;/span&gt;
  &lt;span class="s"&gt;floodplain&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.808&lt;/span&gt;
  &lt;span class="na"&gt;reservoir&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.774&lt;/span&gt;
  &lt;span class="na"&gt;drainage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.768&lt;/span&gt;
  &lt;span class="na"&gt;catchments&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.752&lt;/span&gt;
  &lt;span class="na"&gt;streams&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.747&lt;/span&gt;
&lt;span class="s"&gt;cistern&lt;/span&gt;
  &lt;span class="s"&gt;cisterns&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.804&lt;/span&gt;
  &lt;span class="na"&gt;outfall&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.695&lt;/span&gt;
  &lt;span class="na"&gt;chimney&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.670&lt;/span&gt;
  &lt;span class="na"&gt;earthen&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.655&lt;/span&gt;
  &lt;span class="na"&gt;cavern&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.652&lt;/span&gt;
&lt;span class="s"&gt;runoff&lt;/span&gt;
  &lt;span class="s"&gt;run-off&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.830&lt;/span&gt;
  &lt;span class="na"&gt;landslide&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.675&lt;/span&gt;
  &lt;span class="na"&gt;elections&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.667&lt;/span&gt;
  &lt;span class="na"&gt;reelection&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.660&lt;/span&gt;
  &lt;span class="na"&gt;election&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.659&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Catchment" worked well: all five neighbors are about water, and the scores stay high (0.75 to 0.81). "Cistern" was mixed. Its top neighbor is just the plural "cisterns" (0.804), and the scores then drop to around 0.65 to 0.70, where words like "chimney" and "cavern" appear. "Runoff" was the surprise: apart from its spelling variant "run-off", most of its neighbors are about elections, because a runoff is also a type of vote, and that meaning is common in news text. GloVe gives each word only one vector, so it cannot separate the two meanings. I only tested the small 50-dimension version, but this shows that a general-purpose model can misunderstand words from a specialized field, and that lower scores can be a warning sign.&lt;/p&gt;

&lt;p&gt;"Catchment" worked well, and most neighbors of "cistern" made sense, although "chimney" and "cavern" did not. "Runoff" was the surprise: most of its neighbors are about elections, because a runoff is also a type of vote, and that meaning is common in news text. GloVe gives each word only one vector, so it cannot separate the two meanings. I only tested the small 50-dimension version, but this shows that a general-purpose model can misunderstand words from a specialized field.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Google Colab Notebook
&lt;/h2&gt;

&lt;p&gt;You can find the complete code and implementation here:&lt;br&gt;
[view my google Colab Notebook]&lt;br&gt;
&lt;a href="https://colab.research.google.com/drive/1O_FaOlHn9sduGY8tQ8HmScnF1vIF3_UT?usp=sharing" rel="noopener noreferrer"&gt;https://colab.research.google.com/drive/1O_FaOlHn9sduGY8tQ8HmScnF1vIF3_UT?usp=sharing&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned and what's next
&lt;/h2&gt;

&lt;p&gt;At first, "words as numbers" sounded confusing. What helped me was running a real example and seeing that the numbers carry meaning: similar words end up close together. I also learned that the model only knows what it has seen in its training text. GloVe was trained on general text like Wikipedia and news, and my test showed the limit: for "runoff", it mostly returned election words instead of water words.&lt;/p&gt;

&lt;p&gt;Next, I want to use word embeddings in my NLP project to see if they improve my results compared with a simple bag-of-words approach. I also want to try training a small Word2Vec model on my own rainwater harvesting text, to see if it handles words like "runoff" better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pennington, J., Socher, R., &amp;amp; Manning, C. (2014). &lt;a href="https://nlp.stanford.edu/projects/glove/" rel="noopener noreferrer"&gt;GloVe: Global Vectors for Word Representation&lt;/a&gt;. Stanford NLP.&lt;/li&gt;
&lt;li&gt;Mikolov, T., et al. (2013). &lt;a href="https://arxiv.org/abs/1301.3781" rel="noopener noreferrer"&gt;Efficient Estimation of Word Representations in Vector Space&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://radimrehurek.com/gensim/" rel="noopener noreferrer"&gt;gensim library documentation&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Notes from my NLP class.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nlp</category>
      <category>python</category>
      <category>beginners</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
