<?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: Thabasvini</title>
    <description>The latest articles on DEV Community by Thabasvini (@aibythabasvini).</description>
    <link>https://dev.to/aibythabasvini</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3248765%2F699ba749-a5f0-4e3f-ad7c-c62c26313d80.png</url>
      <title>DEV Community: Thabasvini</title>
      <link>https://dev.to/aibythabasvini</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aibythabasvini"/>
    <language>en</language>
    <item>
      <title>Bug Whisperer – AI-Powered Debugging with Redis</title>
      <dc:creator>Thabasvini</dc:creator>
      <pubDate>Mon, 11 Aug 2025 05:41:52 +0000</pubDate>
      <link>https://dev.to/aibythabasvini/bug-whisperer-ai-powered-debugging-with-redis-1f6f</link>
      <guid>https://dev.to/aibythabasvini/bug-whisperer-ai-powered-debugging-with-redis-1f6f</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/redis-2025-07-23"&gt;Redis AI Challenge&lt;/a&gt;: Real-Time AI Innovators&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;Bug Whisperer is an AI-powered debugging assistant that listens for error logs in real time, classifies their severity, explains the cause, and suggests fixes.&lt;br&gt;
It stores embeddings of each bug so it can instantly recall and provide suggestions for similar issues in the future.&lt;/p&gt;

&lt;p&gt;Key highlights:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Real-time bug ingestion via Redis Streams&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AI-powered suggestions using Google FLAN-T5&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Semantic similarity search via Redis Vector Store + Sentence Transformers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Template fallback for common errors&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Streamlit dashboard to view recent bugs &amp;amp; chat with the assistant&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;GitHub Repo: &lt;a href="https://github.com/Thabasvini/Bug-Whisperer-AI-Powered-Debugging-with-Redis-Vector-Search" rel="noopener noreferrer"&gt;https://github.com/Thabasvini/Bug-Whisperer-AI-Powered-Debugging-with-Redis-Vector-Search&lt;/a&gt;&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.amazonaws.com%2Fuploads%2Farticles%2Fav9ttswx028pqcgazbg9.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.amazonaws.com%2Fuploads%2Farticles%2Fav9ttswx028pqcgazbg9.png" alt="dashboard1" width="" height=""&gt;&lt;/a&gt;&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.amazonaws.com%2Fuploads%2Farticles%2Fs20vr27g7re839sp4e01.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.amazonaws.com%2Fuploads%2Farticles%2Fs20vr27g7re839sp4e01.png" alt="dashboard2" width="800" height="434"&gt;&lt;/a&gt;&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.amazonaws.com%2Fuploads%2Farticles%2Fnxl5i4ws8bpb7mofqlps.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.amazonaws.com%2Fuploads%2Farticles%2Fnxl5i4ws8bpb7mofqlps.png" alt="dashboard3" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How it works in action:&lt;/p&gt;

&lt;p&gt;Producer/Simulated App pushes an error into Redis Stream bug_logs&lt;/p&gt;

&lt;p&gt;Consumer reads new error → classifies severity → checks for similar bugs in Redis → generates suggestion&lt;/p&gt;

&lt;p&gt;Dashboard displays recent errors + lets users ask about new bugs directly&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used Redis 8
&lt;/h2&gt;

&lt;p&gt;I leveraged multiple Redis 8 AI-focused features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Redis Streams: Acts as the real-time log ingestion layer (bug_logs).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redis Hashes &amp;amp; Lists: Store structured bug reports (bug:{id}) and maintain an ordered list of recent bugs (bug_index).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redis Vector Store: Store semantic embeddings of bug messages from all-MiniLM-L6-v2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enables semantic recall for similar bugs with high cosine similarity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Semantic Caching: When a bug is seen again, the system instantly retrieves a stored suggestion instead of calling the model again, reducing cost &amp;amp; latency.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Solo project by &lt;a class="mentioned-user" href="https://dev.to/aibythabasvini"&gt;@aibythabasvini&lt;/a&gt; &lt;/p&gt;

