<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python | 정진영의 포트폴리오</title><link>https://wjdwlsdud.github.io/en/tags/python/</link><atom:link href="https://wjdwlsdud.github.io/en/tags/python/index.xml" rel="self" type="application/rss+xml"/><description>Python</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Mon, 13 Oct 2025 00:00:00 +0000</lastBuildDate><image><url>https://wjdwlsdud.github.io/media/sharing.jpg</url><title>Python</title><link>https://wjdwlsdud.github.io/en/tags/python/</link></image><item><title>Machine Learning</title><link>https://wjdwlsdud.github.io/en/studying/mr/</link><pubDate>Mon, 13 Oct 2025 00:00:00 +0000</pubDate><guid>https://wjdwlsdud.github.io/en/studying/mr/</guid><description>&lt;h2 id="machine-learning-study-log-teaching-a-computer-with-data"&gt;Machine Learning Study Log: Teaching a Computer with Data&lt;/h2&gt;
&lt;p&gt;As I entered the fall semester of my junior year, I began taking a course called &amp;ldquo;Machine Learning&amp;rdquo;. I&amp;rsquo;m attending Professor Song Hyun-je&amp;rsquo;s lectures every Monday and Wednesday at 4:00 PM in Room 523 of Engineering Building 7. You can find more information on Professor Song Hyun-je&amp;rsquo;s site via the link attached above!&lt;/p&gt;
&lt;p&gt;At first, the term &amp;ldquo;Machine Learning&amp;rdquo; felt very difficult and complex. However, now that I&amp;rsquo;ve started learning it, I&amp;rsquo;ve realized it&amp;rsquo;s a fascinating technology that is much closer to our daily lives than I expected. I&amp;rsquo;ve decided to summarize the basic ML concepts I&amp;rsquo;ve learned in my own simple words.&lt;/p&gt;
&lt;p&gt;🧐 So, what is Machine Learning? My understanding is that machine learning starts with a very simple idea. Instead of explicitly telling a computer every single rule (e.g., &amp;ldquo;this is an apple,&amp;rdquo; &amp;ldquo;this is an orange&amp;rdquo;), it is a technology that lets the computer learn patterns and rules on its own by showing it vast amounts of data.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s similar to how a young child might look at hundreds of pictures of dogs and come to realize on their own, &amp;ldquo;Ah, an animal with perky ears and fluffy fur is a dog!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;📚 Two Learning Methods I&amp;rsquo;ve Learned There are many types of machine learning, but I have learned about the two most representative methods.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Teaching with the &amp;ldquo;Answer Key&amp;rdquo;: Supervised Learning Supervised learning is, as the name suggests, a method of training a computer using data that already has the &amp;ldquo;answer&amp;rdquo; (known as a Label). It works by repeatedly showing the computer sets of &amp;ldquo;problems&amp;rdquo; and &amp;ldquo;answers&amp;rdquo; together.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A spam filter is a classic example. By training the model on countless emails (problems) labeled as &amp;ldquo;this is spam&amp;rdquo; (answer) or &amp;ldquo;this is important&amp;rdquo; (answer), it eventually learns to classify new, unseen emails on its own.&lt;/p&gt;
&lt;p&gt;Housing price prediction is another example. If it learns from vast amounts of housing data (problems) like, &amp;ldquo;A 3-bedroom house in Area A costs $500,000&amp;rdquo; (answer), it will be able to predict the price when given information about a new house.&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Letting it Learn on its Own: Unsupervised Learning Unsupervised learning is like giving the computer raw data without any answers and telling it, &amp;ldquo;Find some meaningful groups or structures within this!&amp;rdquo; The computer analyzes the features of the data and groups similar items together by itself.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is very useful for customer management. By feeding it customer purchase pattern data, the model can discover hidden customer segments, such as a &amp;ldquo;budget shopper group&amp;rdquo; or a &amp;ldquo;new product enthusiast group.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;News article clustering is another great example. When given thousands of news articles, the AI can automatically bundle them into similar topics like &amp;ldquo;Politics,&amp;rdquo; &amp;ldquo;Economy,&amp;rdquo; or &amp;ldquo;Sports.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;✨ Closing Thoughts Now that I&amp;rsquo;ve learned the concepts firsthand, I feel that machine learning isn&amp;rsquo;t some vague, abstract technology, but rather a very logical tool for solving problems. Of course, I still only know the absolute basics, but I find the process of discovering meaning within data to be truly fascinating. I&amp;rsquo;ve now set a goal for myself to study this more deeply and to try and build a simple project of my own.&lt;/p&gt;</description></item><item><title>Pacman</title><link>https://wjdwlsdud.github.io/en/projects/pacman/</link><pubDate>Sat, 01 Mar 2025 00:00:00 +0000</pubDate><guid>https://wjdwlsdud.github.io/en/projects/pacman/</guid><description>&lt;p&gt;This is the UC Berkeley Pacman AI project I completed as part of my Artificial Intelligence and Data Structures coursework. The core objective of this assignment was to implement fundamental Graph Search algorithms from scratch and apply them to solve tangible problems within the Pacman game environment.&lt;/p&gt;
&lt;p&gt;My work involved implementing generic search algorithms in &lt;strong&gt;search.py&lt;/strong&gt; and defining/solving specific Pacman problems in &lt;strong&gt;searchAgents.py&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id="1-core-search-algorithm-implementation-searchpy"&gt;1. Core Search Algorithm Implementation (search.py)&lt;/h2&gt;
&lt;p&gt;First, I implemented four fundamental search algorithms that can be applied to any search problem.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DFS (Depth-First Search): Using a &lt;strong&gt;Stack&lt;/strong&gt;, this algorithm explores nodes as deeply as possible first. It was implemented as a graph search, using an &lt;strong&gt;explored&lt;/strong&gt; list to prevent cycles.&lt;/li&gt;
&lt;li&gt;BFS (Breadth-First Search): Using a &lt;strong&gt;Queue&lt;/strong&gt;, this algorithm explores the shallowest (closest) nodes first. It guarantees the shortest path when all edge costs are uniform.&lt;/li&gt;
&lt;li&gt;UCS (Uniform Cost Search): Using a &lt;strong&gt;PriorityQueue&lt;/strong&gt;, this algorithm prioritizes nodes by their total cumulative &amp;lsquo;cost&amp;rsquo;. It always explores the path with the lowest cost first, guaranteeing the shortest cost path.&lt;/li&gt;
&lt;li&gt;A* (A-Star) Search: Also uses a &lt;strong&gt;PriorityQueue&lt;/strong&gt;, but its priority is the sum of the &amp;lsquo;cumulative cost to date&amp;rsquo; ($g(n)$) and an &amp;rsquo;estimated cost to the goal&amp;rsquo; (heuristic, $h(n)$). This function is $f(n) = g(n) + h(n)$. As an informed search, it finds the optimal solution far more efficiently than UCS.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="2-defining-and-solving-pacman-problems-searchagentspy"&gt;2. Defining and Solving Pacman Problems (searchAgents.py)&lt;/h2&gt;
&lt;p&gt;Beyond just implementing the algorithms, I modeled complex problems Pacman faces as formal &amp;lsquo;search problems&amp;rsquo; and solved them.&lt;/p&gt;
&lt;p&gt;📍 The Corners Problem (CornersProblem)
The challenge is to find a path for Pacman to visit all four corners of the map.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;State Definition: To solve this, the state space couldn&amp;rsquo;t just be (x, y). I defined the state as &lt;strong&gt;(currentPosition, (visitedCornersTuple))&lt;/strong&gt;. For example, a state might be &lt;strong&gt;((5, 5), (True, False, False, True))&lt;/strong&gt;, tracking both the position and the visit-status of each corner.&lt;/li&gt;
&lt;li&gt;Goal Definition: The goal state is reached when all boolean values in the tuple state[1] are &lt;strong&gt;True&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Successor Function: As Pacman moves, the function checks if the new position is one of the corners. If it is, it generates a new state with the corresponding boolean in the tuple updated to &lt;strong&gt;True&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;💡 Corners Problem Heuristic (cornersHeuristic)&lt;/p&gt;
&lt;p&gt;I designed a heuristic for solving the Corners Problem using A* search.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Design: A heuristic must be admissible (never overestimates the true cost).&lt;/li&gt;
&lt;li&gt;Logic: The function calculates the Manhattan Distance from the &amp;lsquo;current position&amp;rsquo; to &amp;rsquo;every unvisited corner&amp;rsquo;. It then returns the maximum (max) value among these distances.&lt;/li&gt;
&lt;li&gt;Justification: This is admissible because Pacman must travel at least as far as the farthest remaining corner to complete the goal. This value serves as a safe lower bound on the true remaining cost.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;🍔 All Food Heuristic (foodHeuristic)&lt;/p&gt;
&lt;p&gt;This heuristic was for the &lt;strong&gt;FoodSearchProblem&lt;/strong&gt;, which involves finding a path to eat all the food dots on the map.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Logic: Similar to the corners heuristic, I calculated the actual maze distance (&lt;strong&gt;mazeDistance&lt;/strong&gt;) from the &amp;lsquo;current position&amp;rsquo; to &amp;rsquo;every remaining food dot&amp;rsquo; and returned the maximum (max) value.&lt;/li&gt;
&lt;li&gt;Using &lt;strong&gt;mazeDistance&lt;/strong&gt;: Unlike Manhattan distance, &lt;strong&gt;mazeDistance&lt;/strong&gt; is a helper function that runs a BFS to find the true shortest path considering walls, providing a much more accurate (and still admissible) estimate.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;🎯 Closest Dot Search Agent&lt;/p&gt;
&lt;p&gt;Finding a path to eat all food is very complex (NP-hard). Therefore, I implemented a greedy algorithm that repeatedly finds and eats the closest food dot.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;findPathToClosestDot&lt;/strong&gt; Implementation: I defined a sub-problem called &lt;strong&gt;AnyFoodSearchProblem&lt;/strong&gt; (where the goal is to reach any single food dot).&lt;/li&gt;
&lt;li&gt;Using UCS: I applied &lt;strong&gt;UCS&lt;/strong&gt; to this sub-problem. This finds the path to the food dot with the lowest cost (i.e., the closest dot). (Since costs are uniform, &lt;strong&gt;BFS&lt;/strong&gt; would also have guaranteed the same result).&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>