<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dağhan on Medium]]></title>
        <description><![CDATA[Stories by Dağhan on Medium]]></description>
        <link>https://medium.com/@daghansinan?source=rss-aa01cbafdf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8uckvRLkG1q_AEgrT5dOlA@2x.jpeg</url>
            <title>Stories by Dağhan on Medium</title>
            <link>https://medium.com/@daghansinan?source=rss-aa01cbafdf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:55:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@daghansinan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating a Wordle AI with Python]]></title>
            <link>https://medium.com/@daghansinan/creating-a-wordle-ai-with-python-a6366b57e8c8?source=rss-aa01cbafdf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6366b57e8c8</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Dağhan]]></dc:creator>
            <pubDate>Tue, 08 Feb 2022 16:45:35 GMT</pubDate>
            <atom:updated>2022-02-09T03:00:55.776Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Wordle?</h3><p><a href="https://en.wikipedia.org/wiki/Wordle"><strong><em>Wordle</em></strong> </a>is a <a href="https://en.wikipedia.org/wiki/Browser_game">web-based</a> <a href="https://en.wikipedia.org/wiki/Word_game">word game</a> developed by <a href="https://en.wikipedia.org/wiki/Josh_Wardle">Josh Wardle</a>. Players have six attempts to guess a five-letter word; feedback is given for each guess, in the form of colored tiles, indicating when letters match or occupy the correct position. Yellowish color means that letter exists but it’s in the wrong place while green means that is in the right place. Wordle has a single daily solution, with all players attempting to guess the same word.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QDbcVV6H2QfxsBOFHoQXag.png" /></figure><h3>What is the best strategy?</h3><p>Honestly, I have no idea. I always focus on the solution solver rather than the actual solution solver itself. So, this makes my main goal to write the best strategy maker which kinda seems like creating a chess bot. The upside of this is that I only will calculate 6 possible turns and 5 possible letters instead of countless possibilities of chess.</p><h3>Getting Started</h3><p>As always, I start with getting the English word database from NLTK.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5bca9be0c11f271e0d45e350dcd8543/href">https://medium.com/media/b5bca9be0c11f271e0d45e350dcd8543/href</a></iframe><p>After downloading the words, we’re gonna get rid of words that have more or fewer letters than 5.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ddb4de3d5e7572bfd8a825062ebef07/href">https://medium.com/media/9ddb4de3d5e7572bfd8a825062ebef07/href</a></iframe><p>Now, the word we’re looking for is one of the 10.422 words. Our chances of getting the word on the first try are ~%0.0096, chances of getting hit by lightning are ~%0.0065. That’s why we need a combination of a chance and brain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UYHPxfo423qqkIEH" /><figcaption>Photo by <a href="https://unsplash.com/@jessemartini?utm_source=medium&amp;utm_medium=referral">Jesse Martini</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First, I tried just randomly entering words just to see how frequently it actually finds the words. It was found in ~5404 tries, which is quite higher than the maximum number which is 6.</p><p>Next time, I tried guessing by respecting the colors using these two functions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5e9b87ac9caaa6b8168ce77a5bc26e9/href">https://medium.com/media/f5e9b87ac9caaa6b8168ce77a5bc26e9/href</a></iframe><p>This is where it gets tricky because I had to create an empty dictionary that would hold the knowledge and pass it to the next try in the function where it also returns the remaining words. It managed the find the word in ~3.805 tries which were way too good than my expectations compared to the table of real player results below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16806f943f3e565b56adcff35bc95781/href">https://medium.com/media/16806f943f3e565b56adcff35bc95781/href</a></iframe><p>Being in the top ~%50 didn’t really satisfy me and I wanted to improve it more so I gathered this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/255b23f31c6c933a9546c53e9a4b15e3/href">https://medium.com/media/255b23f31c6c933a9546c53e9a4b15e3/href</a></iframe><p>These are the frequency of occurrence of letters in that 10.422 words. This is a good point for a start right? I wanted to change the starting word from random to a predetermined one. Here are my top picks and try counts:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/592632f55a97068ccd27ca7b0ab14230/href">https://medium.com/media/592632f55a97068ccd27ca7b0ab14230/href</a></iframe><p>Then, I tried the community starting words:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0053c3c5912e4c3510af5d623e6e93c7/href">https://medium.com/media/0053c3c5912e4c3510af5d623e6e93c7/href</a></iframe><p>It doesn’t seem to differ much between the starting words but I might also be missing something. Maybe implementing the letter order would help decrease the average try count but I didn’t find any database for that so I decided to end the experiment after trying today&#39;s Wordle puzzle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*A55ePme1uapegYA9aXaGCA.png" /></figure><p>It found the word “HUMOR” in 5 tries even though it’s a little bit unlucky that it didn’t find it in 4 tries…</p><p>Thank you for reading this, it was fun for me to build a program that could do something that I can’t. I posted the full code down below in case you wanna check it out. See you in the next project!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKQhACHktyALfHBsqFzwgg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b25ea5ad5b0b4c0a788f51b75649178/href">https://medium.com/media/0b25ea5ad5b0b4c0a788f51b75649178/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6366b57e8c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a movie recommendation AI with Python and MySQL]]></title>
            <link>https://medium.com/@daghansinan/creating-a-movie-recommendation-ai-with-python-and-mysql-f71dcdb2770?source=rss-aa01cbafdf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f71dcdb2770</guid>
            <category><![CDATA[movies]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Dağhan]]></dc:creator>
            <pubDate>Tue, 08 Feb 2022 10:44:51 GMT</pubDate>
            <atom:updated>2022-02-08T12:35:47.352Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OJJiG8knz4R1ogKQ" /><figcaption>Photo by <a href="https://unsplash.com/@ninjason?utm_source=medium&amp;utm_medium=referral">Jason Leung</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I like watching movies. At this point, I’m pretty sure it’s an addiction rather than a hobby. I even rate the movies I watched and IMDb tells me that I watched 617 movies and 272 TV Series. Recently, I feel like there are no movies left for my taste but I can’t figure out how could this happen. There are literally thousands of movies that I haven’t watched yet. So I decided to use a movie recommendation bot on the internet to find movies for my taste but they were bad at recommending. That’s why I decided to create this AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sQ4_G6D_VmsdOs4o" /><figcaption>Photo by <a href="https://unsplash.com/@possessedphotography?utm_source=medium&amp;utm_medium=referral">Possessed Photography</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First things first, I had to find a database for the movies. In this article, I’ll use <a href="https://www.kaggle.com/tmdb/tmdb-movie-metadata">this Kaggle dataset</a> to experiment on it. It’s a bit old (4 years old) but it has nice parameters to classify movies. I also have the API key but I’m not going to use it for this project.</p><p>Now that we have our dataset, let’s get rid of the unnecessary parameters and import them into a MySQL database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GUBpICltsIHDeVKlmxTouA.png" /><figcaption>Logical Diagram for the MySQL database.</figcaption></figure><p>I installed <a href="https://pypi.org/project/mysql-connector-python/">this MySQL connector</a> to connect the MySQL server from Python.</p><p>It was pretty easy to connect. I created the connection between the two using these parameters:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f06fb8caa19dec27f5a72c818fffab25/href">https://medium.com/media/f06fb8caa19dec27f5a72c818fffab25/href</a></iframe><p>Then, I wrote functions like this one to import the .csv data (using pandas) to MySQL tables:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cb3e5561f2275cd98a4f41e68f25702/href">https://medium.com/media/7cb3e5561f2275cd98a4f41e68f25702/href</a></iframe><p>After preparing all tables, I also decided to use MySQL table to store relation scores so I wrote this function to calculate the score on Python and insert it into the MySQL table:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ead74a7ceed29a6b1174758b1c651393/href">https://medium.com/media/ead74a7ceed29a6b1174758b1c651393/href</a></iframe><p>I didn’t want to make lots of traffic with many select queries so that’s why I calculate the score in Python and just insert it into the relation table.</p><p>Now that I have my database and I’m connected to it with Python, I can create a formula to calculate the relation between two movies. I decided to make specific relation scores for a few things that I think it makes two movies related to. I think this was the hardest part for me because I’m not really good at relating two things… But after hours, I came up with this basic table:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23eab8ce6991cbfeac73c19f0eff7eb4/href">https://medium.com/media/23eab8ce6991cbfeac73c19f0eff7eb4/href</a></iframe><p>While it looks logical, I wanted to make sure it works as intended so I filled up the relation table with scores between all movies. Now it’s time to test this for “The Dark Knight”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JWUZGbGNES_yTvds" /><figcaption>Photo by <a href="https://unsplash.com/@serge_k?utm_source=medium&amp;utm_medium=referral">Serge Kutuzov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/168bcf29bb7e2b2c4e5dae11a241b780/href">https://medium.com/media/168bcf29bb7e2b2c4e5dae11a241b780/href</a></iframe><p>The first thing that caught me was that we can see the trilogy right away. Both over 800 relation score which is a good sign. Out of the 10 most related movies; Interstellar, Inception and Clash of the Titans seemed not really related so I decided to see the calculation for them.</p><p>For the Clash of the Titans, 200 of the 235 points come from the crew. While this shouldn’t make the two movies related, I have to admit that I have seen both and liked both. But for the sake of the argument, I’ll tweak the score formula later.</p><p>I’m actually more than satisfied because it also established some connections that I wasn’t really paying attention to at first. Like in “The Matrix”:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16bebb37e3174564b906bfb87a1c9474/href">https://medium.com/media/16bebb37e3174564b906bfb87a1c9474/href</a></iframe><p>I couldn’t make the connection between The Matrix — V for Vendetta at first but I noticed that both are rebelling to the system stories when you look at it. I don’t have to mention the relations with the Terminator and I, Robot…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k0x_S9YTXRWP1dHJ" /><figcaption>Photo by <a href="https://unsplash.com/@comparefibre?utm_source=medium&amp;utm_medium=referral">Compare Fibre</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I also want to implement comments from r/MovieRecommendations in the next version when I figure out how to extract movie names from the comments without extracting unnecessary words.</p><p>That’s pretty much it for the experiment. Thanks for reading and I hope it’s helpful for you. It was a fun project for me and I learned a lot.</p><p>I think <a href="https://www.kaggle.com/tmdb/tmdb-movie-metadata">the Kaggle dataset</a> used TMDB API to get the data so I’m adding it to credits just in case.</p><p><em>This project uses the TMDB API but is not endorsed or certified by TMDB.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f71dcdb2770" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>