</description>
      <category>redischallenge</category>
      <category>devchallenge</category>
      <category>database</category>
      <category>ai</category>
    </item>
    <item>
      <title>How Linear Regression Works: Predictive ML Explained with Python Demo</title>
      <dc:creator>Thabasvini</dc:creator>
      <pubDate>Fri, 11 Jul 2025 13:16:31 +0000</pubDate>
      <link>https://dev.to/aibythabasvini/how-linear-regression-works-predictive-ml-explained-with-python-demo-1j1e</link>
      <guid>https://dev.to/aibythabasvini/how-linear-regression-works-predictive-ml-explained-with-python-demo-1j1e</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;What if a machine could predict your salary just by looking at your experience?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well that what we call as Linear Regression, one of the most fundamental yet powerful algorithms in machine learning.&lt;/p&gt;

&lt;p&gt;In this post, I’ll explain how linear regression works from intuition to code, complete with a real Python demo and visuals.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Linear Regression?
&lt;/h2&gt;

&lt;p&gt;Linear regression is a way for machines to predict a number (continuous value) based on past data.&lt;/p&gt;

&lt;p&gt;Think of it like drawing the &lt;strong&gt;best-fitting straight line through your data points&lt;/strong&gt;, and then using that line to make future predictions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-life examples
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Predicting house price based on area&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Estimating sales based on ad spend&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Calculating salary based on experience&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Mathematically, it looks like this,&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Y = mX + b&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here’s a simple scatter plot with a regression line that represents this idea,&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.amazonaws.com%2Fuploads%2Farticles%2Fflypij8rrhq7du3i3rjo.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.amazonaws.com%2Fuploads%2Farticles%2Fflypij8rrhq7du3i3rjo.png" alt="Salary Prediction Linear Regression Plot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Intuition Behind It
&lt;/h2&gt;

&lt;p&gt;Let’s say you have the following dataset,&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.amazonaws.com%2Fuploads%2Farticles%2Fg8b42s3rhd7u53wjoa6k.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.amazonaws.com%2Fuploads%2Farticles%2Fg8b42s3rhd7u53wjoa6k.png" alt="Experience salary table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Can you guess the salary for someone with 5 years of experience?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Probably ₹50,000?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s exactly what linear regression does, it finds the trend in past data and uses it to predict future values.&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.amazonaws.com%2Fuploads%2Farticles%2Fh3y1yl9e3n7wnh97xtes.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.amazonaws.com%2Fuploads%2Farticles%2Fh3y1yl9e3n7wnh97xtes.png" alt="Intuition Plot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Linear Regression in Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Training the model

from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt

X = [[1], [2], [3], [4], [5]]
y = [30000, 35000, 40000, 45000, 50000]

model = LinearRegression()
model.fit(X, y)

#Predicting the salary

prediction = model.predict([[6]])
print("Predicted salary for 6 years experience:", prediction[0])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
Predicted salary for 6 years experience: 55000.0&lt;/p&gt;
&lt;h2&gt;
  
  
  Real-World Use Cases
&lt;/h2&gt;

&lt;p&gt;Linear regression is widely used in industries,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Finance → Predicting stock price trends&lt;/li&gt;
&lt;li&gt; Marketing → Estimating ROI from ad spend&lt;/li&gt;
&lt;li&gt; Real Estate → Pricing homes based on area/location&lt;/li&gt;
&lt;li&gt; Sales Forecasting → Projecting revenue&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So yes, Linear regression is the gateway to machine learning.&lt;/p&gt;

&lt;p&gt;Need a full YouTube video explanation on Decision Tree,&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/KPjztC7Fe_0"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I build lightweight, fully tailored AI models that run directly on your own data, whether it's spreadsheets, CSVs, or CRM exports.&lt;/p&gt;

&lt;p&gt;Whether you're in product, growth, support, or sales, you’ll get clear, AI-powered insights to automate decisions and save time.&lt;/p&gt;

&lt;p&gt;Want to see what this looks like?&lt;br&gt;
Check out &lt;a href="https://siteencoders.in/" rel="noopener noreferrer"&gt;SiteEncoders&lt;/a&gt;, where we turn AI ideas into real working solutions.&lt;/p&gt;

&lt;p&gt;Check out our &lt;a href="https://siteencoders.in/blogs/decision-trees" rel="noopener noreferrer"&gt;Blog-Page&lt;/a&gt;, How AI Can Make Smart Business Decisions ---&amp;gt; Automatically&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>How Decision Trees Work: Real Demo and Simple Explanation</title>
      <dc:creator>Thabasvini</dc:creator>
      <pubDate>Thu, 26 Jun 2025 14:26:43 +0000</pubDate>
      <link>https://dev.to/aibythabasvini/how-decision-trees-work-real-demo-and-simple-explanation-4nd4</link>
      <guid>https://dev.to/aibythabasvini/how-decision-trees-work-real-demo-and-simple-explanation-4nd4</guid>
      <description>&lt;p&gt;Do you ever ask yourself how machines make decisions like humans?&lt;/p&gt;

&lt;p&gt;Let’s break down one of the most beginner-friendly algorithms in machine learning, &lt;/p&gt;

&lt;p&gt;Wanna know what’s that, ta-da “Decision Tress”, with a real working demo using Python and scikit-learn.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Decision Tree?
&lt;/h2&gt;

&lt;p&gt;A decision tree is a flowchart-like structure where each internal node represents a question based on a feature, each branch represents an answer, and each leaf node represents an outcome or class label.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;(Deos the definition overwhelm you?)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is the simplified version,&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Machines ask yes/no questions ----&amp;gt; (just like we do)----&amp;gt; to make decisions. *&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Real Life Analogy
&lt;/h2&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.amazonaws.com%2Fuploads%2Farticles%2Fe1meh4ksqthjgllo5xus.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.amazonaws.com%2Fuploads%2Farticles%2Fe1meh4ksqthjgllo5xus.png" alt="Decision Tree Flowchart Example: Should I Go Out"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s a decision tree for you to visualize.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Sample Use Case
&lt;/h2&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.amazonaws.com%2Fuploads%2Farticles%2F1zae4nwsvoyy403raz7m.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.amazonaws.com%2Fuploads%2Farticles%2F1zae4nwsvoyy403raz7m.png" alt="Table showing sample data with columns: Age, Income, Will Buy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Build It in Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Import Libraries

from sklearn.tree import DecisionTreeClassifier, plot_tree
import matplotlib.pyplot as plt

Prepare the Data

X = [[25, 50000], [35, 60000], [45, 80000], [22, 30000]]
y = [0, 1, 1, 0]  # 0 = No Buy, 1 = Buy

Train the Model

clf = DecisionTreeClassifier()
clf.fit(X, y)

Visualize the Tree

plt.figure(figsize=(8, 5))
plot_tree(clf, feature_names=["Age", "Income"], class_names=["No", "Yes"], filled=True)
plt.show()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&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.amazonaws.com%2Fuploads%2Farticles%2Fqzwduo6x3yhh08fmc820.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.amazonaws.com%2Fuploads%2Farticles%2Fqzwduo6x3yhh08fmc820.png" alt="Decision Tree Output Visual"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does It Decide?
&lt;/h2&gt;

&lt;p&gt;Well, thats the cool one here,the decision tree uses something called &lt;strong&gt;Gini&lt;/strong&gt; Impurity to choose the best split,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If a node has all “Yes” or all “No”, it’s pure (Gini = 0).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The more mixed it is, the higher the impurity.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, the takeaway algorithm keeps splitting where impurity is lowest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try making a prediction using the above code!
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(clf.predict([[40, 70000]]))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be [1] //means they will buy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Are Decision Trees Used?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Credit card approval&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customer churn prediction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Recommender systems&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Medical diagnosis&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;E-commerce decision engines&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;okay so finally, Decision Trees are powerful, visual, and easy to understand. &lt;/p&gt;

&lt;p&gt;If you’re learning ML or just want to understand how AI “thinks”, start with Decision Trees. &lt;/p&gt;

&lt;p&gt;And if you want to see a live demo in action,Here's a quick youtube video me explaining How decision tress actually work,   &lt;iframe src="https://www.youtube.com/embed/KPjztC7Fe_0"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;🙌 Follow me for more beginner-friendly AI &amp;amp; ML breakdowns!&lt;br&gt;
🚀 Need help building real AI/ML solutions? Check out &lt;a href="https://siteencoders.in/" rel="noopener noreferrer"&gt;SiteEncoders&lt;/a&gt;, we build it for you.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>ai</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>How KNN "Guesses" Like a Human: A Visual Python Demo</title>
      <dc:creator>Thabasvini</dc:creator>
      <pubDate>Mon, 16 Jun 2025 14:18:03 +0000</pubDate>
      <link>https://dev.to/aibythabasvini/how-knn-guesses-like-a-human-a-visual-python-demo-38ia</link>
      <guid>https://dev.to/aibythabasvini/how-knn-guesses-like-a-human-a-visual-python-demo-38ia</guid>
      <description>&lt;p&gt;Have you ever made a decision just by looking around and trusting your instinct! Well, That’s how K-Nearest Neighbors (KNN) works.&lt;/p&gt;

&lt;p&gt;In this post, I’ll walk you through a visual, beginner-friendly KNN demo using Python. We’ll plot data, add a new point. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is KNN
&lt;/h2&gt;

&lt;p&gt;KNN is one of the simplest machine learning algorithms but also one of the most intuitive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It stores all &lt;strong&gt;known data&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When asked to &lt;strong&gt;make a prediction&lt;/strong&gt;, it &lt;strong&gt;finds the K closest&lt;/strong&gt; known data points&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, it "&lt;strong&gt;votes" on what the new data point should be&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Think of it like this:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your 5 closest friends love Chocolate Burgers, well, chocolate Burgers! Does anyone like Chocolate Burger's here?&lt;/p&gt;

&lt;p&gt;LOL&lt;/p&gt;

&lt;p&gt;Chances are you will too, or that's how KNN will assume.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it's Super Cool
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;No need for the training step, it's Lazy Learning.&lt;/li&gt;
&lt;li&gt;Works really well on small datasets.&lt;/li&gt;
&lt;li&gt;It's super great for visual understanding of AI behaviour&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Python Code (Visual Demo)
&lt;/h2&gt;

&lt;p&gt;Let me show some code for KNN, we'll create a synthetic dataset of two classes, plot them and predict a new data point&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import matplotlib.pyplot as plt
from sklearn.datasets import make_classification
from sklearn.neighbors import KNeighborsClassifier

# let's create a 2D Dataset

data, labels = make_classification(n_samples=100,n_features=2,n_informative=2, n_redundant=0,n_clusters_per_class=1)

# Split the data into two classes

class_0 = data[labels == 0]
class_1 = data[labels == 1]

# Plot the existing data

plt.scatter(class_0[:, 0], class_0[:, 1], color='blue', label='Class 0')
plt.scatter(class_1[:, 0], class_1[:, 1], color='red', label='Class 1')

# Define a new plot

new_point = [[0.5, -0.5]]
plt.scatter(new_point[0][0], new_point[0][1], color='green', label='New Point', s=100, edgecolors='black')

# Fit the model and start predicting

knn = KNeighborsClassifier(n_neighbors=5)
knn.fit(data, labels)
predicted = knn.predict(new_point)

# Finally Annotate

plt.title(f"Predicted Class: {predicted[0]}")
plt.legend()
plt.show()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;This code works, feel free to run it, tweak the dataset size or n_neighbors, and experiment with different points. It's a great way to see how AI makes decisions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Output:&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.amazonaws.com%2Fuploads%2Farticles%2F7wo6bu4swtmsdjfg116l.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.amazonaws.com%2Fuploads%2Farticles%2F7wo6bu4swtmsdjfg116l.png" alt="Scatter plot showing blue and red data clusters, with a green new point labeled by predicted class" width="757" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So why KNN matter, it's not just acadamic,it's used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recommendation Systems&lt;/li&gt;
&lt;li&gt;Image Classifier&lt;/li&gt;
&lt;li&gt;Anomaly Detection&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;The beauty of KNN lies in simplicity which lays the foundation for understanding more complex AI systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Want to see more?&lt;/strong&gt; I build AI agents, storytelling bots, and fun Python experiments that feel alive.&lt;/p&gt;

&lt;p&gt;Follow me here on Dev.to or check out &lt;a href="https://siteencoders.in/" rel="noopener noreferrer"&gt;SiteEncoders&lt;/a&gt; where we turn cool AI into real products.&lt;/p&gt;

&lt;p&gt;Let me know your thoughts below or share your favorite "super smart" algorithm!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>knn</category>
      <category>datavisualization</category>
    </item>
  </channel>
</rss>
