<?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 Kotturjyothi on Medium]]></title>
        <description><![CDATA[Stories by Kotturjyothi on Medium]]></description>
        <link>https://medium.com/@kotturjyothi369?source=rss-a44bcb4bd489------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*R_l_Cjz_wihieYWT</url>
            <title>Stories by Kotturjyothi on Medium</title>
            <link>https://medium.com/@kotturjyothi369?source=rss-a44bcb4bd489------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:16:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kotturjyothi369/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[Decision Tree Algorithm in Machine Learning]]></title>
            <link>https://medium.com/@kotturjyothi369/decision-tree-algorithm-in-machine-learning-152409b3af1f?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/152409b3af1f</guid>
            <category><![CDATA[decision-tree-algorithm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Fri, 29 May 2026 10:40:12 GMT</pubDate>
            <atom:updated>2026-05-29T10:40:12.943Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning is transforming industries by enabling computers to learn from data and make intelligent decisions. Among all machine learning algorithms, the <strong>Decision Tree Algorithm</strong> is one of the easiest and most powerful algorithms to understand.</p><p>It works just like human decision-making.</p><p>A Decision Tree solves these problems by asking a sequence of questions and making decisions step by step.</p><h3>What is a Decision Tree?</h3><p>A <strong>Decision Tree</strong> is a supervised machine learning algorithm used for:</p><ul><li>Classification problems</li><li>Regression problems</li></ul><p>It creates a tree-like structure where:</p><ul><li>The root node represents the main question</li><li>Branches represent decisions</li><li>Leaf nodes represent final outcomes</li></ul><p>The algorithm splits the data into smaller groups based on conditions.</p><h3>Real-Life Example of Decision Tree</h3><p>Imagine deciding whether to play cricket or not.</p><p>The decision process may look like this:</p><pre>Is the weather sunny?<br>        |<br>      Yes<br>        |<br>Is humidity high?<br>     /      \<br>   Yes      No<br>   Stay    Play<br>   Home</pre><p>This structure is exactly how a Decision Tree works.</p><h3>Visualization of Decision Tree</h3><h3>Image Suggestion 1</h3><p>Use an image showing:</p><ul><li>Root Node</li><li>Internal Nodes</li><li>Branches</li><li>Leaf Nodes</li></ul><p>Suggested caption:</p><p>“Basic structure of a Decision Tree”</p><h3>Components of a Decision Tree</h3><h3>1. Root Node</h3><p>The topmost node in the tree.</p><p>Example:<br>“Is Age &gt; 30?”</p><h3>2. Internal Nodes</h3><p>These nodes represent conditions or questions.</p><p>Example:<br>“Income &gt; 50K?”</p><h3>3. Branches</h3><p>Branches show possible outcomes.</p><p>Example:<br>Yes / No</p><h3>4. Leaf Nodes</h3><p>Final prediction or decision.</p><p>Example:<br>“Approved” or “Rejected”</p><h3>How Decision Tree Works</h3><p>The algorithm follows these steps:</p><h3>Step 1: Select Best Feature</h3><p>The algorithm chooses the best feature that splits the data effectively.</p><p>Example:</p><ul><li>Age</li><li>Salary</li><li>Experience</li></ul><h3>Step 2: Split the Dataset</h3><p>The dataset is divided into subsets based on the selected feature.</p><h3>Step 3: Repeat the Process</h3><p>The same process continues recursively until:</p><ul><li>Data becomes pure</li><li>Maximum depth is reached</li><li>No further split is possible</li></ul><h3>Figure Suggestion</h3><p>Add a flowchart like:</p><pre>Start<br>  ↓<br>Choose Best Feature<br>  ↓<br>Split Dataset<br>  ↓<br>Create Branches<br>  ↓<br>Repeat Until Pure</pre><h3>Types of Decision Trees</h3><h3>1. Classification Tree</h3><p>Used when the target variable is categorical.</p><p>Examples:</p><ul><li>Spam or Not Spam</li><li>Pass or Fail</li><li>Yes or No</li></ul><h3>2. Regression Tree</h3><p>Used when the target variable is continuous.</p><p>Examples:</p><ul><li>House Price Prediction</li><li>Temperature Prediction</li></ul><h3>Important Concepts in Decision Trees</h3><h3>1. Entropy</h3><p>Entropy measures impurity or randomness.</p><h3>Formula</h3><p>[<br>Entropy = — \sum p(x) \log_2 p(x)<br>]</p><p>Lower entropy means better classification.</p><h3>2. Information Gain</h3><p>Information Gain tells how much uncertainty is reduced after splitting.</p><h3>Formula</h3><p>[<br>Information\ Gain = Entropy(parent) — Weighted\ Entropy(children)<br>]</p><p>The feature with highest information gain is selected.</p><h3>Mathematical Visualization</h3><p>Entropy Example:</p><pre>Class Distribution:<br>Yes = 8<br>No = 2</pre><pre>Entropy = Low</pre><p>Balanced classes have higher entropy.</p><h3>Gini Index</h3><p>Another metric used to split data.</p><h3>Formula</h3><p>[<br>Gini = 1 — \sum p(x)²<br>]</p><p>Lower Gini value indicates better split.</p><h3>Popular Decision Tree Algorithms</h3><h3>1. ID3</h3><p>Uses Information Gain.</p><h3>2. C4.5</h3><p>Improved version of ID3.</p><h3>3. CART</h3><p>Uses Gini Index and creates binary trees.</p><h3>Advantages of Decision Tree</h3><p>✅ Easy to understand<br>✅ Simple visualization<br>✅ Requires less data preprocessing<br>✅ Handles both numerical and categorical data<br>✅ Useful for feature selection</p><h3>Disadvantages of Decision Tree</h3><p>❌ Can overfit easily<br>❌ Sensitive to small data changes<br>❌ Complex trees reduce accuracy<br>❌ Biased toward dominant classes</p><h3>Overfitting in Decision Trees</h3><p>Overfitting happens when the model memorizes training data instead of learning patterns.</p><h3>Example</h3><p>A very deep tree may perfectly classify training data but fail on new data.</p><h3>Methods to Avoid Overfitting</h3><h3>1. Pruning</h3><p>Removing unnecessary branches.</p><h3>2. Maximum Depth</h3><p>Limit the depth of the tree.</p><h3>3. Minimum Samples Split</h3><p>Require minimum samples before splitting.</p><h3>Visualization Suggestion</h3><p>Add two trees:</p><ul><li>Overfitted Tree</li><li>Optimized Tree</li></ul><p>Caption:</p><p>“Comparison between overfitting and pruning”</p><h3>Real-World Applications</h3><p>Decision Trees are widely used in:</p><h3>Healthcare</h3><p>Disease prediction</p><h3>Banking</h3><p>Loan approval systems</p><h3>Marketing</h3><p>Customer segmentation</p><h3>Education</h3><p>Student performance prediction</p><h3>E-commerce</h3><p>Product recommendation systems</p><h3>Python Implementation of Decision Tree</h3><pre>from sklearn.tree import DecisionTreeClassifier<br>from sklearn.model_selection import train_test_split<br>from sklearn.datasets import load_iris<br>from sklearn.metrics import accuracy_score</pre><pre># Load dataset<br>data = load_iris()</pre><pre>X = data.data<br>y = data.target</pre><pre># Split dataset<br>X_train, X_test, y_train, y_test = train_test_split(<br>    X, y, test_size=0.2, random_state=42<br>)</pre><pre># Create model<br>model = DecisionTreeClassifier()</pre><pre># Train model<br>model.fit(X_train, y_train)</pre><pre># Prediction<br>y_pred = model.predict(X_test)</pre><pre># Accuracy<br>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))</pre><h3>Decision Tree Visualization in Python</h3><pre>from sklearn import tree<br>import matplotlib.pyplot as plt</pre><pre>plt.figure(figsize=(12,8))<br>tree.plot_tree(model, filled=True)<br>plt.show()</pre><p>This visualization helps us understand how the model makes decisions.</p><h3>Decision Tree vs Random Forest</h3><p>Decision TreeRandom ForestSingle treeMultiple treesFasterMore accurateCan overfitReduces overfittingEasy interpretationComplex interpretation</p><h3>Conclusion</h3><p>The Decision Tree Algorithm is one of the most beginner-friendly machine learning algorithms. It mimics human decision-making and provides easy-to-understand results.</p><p>Its ability to handle classification and regression problems makes it highly useful in real-world applications.</p><p>Although Decision Trees may suffer from overfitting, techniques like pruning and ensemble learning can significantly improve performance.</p><p>If you are starting your machine learning journey, Decision Trees are an excellent algorithm to learn because they build a strong foundation for advanced algorithms like Random Forest and Gradient Boosting.</p><h3>1. Basic Decision Tree Structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*FERwyad7mzk4g65w" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*mZAHTvnLAEwTjefo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x4W1Naf_ASn7UWdn" /></figure><h3>2. Decision Tree Working Process</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a0vSnNi8xL0kRLA8" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/0*H_xvkpc_ZIi4RN6w" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*HcqTxOuQwVCGYrqg" /></figure><h3>3. Overfitting vs Pruning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xBdj3dhpKT0-Hbt8" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ijVmxG9URIdRcyAx" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*MvN0p_9k4Fu9y3gY" /></figure><h3>4. Real-World Applications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nG7V_gYQgSqMl6Cu" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5pwnuN1EGkIlLY9C" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wjhweOcbiOAMehap" /></figure><p>Also include these important formulas in your article for better understanding:</p><p>Entropy Formula:</p><p>Entropy=−∑p(x)log⁡2p(x)Entropy=-\sum p(x)\log_2 p(x)Entropy=−∑p(x)log2​p(x)</p><p>Information Gain:</p><p>Information Gain=Entropy(parent)−Weighted Entropy(children)Information\ Gain=Entropy(parent)-Weighted\ Entropy(children)Information Gain=Entropy(parent)−Weighted Entropy(children)</p><p>Gini Index:</p><p>Gini=1−∑p(x)2Gini=1-\sum p(x)²Gini=1−∑p(x)2.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=152409b3af1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperparameter Tuning using GridSearchCV and RandomizedSearchCV in Machine Learning]]></title>
            <link>https://medium.com/@kotturjyothi369/hyperparameter-tuning-using-gridsearchcv-and-randomizedsearchcv-in-machine-learning-88944337e594?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/88944337e594</guid>
            <category><![CDATA[romdomizedsearchcv]]></category>
            <category><![CDATA[hyperparameter-tuning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[gridsearchcv]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Fri, 29 May 2026 10:26:16 GMT</pubDate>
            <atom:updated>2026-05-29T10:26:16.784Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Machine learning models do not automatically give the best performance with default settings.<br> To improve model accuracy, we need to adjust important settings called <strong>hyperparameters</strong>.</p><p>Hyperparameter tuning helps us find the best combination of parameters that improves model performance.</p><p>Two popular techniques in Scikit-learn are:</p><ul><li><strong>GridSearchCV</strong></li><li><strong>RandomizedSearchCV</strong></li></ul><p>In this article, we will understand:</p><ul><li>What is hyperparameter tuning?</li><li>Why it is important</li><li>How GridSearchCV works</li><li>How RandomizedSearchCV works</li><li>Differences between them</li><li>Real-world example with Python code</li><li>Visual explanations and figure ideas</li></ul><h3>What are Hyperparameters?</h3><p>Hyperparameters are settings that are defined <strong>before training</strong> a machine learning model.</p><p>Examples:</p><p>AlgorithmHyperparameterDecision Treemax_depthKNNn_neighborsRandom Forestn_estimatorsSVMC, gamma</p><p>These parameters control how the model learns from data.</p><h3>Why Hyperparameter Tuning is Important?</h3><p>Without tuning:</p><ul><li>Model may underfit</li><li>Model may overfit</li><li>Accuracy may be low</li></ul><p>With tuning:</p><p>✅ Better accuracy<br> ✅ Better generalization<br> ✅ Improved performance</p><h3>Visualization Idea — Default vs Tuned Model</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*F-CF5HOX7X0wNWm_" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*g1BRN9TbjOA6h1_H" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*m-QhycZ-HZpmerqf" /></figure><p>6</p><h3>What is GridSearchCV?</h3><p>GridSearchCV tries <strong>all possible combinations</strong> of hyperparameters.</p><p>It performs:</p><ol><li>Parameter combination generation</li><li>Cross-validation</li><li>Performance evaluation</li><li>Best parameter selection</li></ol><h3>How GridSearchCV Works</h3><p>Suppose we have:</p><pre>{<br>    &#39;n_neighbors&#39;: [3,5,7],<br>    &#39;weights&#39;: [&#39;uniform&#39;, &#39;distance&#39;]<br>}</pre><p>GridSearchCV checks:</p><p>n_neighborsweights3uniform3distance5uniform5distance7uniform7distance</p><p>Total combinations = 6</p><h3>GridSearchCV Workflow Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j4YoNQfMjjeR77WC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*36P4ZQRVUS2h_x35" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qTD7taOnJthfw1MG" /></figure><h3>GridSearchCV Code Example</h3><pre>from sklearn.model_selection import GridSearchCV<br>from sklearn.neighbors import KNeighborsClassifier</pre><pre>model = KNeighborsClassifier()</pre><pre>param_grid = {<br>    &#39;n_neighbors&#39;: [3,5,7,9],<br>    &#39;weights&#39;: [&#39;uniform&#39;, &#39;distance&#39;]<br>}</pre><pre>grid = GridSearchCV(<br>    estimator=model,<br>    param_grid=param_grid,<br>    cv=5,<br>    scoring=&#39;accuracy&#39;<br>)</pre><pre>grid.fit(X_train, y_train)</pre><pre>print(&quot;Best Parameters:&quot;, grid.best_params_)<br>print(&quot;Best Score:&quot;, grid.best_score_)</pre><h3>Advantages of GridSearchCV</h3><p>✅ Finds best combination<br> ✅ More accurate<br> ✅ Easy to implement</p><h3>Disadvantages of GridSearchCV</h3><p>❌ Computationally expensive<br> ❌ Slow for large datasets<br> ❌ Tests every combination</p><h3>What is RandomizedSearchCV?</h3><p>RandomizedSearchCV selects <strong>random combinations</strong> of hyperparameters instead of checking all combinations.</p><p>This makes it faster and more efficient for large datasets.</p><h3>RandomizedSearchCV Visualization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ribGsJv6TLFmubet" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tBQ0GEOyYAzgwZJh" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*bo6kLHpA2UTVs4-Y" /></figure><p>6</p><h3>How RandomizedSearchCV Works</h3><p>Instead of trying all combinations:</p><p>CombinationChecked?1✅2❌3✅4❌5✅</p><p>It randomly selects combinations based on n_iter.</p><h3>RandomizedSearchCV Code Example</h3><pre>from sklearn.model_selection import RandomizedSearchCV<br>from sklearn.neighbors import KNeighborsClassifier</pre><pre>model = KNeighborsClassifier()</pre><pre>param_dist = {<br>    &#39;n_neighbors&#39;: [3,5,7,9,11,13],<br>    &#39;weights&#39;: [&#39;uniform&#39;, &#39;distance&#39;]<br>}</pre><pre>random_search = RandomizedSearchCV(<br>    estimator=model,<br>    param_distributions=param_dist,<br>    n_iter=5,<br>    cv=5,<br>    scoring=&#39;accuracy&#39;,<br>    random_state=42<br>)</pre><pre>random_search.fit(X_train, y_train)</pre><pre>print(&quot;Best Parameters:&quot;, random_search.best_params_)<br>print(&quot;Best Score:&quot;, random_search.best_score_)</pre><h3>GridSearchCV vs RandomizedSearchCV</h3><p>FeatureGridSearchCVRandomizedSearchCVSearch TypeExhaustiveRandomSpeedSlowFasterAccuracyUsually betterGoodComputation CostHighLowBest ForSmall datasetsLarge datasets</p><h3>Comparison Visualization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oo9RoJdC9adX-0Fa" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aBzX7kCmYiZ2Ps40" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5xybDi3OLPFGYFiG" /></figure><h3>Cross Validation in Hyperparameter Tuning</h3><p>Both methods use <strong>Cross Validation (CV)</strong>.</p><p>Example:</p><p>If cv = 5:</p><ul><li>Dataset is divided into 5 parts</li><li>Model trains on 4 parts</li><li>Tests on remaining 1 part</li><li>Repeats 5 times</li></ul><p>This gives reliable performance evaluation.</p><h3>Cross Validation Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_L91Ch3CkWlm-Qfm" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SNnZlrDvsJ6edV-M" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*tE1BJobR2ay7Jafw" /></figure><p>5</p><h3>Real-World Applications</h3><p>Hyperparameter tuning is used in:</p><ul><li>Fraud detection</li><li>Recommendation systems</li><li>Healthcare prediction</li><li>Stock market prediction</li><li>NLP applications</li><li>Computer vision</li></ul><h3>Best Practices</h3><p>✅ Start with RandomizedSearchCV for large search spaces<br> ✅ Use GridSearchCV for fine-tuning<br> ✅ Reduce unnecessary parameters<br> ✅ Use cross-validation properly<br> ✅ Monitor computation time</p><h3>Conclusion</h3><p>Hyperparameter tuning is one of the most important steps in building high-performing machine learning models.</p><ul><li><strong>GridSearchCV</strong> checks all combinations and gives highly accurate results.</li><li><strong>RandomizedSearchCV</strong> is faster and works efficiently on large datasets.</li></ul><p>Choosing the right tuning method depends on:</p><ul><li>Dataset size</li><li>Computational resources</li><li>Time constraints</li></ul><p>Mastering these techniques can significantly improve your machine learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88944337e594" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Preprocessing in Machine Learning: Encoding and Feature Scaling]]></title>
            <link>https://medium.com/@kotturjyothi369/data-preprocessing-in-machine-learning-encoding-and-feature-scaling-bf982b414717?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf982b414717</guid>
            <category><![CDATA[feature-selection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-preprocessing]]></category>
            <category><![CDATA[encoding]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Wed, 27 May 2026 15:36:28 GMT</pubDate>
            <atom:updated>2026-05-27T15:36:28.687Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning models are powerful, but they cannot directly understand raw data. Before feeding data into a model, we must clean and transform it into a suitable format. This important step is called <strong>Data Preprocessing</strong>.</p><p>Two of the most important preprocessing techniques are:</p><ol><li><strong>Encoding</strong> — converting categorical data into numerical format</li><li><strong>Feature Scaling</strong> — bringing numerical values into a similar range</li></ol><p>In this article, we’ll explore these concepts with simple explanations, examples, visualizations, and Python code.</p><h3>What is Data Preprocessing?</h3><p>Data preprocessing is the process of preparing raw data before using it in Machine Learning models.</p><h3>Why is preprocessing important?</h3><p>Without preprocessing:</p><ul><li>Models may produce poor predictions</li><li>Algorithms may become biased</li><li>Training may become slower</li><li>Accuracy may decrease</li></ul><h3>Main Steps in Data Preprocessing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/0*e2YIzVxsflrbh-30" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eHzGP9-l6JaIXapT" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1lUghb5v5aIVrEll" /></figure><p>Typical preprocessing steps:</p><ul><li>Handling missing values</li><li>Encoding categorical variables</li><li>Feature scaling</li><li>Feature selection</li><li>Outlier handling</li></ul><h3>Part 1: Encoding in Machine Learning</h3><h3>What is Encoding?</h3><p>Machine Learning algorithms work with numbers, not text.</p><p>Encoding converts categorical data (words/labels) into numerical form.</p><h3>Example Dataset</h3><p>GenderMaleFemaleMale</p><p>A machine learning model cannot understand “Male” or “Female” directly.</p><p>After encoding:</p><p>Gender10</p><h3>Types of Encoding Techniques</h3><h3>1. Label Encoding</h3><p>Label Encoding assigns a unique number to each category.</p><h3>Example</h3><p>CityEncodedHyderabad0Chennai1Bangalore2</p><h3>Visualization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OWinxXqI36igBUMT" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/0*s0sT7KvwZ__3lizP" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/0*sLXyJXpv_4kkZZk5" /></figure><h3>Python Code</h3><pre>from sklearn.preprocessing import LabelEncoder</pre><ul><li>Uses less memory</li></ul><h3>Disadvantages</h3><ul><li>Creates an order that may not exist</li><li>Not suitable for nominal categories</li></ul><h3>2. One-Hot Encoding</h3><p>One-Hot Encoding creates separate columns for each category.</p><h3>Example</h3><p>ColorRedBlueGreen</p><p>After encoding:</p><p>RedBlueGreen100010001</p><h3>Visualization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*VK5VCOvIoCwvi5g_" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/0*2AINUijt44xTfVTH" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7wwkl4whHj5HtjrQ" /></figure><h3>Python Code</h3><pre>import pandas as pd</pre><pre>encoded_data = pd.get_dummies(data, columns=[&#39;Color&#39;])</pre><pre>print(encoded_data.head())</pre><h3>Advantages</h3><ul><li>No ranking problem</li><li>Best for nominal data</li></ul><h3>Disadvantages</h3><ul><li>Creates many columns</li><li>Increases dimensionality</li></ul><h3>3. Ordinal Encoding</h3><p>Used when categories have a meaningful order.</p><h3>Example</h3><p>EducationSchoolDegreeMasters</p><p>Encoded as:</p><p>EducationValueSchool0Degree1Masters2</p><h3>Visualization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kSY5oKgsz0w-Nt1g" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4DfhNUcVENSXbziE" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*2zI3_MwxdchUm7vQ" /></figure><h3>Python Code</h3><pre>from sklearn.preprocessing import OrdinalEncoder</pre><pre>oe = OrdinalEncoder()</pre><pre>data[[&#39;Education&#39;]] = oe.fit_transform(data[[&#39;Education&#39;]])</pre><pre>print(data.head())</pre><h3>When Should Each Encoding Technique Be Used?</h3><p>Encoding TechniqueBest Used ForLabel EncodingBinary categoriesOne-Hot EncodingNominal categoriesOrdinal EncodingOrdered categories</p><h3>Part 2: Feature Scaling</h3><h3>What is Feature Scaling?</h3><p>Feature Scaling transforms numerical features into a similar range.</p><h3>Why is Feature Scaling Needed?</h3><p>Consider this dataset:</p><p>AgeSalary25250004080000</p><p>Salary values are much larger than Age values.</p><p>Algorithms like:</p><ul><li>KNN</li><li>SVM</li><li>Logistic Regression</li><li>Neural Networks</li></ul><p>may give more importance to Salary because of its larger scale.</p><p>Feature Scaling solves this problem.</p><h3>Types of Feature Scaling</h3><h3>1. Standardization (Z-Score Scaling)</h3><p>Standardization transforms data so that:</p><ul><li>Mean = 0</li><li>Standard Deviation = 1</li></ul><h3>Formula</h3><p>z=x−μσz = \frac{x-\mu}{\sigma}z=σx−μ​</p><p>xxx</p><p>μ\muμ</p><p>σ\sigmaσ</p><p>z=x−μσ≈1.2z=\frac{x-\mu}{\sigma}\approx 1.2z=σx−μ​≈1.2</p><p>Φ(z)≈88.5%\Phi(z)\approx 88.5\%Φ(z)≈88.5%</p><p>Where:</p><ul><li>xxx = original value</li><li>μ\muμ = mean</li><li>σ\sigmaσ = standard deviation</li></ul><h3>Visualization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GJu--9PPOqCyZH7Z" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5FrY2R6UM6m0D2bE" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*8xN_OV5k2aOelb7W" /></figure><h3>Python Code</h3><pre>from sklearn.preprocessing import StandardScaler</pre><pre>scaler = StandardScaler()</pre><pre>data[[&#39;Age&#39;,&#39;Salary&#39;]] = scaler.fit_transform(data[[&#39;Age&#39;,&#39;Salary&#39;]])</pre><pre>print(data.head())</pre><h3>Best Used For</h3><ul><li>Logistic Regression</li><li>SVM</li><li>PCA</li><li>Neural Networks</li></ul><h3>2. Min-Max Scaling (Normalization)</h3><p>Transforms values between 0 and 1.</p><h3>Formula</h3><p>x′=x−xminxmax−xminx’ = \frac{x — x_{min}}{x_{max} — x_{min}}x′=xmax​−xmin​x−xmin​​</p><h3>Visualization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BxKJawh7nnhII1a1" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CzP7dsmTphPuuaHZ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ajy7cCxI2O4rEb5U" /></figure><h3>Python Code</h3><pre>from sklearn.preprocessing import MinMaxScaler</pre><pre>scaler = MinMaxScaler()</pre><pre>data[[&#39;Age&#39;,&#39;Salary&#39;]] = scaler.fit_transform(data[[&#39;Age&#39;,&#39;Salary&#39;]])</pre><pre>print(data.head())</pre><h3>Best Used For</h3><ul><li>Deep Learning</li><li>Image Processing</li><li>Distance-based algorithms</li></ul><h3>Difference Between Standardization and Normalization</h3><p>StandardizationNormalizationMean = 0Range = 0 to 1Handles outliers betterSensitive to outliersUsed in statistical modelsUsed in neural networks</p><h3>Real-World Example</h3><p>Imagine a dataset containing:</p><ul><li>Age</li><li>Salary</li><li>City</li><li>Education</li></ul><h3>Preprocessing Steps</h3><ol><li>Handle missing values</li><li>Encode City and Education columns</li><li>Scale Age and Salary columns</li><li>Train Machine Learning model</li></ol><h3>Complete Workflow Visualization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*1U3xv_wfTcqcyrrl" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NmSVhJA0nRDhx7qr" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*xwnlgU4sm8yWbrr_" /></figure><h3>Conclusion</h3><p>Data preprocessing is one of the most important steps in Machine Learning. Even the best algorithms cannot perform well with poorly prepared data.</p><p>Encoding helps machines understand categorical data, while feature scaling ensures numerical features contribute equally to the learning process.</p><p>A well-preprocessed dataset leads to:</p><ul><li>Better accuracy</li><li>Faster training</li><li>Improved model performance</li></ul><p>Mastering preprocessing techniques is essential for every aspiring Data Scientist and Machine Learning Engineer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf982b414717" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evaluation Metrics for Regression and Classification Models]]></title>
            <link>https://medium.com/@kotturjyothi369/evaluation-metrics-for-regression-and-classification-models-038cb351d512?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/038cb351d512</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[evalution-metrics]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Wed, 27 May 2026 15:17:16 GMT</pubDate>
            <atom:updated>2026-05-27T15:17:16.026Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning models are designed to make predictions, but building a model is only the first step. The most important part is understanding how well the model performs. This is where Evaluation Metrics become extremely important. Evaluation metrics help us:</p><ul><li>Measure prediction accuracy</li><li>Compare different models</li></ul><p>Detect errors and weaknesses</p><ul><li>Improve model performance</li><li>Build reliable AI systems</li></ul><h3>Evaluation Metrics for Regression Models</h3><p>Regression models predict continuous numerical values such as:</p><ul><li>House Price Prediction</li><li>Salary Prediction</li><li>Weather Forecasting</li><li>Weather Forecasting</li></ul><p>Common regression metrics include MAE, MSE, RMSE, and R² Score.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/0*zuti-kkPcAiALYZB.png" /></figure><p><strong>Regression Prediction Example</strong></p><p><strong>Mean Absolute Error (MAE)</strong></p><p>MAE measures the average absolute difference between actual and predicted values. A lower MAE indicates better model performance.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*AWhG3a_EHf7Z8T3u.png" /></figure><p><strong>Mean Squared Error (MSE)</strong></p><p>MSE squares the errors before averaging them. Large errors receive more penalty, making it useful for optimization problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/0*myso96JBYRJo5p1L.png" /></figure><p><strong>Root Mean Squared Error (RMSE)</strong></p><p>RMSE is the square root of MSE and is easy to interpret because it uses the same unit as the target variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/0*Sk0GqLN-PNzZsr0L.png" /></figure><p><strong>R² Score</strong></p><p>R² measures how much variance in the data is explained by the model. Values closer to 1 indicate stronger performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/0*xX83H2MeQR97wV5L.png" /></figure><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h3Z-i3xPCBSPpDyK.png" /></figure><h3>2. Evaluation Metrics for Classification Models</h3><p><strong>Classification models predict categories or labels such as:</strong></p><ul><li>Spam or Not Spam</li><li>Disease or No Disease</li><li>• Fraud or Legitimate Transaction</li><li>• Pass or Fail</li></ul><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*xoxa7ur6oyVX04EV.png" /></figure><p><strong>Confusion Matrix Example</strong></p><p><strong>Accuracy</strong></p><p>Accuracy measures the percentage of correct predictions. It works well when the dataset is balanced.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/0*lEXCm1VejJfDVn2M.png" /></figure><h3>Interpretation</h3><ul><li>67% predictions are correct</li><li>Higher accuracy means better performance</li></ul><p><strong>Precision</strong></p><p>Precision measures how many predicted positive values are actually positive. Important when false positives are costly.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/0*rGfj_Y5QAHOMlsEK.png" /></figure><h3>Interpretation</h3><ul><li>Out of all predicted Disease cases, 67% are correct</li><li>High Precision means low False Positives</li></ul><h3>Recall</h3><p>Recall measures how many actual positive cases are correctly identified. Important in medical diagnosis and fraud detection.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/0*oqnDWLduuZnkoSsT.png" /></figure><h3>Interpretation</h3><ul><li>Model identified 67% of actual disease patients</li><li>High Recall means low False Negatives</li></ul><p><strong>F1 Score</strong></p><p>F1 Score balances precision and recall. It is highly useful for imbalanced datasets.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*erd01GuzTYSZV3Gb.png" /></figure><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DacL8fO2Pi-Q7hy2.png" /></figure><h3>Interpretation</h3><ul><li>Combines Precision and Recall into a single score</li><li>Useful when dataset is imbalanced</li></ul><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K2c7Mhyn021IS918.png" /></figure><h3>4. Conclusion</h3><p>Evaluation metrics are one of the most important concepts in Machine Learning because they help us understand model quality and performance. Regression metrics focus on prediction error for numerical problems, while classification metrics evaluate prediction quality for categorical problems. Choosing the right evaluation metric helps build accurate, reliable, and intelligent machine learning systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=038cb351d512" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Text Preprocessing in NLP : Bag of Words(BoW) and TFIDF]]></title>
            <link>https://medium.com/@kotturjyothi369/text-preprocessing-in-nlp-bag-of-words-bow-and-tfidf-e63a3a94ae29?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/e63a3a94ae29</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[text-preprocessing-in-nlp]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Tue, 26 May 2026 12:43:43 GMT</pubDate>
            <atom:updated>2026-05-26T12:43:43.125Z</atom:updated>
            <content:encoded><![CDATA[<p>Before a machine learning model can understand language, it needs numbers. Text preprocessing transforms chaotic, ambiguous, human language into clean numerical representations — and Bag of Words and TF-IDF are where that story begins.</p><p>Computers fundamentally work with numbers. But language — rich with context, idioms, typos, plurals, and punctuation — resists direct numerical encoding. Text preprocessing is the bridge: a sequence of transformations that standardise raw text into a form that algorithms can meaningfully learn from.</p><h3>The Standard Preprocessing</h3><p>Every text preprocessing workflow follows a similar sequence of steps. Here is the canonical pipeline, each step building on the last:</p><p><strong>1.Lowercasing</strong></p><p>Normalize all characters to lowercase so “Apple”, “APPLE”, and “apple” are treated identically.</p><p>“The Cat SAT” → “the cat sat”</p><p><strong>2.Removing Punctuation &amp; Special Characters</strong></p><p>Strip commas, periods, exclamation marks, and other non-alphanumeric characters that carry no semantic weight in bag-based models.</p><p>“Hello, world!” → “Hello world”</p><p><strong>3.Tokenization</strong></p><p>Split the cleaned string into individual tokens (words or sub-words). This is the fundamental unit for all subsequent steps.</p><p>“hello world” → [“hello”, “world”]</p><p><strong>4.Stop Word Removal</strong></p><p>Discard high-frequency words like “the”, “is”, “at”, “which” that appear so often they obscure meaningful patterns.</p><p>[“the”, “cat”, “sat”, “on”, “a”, “mat”] → [“cat”, “sat”, “mat”]</p><p><strong>5.Stemming / Lemmatization</strong></p><p>Reduce words to their root form. Stemming is aggressive (chops suffixes); lemmatization uses vocabulary and morphological analysis to return proper base forms.</p><p>[“running”, “runs”, “ran”] → [“run”, “run”, “run”]</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V_GCsB6hyxX3pONw.png" /></figure><h3>Bag of Words: Counting What’s There</h3><p>The Bag of Words (BoW) model is the simplest possible text representation. The core idea: represent a document by the <em>count of each word</em> it contains, completely ignoring word order, grammar, and sentence structure.</p><p>The term “bag” is deliberate — imagine throwing all words from a document into a bag and then counting how many of each word you can pull out. No matter what order they went in, the counts are what matter.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZlAIL_S4lywDtwN-.png" /></figure><h3>How BoW is Built</h3><p>Given a corpus (collection of documents), BoW works in two phases:</p><p>Step 1 — Build the vocabulary: Scan every document and collect every unique word. This vocabulary defines the dimensions of your feature space.</p><p>Step 2 — Vectorize: For each document, create a vector the length of the vocabulary, filling each position with the word’s frequency in that document.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eTqgzQhcrxEa3960.png" /></figure><h3>Strengths and Weaknesses of BoW</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j5IP-r-d547q39Ut.png" /></figure><h3>Limitations of Bag of Words (BoW):</h3><ol><li>Ignore meaning and context.</li><li>Unnecessary dimensionality increases.</li><li>Ignore word order.</li><li>Large sparse marix.</li></ol><h3>TF-IDF: Weighting Words by Importance</h3><p>Raw word counts are naïve. The word “the” appears in almost every English document, yet it tells us almost nothing about a document’s topic. TF-IDF (Term Frequency–Inverse Document Frequency) solves this by rewarding words that are frequent <em>in a specific document</em> but rare <em>across the corpus</em>.</p><h3>The Two-Part Formula</h3><p>TF-IDF is the product of two quantities — one that rewards local frequency, and one that penalises global ubiquity:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HZmR86V-MRCM5mQS.png" /></figure><h3>Example:</h3><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CZS5Jv6Gm2vpR9rv.png" /></figure><p>“learning” and “the” score zero because they appear in every document — they carry no discriminative power. “neural” scores highest because it’s frequent in <em>this</em> document but rare across the corpus. TF-IDF finds the signal in the noise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DbV-N_M1e0bMhhOv.png" /></figure><h3>BoW vs TF-IDF:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p0xtsD8DD4Jaw7VA.png" /></figure><h3>Limitations of TFIDF:</h3><ol><li>Ignores word order.</li><li>Unnecessary dimensionality increases.</li><li>No understanding of meaning.</li><li>Sensitive to Noise.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e63a3a94ae29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Naive Bayes Algorithm]]></title>
            <link>https://medium.com/@kotturjyothi369/naive-bayes-algorithm-ee4c1311e2eb?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee4c1311e2eb</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[naive-bayes]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Tue, 26 May 2026 12:25:03 GMT</pubDate>
            <atom:updated>2026-05-26T12:25:03.171Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. What is Naive Bayes?</h3><p>Naive Bayes is a supervised machine learning algorithm mainly used for classification tasks. It predicts the category or class of data based on probability.</p><p>The algorithm is based on Bayes’ Theorem and assumes that all input features are independent of each other, which is why it is called “Naive.”</p><p>Naive Bayes is widely used in text classification, sentiment analysis, spam filtering, and recommendation systems because it is simple, fast, and effective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*4lRNlYyETkcIKda0.jpeg" /></figure><h3>Examples:</h3><ul><li>Email classification → Spam or Not Spam</li><li>Movie review analysis → Positive or Negative</li><li>News article classification → Sports, Politics, or Entertainment</li><li>Medical diagnosis → Disease or No Disease</li></ul><h3>3. Bayes Theorem</h3><p>Use this visual in your article:</p><p>P(A|B)=P(B|A)P(A)/P(B)</p><h3>Meaning:</h3><ul><li><strong>P(A|B)</strong> → Probability of A given B</li><li><strong>P(B|A)</strong> → Probability of B given A</li><li><strong>P(A)</strong> → Prior probability</li><li><strong>P(B)</strong> → Evidence probability</li></ul><p>Simple interpretation:</p><p>Posterior = Likelihood × Prior / Evidence</p><h3>4. Why is it called “Naive”?</h3><p>It assumes all features are <strong>independent</strong>.</p><p>Example:</p><p>For house price prediction:</p><ul><li>Size</li><li>Location</li><li>Bedrooms</li></ul><p>Naive Bayes assumes they don’t affect each other (which is often not true).</p><p>That’s why it’s called <strong>“Naive”</strong>.</p><h3>Visual 1: Working Flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HJa_9fQzsZOl0xy7" /></figure><h3>5. How Naive Bayes Works (Step-by-Step)</h3><h3>Step 1: Collect training data</h3><p>Example:</p><h3>Weather Prediction (Play Tennis or Not)</h3><p>Imagine we want to teach the Naive Bayes model to predict:</p><p><strong>“Should we play tennis today?”</strong></p><p>To do this, we give the model past weather examples with the correct answers.</p><p>For example:</p><ul><li>Sunny, Hot, High Humidity, Not Windy → Do Not Play</li><li>Sunny, Hot, High Humidity, Windy → Do Not Play</li><li>Cloudy, Hot, High Humidity, Not Windy → Play</li><li>Rainy, Mild, High Humidity, Not Windy → Play</li><li>Rainy, Cool, Normal Humidity, Not Windy → Play</li><li>Rainy, Cool, Normal Humidity, Windy → Do Not Play</li><li>Cloudy, Cool, Normal Humidity, Windy → Play</li></ul><h3>Step 2: Calculate probabilities</h3><p>Example:</p><p>Probability of Spam:</p><p>P(Spam)=2/3</p><h3>Step 3: Check word probabilities</h3><p>Example:</p><p>Probability of word “Free” in spam emails:</p><p>P(Free∣Spam)</p><h3>Step 4: Multiply probabilities</h3><p>Naive Bayes combines all probabilities and chooses the highest one.</p><p><strong>Visual 2: Probability Example</strong></p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/0*JaqpzHVLncVrUcQq" /></figure><h3>6. Types of Naive Bayes</h3><h3>Gaussian Naive Bayes</h3><p>Used for <strong>continuous numerical data</strong></p><p>Examples:</p><ul><li>Height</li><li>Salary</li><li>Temperature</li></ul><h3>Multinomial Naive Bayes</h3><p>Used for <strong>text classification</strong></p><p>Examples:</p><ul><li>Spam detection</li><li>Sentiment analysis</li></ul><h3>Bernoulli Naive Bayes</h3><p>Used for <strong>binary features (Yes/No)</strong></p><p>Example:</p><ul><li>Contains word “free”? Yes/No</li></ul><h3>Conclusion</h3><p>Naive Bayes is a simple, fast, and efficient machine learning classification algorithm based on probability and Bayes’ Theorem. It is especially useful for text classification tasks such as spam detection, sentiment analysis, and document categorization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee4c1311e2eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear Regression]]></title>
            <link>https://medium.com/@kotturjyothi369/linear-regression-4a1c67636a66?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a1c67636a66</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Fri, 22 May 2026 10:00:26 GMT</pubDate>
            <atom:updated>2026-05-22T10:00:26.463Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linear Regression: The Foundation of Machine Learning</h3><h3>Introduction</h3><p>Linear Regression is one of the simplest and most important algorithms in Machine Learning. It helps us understand the relationship between variables and predict future values.</p><p>For example:</p><ul><li>Predicting house prices based on size</li><li>Predicting student marks based on study hours</li><li>Predicting sales based on advertising budget</li></ul><p>Because of its simplicity and interpretability, Linear Regression is often the <strong>first algorithm every data scientist learns</strong>.</p><h3>What is Linear Regression?</h3><p>Linear Regression is a <strong>supervised machine learning algorithm</strong> used for predicting continuous numerical values.</p><p>It tries to find the <strong>best-fit straight line</strong> through the data points.</p><p>The equation of a linear regression line is:</p><p>y=mx+by = mx + by=mx+b</p><p>mmm</p><p>bbb</p><p>-10–8–6–4–2246810–10–5510y-interceptx-intercept</p><p>Where:</p><ul><li><strong>y</strong> = predicted value</li><li><strong>x</strong> = input feature</li><li><strong>m</strong> = slope of the line</li><li><strong>b</strong> = intercept</li></ul><h3>Real-Life Example</h3><p>Imagine you want to predict a student’s exam marks based on study hours.</p><p>Study HoursExam Marks130240350460570</p><p>The relationship forms a straight-line pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aX1yj7dmkF0k7CvQ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/0*GDU4Hch-_msDJKj2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EMVd1PyRVV7J9U5p" /></figure><p>The regression line helps predict future values such as:</p><ul><li>If a student studies 6 hours → predicted marks may be 80.</li></ul><h3>How Linear Regression Works</h3><p>Linear Regression works in three simple steps:</p><h3>1. Collect Data</h3><p>The algorithm first collects input and output values.</p><p>Example:</p><ul><li>Input (X): Study Hours</li><li>Output (Y): Marks</li></ul><h3>2. Find the Best Fit Line</h3><p>The algorithm draws a line that minimizes prediction errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*ipwmVHyoHdsS1lzX" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E-Fqv5Vyv6aKQIXS" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UpmwlFGSRm1NtcF2" /></figure><h3>3. Predict Future Values</h3><p>Once the line is created, new predictions become easy.</p><p>Example:</p><ul><li>Input = 7 study hours</li><li>Output = Predicted marks</li></ul><h3>Types of Linear Regression</h3><h3>1. Simple Linear Regression</h3><p>Uses:</p><ul><li>One input variable</li><li>One output variable</li></ul><p>Example:</p><ul><li>Predict salary using years of experience</li></ul><p>Equation:</p><p>y=b0+b1xy = b_0 + b_1xy=b0​+b1​x</p><h3>2. Multiple Linear Regression</h3><p>Uses:</p><ul><li>Multiple input variables</li><li>One output variable</li></ul><p>Example:<br> Predict house price using:</p><ul><li>Area</li><li>Number of bedrooms</li><li>Location</li></ul><p>Equation:</p><p>y=b0+b1x1+b2x2+b3x3+⋯+bnxny = b_0 + b_1x_1 + b_2x_2 + b_3x_3 + \cdots + b_nx_ny=b0​+b1​x1​+b2​x2​+b3​x3​+⋯+bn​xn​</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YblMXRkUqnkQTsmD" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pK-axsOxuPvZLFUS" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*obPi3KP553NLrVH-" /></figure><h3>Important Terminologies</h3><h3>1. Dependent Variable</h3><p>The value we want to predict.</p><p>Example:</p><ul><li>House Price</li><li>Student Marks</li></ul><h3>2. Independent Variable</h3><p>The input feature used for prediction.</p><p>Example:</p><ul><li>Study Hours</li><li>House Size</li></ul><h3>3. Slope</h3><p>Shows how much the output changes when input changes.</p><h3>4. Intercept</h3><p>The point where the regression line crosses the y-axis.</p><h3>Cost Function in Linear Regression</h3><p>The model tries to reduce prediction error using a <strong>Cost Function</strong>.</p><p>Most commonly used:</p><h3>Mean Squared Error (MSE)</h3><p>MSE=1n∑i=1n(yi−y^i)2MSE = \frac{1}{n}\sum_{i=1}^{n}(y_i-\hat{y}_i)²MSE=n1​∑i=1n​(yi​−y^​i​)2</p><p>Where:</p><ul><li>yiy_iyi​ = actual value</li><li>y^i\hat{y}_iy^​i​ = predicted value</li></ul><p>Lower MSE means better predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xYqz7KiAgZrym4EL" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*R72teQ16Te5FggcY" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*ita1y7rcVn6Q3Kmq" /></figure><h3>Assumptions of Linear Regression</h3><p>Linear Regression works best when these assumptions are satisfied:</p><ol><li>Linear relationship between variables</li><li>No multicollinearity</li><li>Homoscedasticity</li><li>Normal distribution of errors</li><li>Independence of observations</li></ol><h3>Advantages of Linear Regression</h3><p>## Easy to understand<br> ## Fast and efficient<br> ## Works well for linear data<br> ## Highly interpretable<br> ## Strong baseline algorithm</p><h3>Disadvantages of Linear Regression</h3><p>## Performs poorly on non-linear data<br> ## Sensitive to outliers<br> ## Assumes linear relationships<br> ## Can underfit complex datasets</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/0*c-y-Y-npKFHoFuTs" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jP4jKz5QiirC2MWq" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/0*z8k_W4P4OayFVSpv" /></figure><p>7</p><h3>Applications of Linear Regression</h3><p>Linear Regression is used in many industries:</p><p>IndustryApplicationFinanceStock predictionHealthcareDisease predictionReal EstateHouse price predictionMarketingSales forecastingEducationStudent performance prediction</p><h3>Linear Regression in Python</h3><pre>from sklearn.linear_model import LinearRegression<br>from sklearn.model_selection import train_test_split<br>import pandas as pd</pre><pre># Sample data<br>X = df[[&#39;Study_Hours&#39;]]<br>y = df[&#39;Marks&#39;]</pre><pre># Split data<br>X_train, X_test, y_train, y_test = train_test_split(<br>    X, y, test_size=0.2, random_state=42<br>)</pre><pre># Create model<br>model = LinearRegression()</pre><pre># Train model<br>model.fit(X_train, y_train)</pre><pre># Predict<br>y_pred = model.predict(X_test)</pre><pre>print(y_pred)</pre><h3>Evaluation Metrics</h3><h3>R² Score</h3><p>Measures how well the model explains the data.</p><p>R2=1−SSresSStotR² = 1 — \frac{SS_{res}}{SS_{tot}}R2=1−SStot​SSres​​</p><ul><li>R² = 1 → Perfect model</li><li>R² = 0 → Poor model</li></ul><h3>Visualization of Linear Regression</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*W-NnVTCzikez_C7p" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1qgOzqSk6haOrrKd" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gNRyweUieSHY2BMG" /></figure><p>The graph above shows:</p><ul><li>Data points</li><li>Best-fit regression line</li><li>Prediction trend</li></ul><h3>Conclusion</h3><p>Linear Regression is the backbone of Machine Learning and Data Science. Despite being simple, it is powerful for understanding relationships between variables and making predictions.</p><p>It is widely used because:</p><ul><li>Easy to implement</li><li>Fast to train</li><li>Easy to interpret</li></ul><p>Mastering Linear Regression helps build a strong foundation for advanced Machine Learning algorithms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a1c67636a66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Complete Guide to Feature Selection Techniques in Machine Learning]]></title>
            <link>https://medium.com/@kotturjyothi369/the-complete-guide-to-feature-selection-techniques-in-machine-learning-90673e49fdad?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/90673e49fdad</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[feature-selection]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[forward-selection]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Fri, 22 May 2026 09:20:38 GMT</pubDate>
            <atom:updated>2026-05-22T09:20:38.470Z</atom:updated>
            <content:encoded><![CDATA[<p>How to choose the right features, reduce dimensionality, and build models that actually generalize — with practical Python examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FY64l6dnh0SCXAe8.jpeg" /></figure><p>Feature selection is the process of identifying and retaining only the most informative variables for your model. Done well, it reduces overfitting, cuts training time, improves interpretability, and — crucially — makes your model more robust in production.</p><p>In this guide, we’ll walk through the three main families of feature selection techniques, their trade-offs, and when to use each one, complete with Python code you can drop straight into your workflow.</p><h3>Why Feature Selection Matters</h3><p>Modern datasets routinely arrive with hundreds or thousands of columns. But quantity rarely equals quality. Many of those columns will be correlated with each other, statistically independent of the target, or simply noise. Feeding all of them into a model creates several problems:</p><h3>Overfitting</h3><p>Too many features gives the model too many knobs to turn, causing it to memorize training data rather than learn patterns.</p><h3>Slow Training</h3><p>Complexity grows with dimensionality. More features mean more computation, especially for tree ensembles and SVMs.</p><h3>Interpretability</h3><p>A model with 5 key features is explainable to stakeholders. A model with 500 is not.</p><h3>The Three Families of Feature Selection</h3><p>All feature selection methods fall into one of three broad categories. Understanding the distinction is fundamental — each carries different assumptions about what makes a feature “good” and a different computational cost.</p><ul><li>Filter Methods</li><li>Wrapper Methods</li><li>Embedded Methods</li></ul><h3>1. Filter Methods</h3><p>Filter methods rank features by their individual relationship to the target variable, using statistical scores. They’re fast enough to run on millions of rows with thousands of columns, and make no assumptions about what model you’ll use downstream.</p><h3>Common Filter Techniques:</h3><h3>a) Correlation Method</h3><p>The <strong>Correlation Method</strong> is a <strong>filter-based feature selection technique</strong> used to measure the relationship between input features and the target variable.</p><p>It helps identify which features are strongly related to the output and removes features that have little or no impact on prediction.</p><ul><li>High correlation → Important feature</li><li>Low correlation → Less useful feature</li></ul><p>For example:</p><ul><li>In student marks prediction, <strong>study hours</strong> may have high correlation with marks.</li><li><strong>Student ID</strong> may have very low correlation and can be removed.</li></ul><h3>Correlation Formula</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/0*j3NuQeup_FcP9GJL.png" /></figure><h3>Correlation Value Range</h3><p>. +1→Strong positive relationship</p><ul><li>0→ No relationship</li><li>-1→Strong negative relationship</li></ul><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pi3pfQZQ0vLakL0L.jpeg" /></figure><h3>b) Chi-Square Test</h3><p>The Chi-Square Test is a filter-based feature selection technique used to measure the relationship between categorical input features and the categorical target variable.</p><p>It checks whether a feature is dependent on the target variable or not.</p><ul><li>Higher Chi-Square value → More important feature</li><li>Lower Chi-Square value → Less important feature</li></ul><p>The Chi-Square test is commonly used in:</p><ul><li>Classification problems</li><li>Text classification</li><li>Categorical datasets</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/0*7dXq5aSh5xpFmL3U.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yx0wi3mDtHw9o8n4.jpeg" /></figure><h3>c) Mutual Information</h3><p><strong>Mutual Information (MI)</strong> is a <strong>filter-based feature selection technique</strong> used to measure how much information one variable provides about another variable.</p><p>In Machine Learning, it measures the dependency between:</p><ul><li>Input feature (X)</li><li>Target variable (Y)</li></ul><p>If a feature gives more information about the target, it is considered more important.</p><ul><li>High Mutual Information → Strong relationship</li><li>Low Mutual Information → Weak relationship</li></ul><p>Unlike correlation, Mutual Information can detect both:</p><ul><li>Linear relationships</li><li>Non-linear relationships</li></ul><h3>Mutual Information Formula</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*epmcZHRrZQgN_e-Y.png" /></figure><h3>Advantages</h3><ul><li>Detects non-linear relationships</li><li>Works well with classification problems</li><li>Useful for high-dimensional datasets</li></ul><h3>2. Wrapper Methods</h3><p>Wrapper methods treat feature selection as a search problem. They evaluate candidate feature subsets by training a model and measuring performance — giving them awareness of feature interactions that filter methods miss entirely.</p><h3>Common Wrapper Techniques:</h3><h3>a) Forward Selection</h3><p><strong>Forward Selection</strong> is a <strong>wrapper-based feature selection technique</strong> used to select the best features step-by-step.</p><p>It starts with <strong>no features</strong> and gradually adds the most important feature that improves the model performance.</p><p>The process continues until adding new features no longer improves accuracy.</p><h3>Steps in Forward SelectionStart with an empty feature set</h3><ol><li>Test each feature individually</li><li>Select the feature with best performance</li><li>Add the next best feature</li><li>Repeat until no improvement occurs</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/0*FV3Td_hMKR57Tt08" /></figure><h3>Advantages</h3><ul><li>Simple to understand</li><li>Reduces unnecessary features</li><li>Improves model performance</li></ul><h3>Disadvantages</h3><ul><li>Computationally expensive</li><li>Slow for large datasets</li></ul><h3>b) Backward Elimination</h3><p>Backward Elimination is a wrapper-based feature selection technique used to remove less important features from a dataset.It starts with all features and removes the least significant feature one by one based on model performance.</p><p>The process continues until only important features remain.</p><p><strong>Steps in Backward Elimination</strong></p><ol><li>Start with all features</li><li>Train the machine learning model</li><li>Identify the least important feature</li><li>Remove that feature</li><li>Repeat the process until performance decreases</li></ol><p>Advantages</p><ul><li>Finds important features effectively</li><li>Improves model accuracy</li><li>Works well with smaller datasets</li></ul><p>Disadvantages</p><ul><li>Computationally expensive</li><li>Slow for large datasets</li><li>Requires repeated model</li></ul><h3>c) Recursive Feature Elimination (RFE)</h3><p>Recursive Feature Elimination (RFE) is a wrapper-based feature selection technique used to select the most important features by repeatedly removing the least important features.</p><p>RFE trains a machine learning model multiple times and eliminates weak features step-by-step until the desired number of features remains.</p><p><strong>How RFE Works:</strong></p><ol><li>Train the model using all features</li><li>Calculate feature importance</li><li>Remove the least important feature</li><li>Train the model again</li><li>Repeat the process recursively</li></ol><p><strong>Algorithms Commonly Used with RFE</strong></p><ul><li>Logistic Regression</li><li>Random Forest</li><li>Support Vector Machine (SVM)</li><li>Decision Tree</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xAEYaXtN5wdNRhKV.jpeg" /></figure><p>Advantages</p><ul><li>Selects highly important features</li><li>Improves model performance</li><li>Reduces overfitting</li></ul><p>Disadvantages</p><ul><li>Computationally expensive</li><li>Slow for large datasets</li><li>Requires repeated training</li></ul><h3>3. Embedded Methods</h3><p>Embedded methods are the sweet spot. Feature selection is woven into the model training process itself, making them more efficient than wrappers while still capturing feature interactions. The two most important are LASSO regularization and tree-based feature importance.</p><p><strong>Common Embedded Techniques:</strong></p><p><strong>a) Lasso Regression (L1 Regularization)</strong></p><p>LASSO adds a penalty to the model’s loss function proportional to the absolute values of coefficients. As the regularization strength increases, less informative feature coefficients are driven exactly to zero — effectively removing them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_FAm2znTmo-XbVQH.jpeg" /></figure><h3>How Lasso Works</h3><ul><li>Important features → Keep non-zero coefficients</li><li>Less important features → Coefficients become zero</li></ul><p>This helps in:</p><ul><li>Feature selection</li><li>Reducing overfitting</li><li>Improving model simplicity</li></ul><h3>Advantages</h3><ul><li>Performs feature selection automatically</li><li>Reduces overfitting</li><li>Works well with high-dimensional data</li></ul><h3>Disadvantages</h3><ul><li>Can remove useful correlated features</li><li>Performance depends on choosing correct lambda value</li></ul><h3>b) Tree-Based Feature Importance</h3><p>Tree-Based Feature Importance is an embedded feature selection technique used in tree algorithms like:</p><ul><li>Decision Tree</li><li>Random Forest</li><li>XGBoost</li></ul><p>These algorithms automatically calculate how important each feature is during model training.</p><p>Features that contribute more to decision-making get higher importance scores.</p><h3>How It Works</h3><p>Tree-based models split data using important features.</p><ul><li>Features used frequently in splits → Higher importance</li><li>Features rarely used → Lower importance</li></ul><p>The model ranks features based on their contribution.</p><h3>Advantages</h3><ul><li>Automatic feature selection</li><li>Handles non-linear relationships</li><li>Works well with large datasets</li><li>Easy to visualize feature importance</li></ul><h3>Disadvantages</h3><ul><li>Can favor features with many unique values</li><li>Different trees may produce different importance scores</li></ul><h3>When to Use</h3><h3>Use Feature Selection When:</h3><ul><li>Dataset contains irrelevant columns</li><li>Interpretability is important</li><li>Training speed matters</li></ul><h3>Use Feature Extraction When:</h3><ul><li>Dataset has very high dimensions</li><li>Features are highly correlated</li><li>Complex patterns exist in data</li></ul><h3>Advantages of Feature Selection</h3><ul><li>Reduces model complexity</li><li>Faster training</li><li>Better accuracy</li><li>Less memory usage</li><li>Reduces dimensionality</li><li>Improves interpretability</li></ul><h3>Disadvantages of Feature Selection</h3><ul><li>Important features may be accidentally removed</li><li>Wrapper methods are computationally expensive</li><li>Different techniques may produce different feature subsets</li></ul><h3>Real-World Applications</h3><h3>Healthcare</h3><p>Selecting important medical indicators for disease prediction.</p><h3>Finance</h3><p>Choosing important financial metrics for fraud detection.</p><h3>Text Classification</h3><p>Selecting important words from documents.</p><h3>Image Processing</h3><p>Reducing unnecessary image features.</p><h3>Conclusion</h3><p>Feature Selection is one of the most important preprocessing techniques in Machine Learning. It helps improve model performance by selecting only the most relevant features from the dataset.</p><p>The three major categories are:</p><ul><li>Filter Methods → Fast and simple</li><li>Wrapper Methods → More accurate but slower</li><li>Embedded Methods → Efficient and powerful</li></ul><p>Choosing the right feature selection method depends on:</p><ul><li>Dataset size</li><li>Number of features</li><li>Model type</li><li>Computational resources</li></ul><p>A good feature selection strategy leads to faster, simpler, and more accurate machine learning models.</p><p><a href="https://medium.com/tag/python?source=post_page-----cc9fb1c76b42---------------------------------------">Python</a></p><p><a href="https://medium.com/tag/data-science?source=post_page-----cc9fb1c76b42---------------------------------------">Data Science</a></p><p><a href="https://medium.com/tag/machine-learning?source=post_page-----cc9fb1c76b42---------------------------------------">Machine Learning</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90673e49fdad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[K-Nearest Neighbors (KNN) Algorithm]]></title>
            <link>https://medium.com/@kotturjyothi369/k-nearest-neighbors-knn-algorithm-420dc32c6c15?source=rss-a44bcb4bd489------2</link>
            <guid isPermaLink="false">https://medium.com/p/420dc32c6c15</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[knn-algorithm]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Kotturjyothi]]></dc:creator>
            <pubDate>Wed, 20 May 2026 10:27:25 GMT</pubDate>
            <atom:updated>2026-05-20T10:27:25.119Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. What is KNN?</h3><p>KNN is a <strong>supervised machine learning algorithm</strong> used for:</p><ul><li>Classification</li><li>Regression</li></ul><p>It works by:</p><p>Finding the nearest data points and predicting based on their majority</p><p>Example:</p><ul><li>If most nearby points are <strong>cats</strong>, the new point is predicted as <strong>cat</strong>.</li></ul><h3>2. Basic KNN Visualization</h3><p>This is the BEST first image for beginners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wlTmitrVh9l5SF6M" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/0*Is7dqB0D3eLndAKu" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*bpsUc8g8cFiKzvlC" /></figure><h3>Explanation for article:</h3><ul><li>Blue dots = Class A</li><li>Red dots = Class B</li><li>Green point = New unknown data point</li><li>KNN checks nearest neighbors</li><li>Majority class becomes prediction</li></ul><h3>3. Step-by-Step Working of KNN</h3><p>Use this process flow image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P1Ta4rG74J5hp7I8" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XM2yiT5g9qLoVask" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/0*VQlsqT2DJsIC7ogs" /></figure><h3>Steps to explain:</h3><ol><li>Choose value of K</li><li>Calculate distance</li><li>Find nearest neighbors</li><li>Count majority class</li><li>Predict output</li></ol><h3>4. Understanding “K Value”</h3><p>This is VERY important in KNN articles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/0*lId60sAU2pHTLM2U" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qag5FaTnwxfhbfCc" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dQpVlU3azMQiblBr" /></figure><h3>Explanation:</h3><ul><li>Small K → Sensitive to noise</li><li>Large K → Smoother prediction</li><li>Best K balances accuracy</li></ul><p>Example:</p><ul><li>K=1 → One nearest neighbor</li><li>K=5 → Five nearest neighbors</li></ul><h3>5. Distance Calculation Visualization</h3><p>KNN mainly uses distance metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l3wh_V3lFWaM3tlp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vEcvqYrlvUJezk1P" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4qKCjUTiQeugUgSa" /></figure><p>Use this formula in article:</p><p>d = \sqrt{(x_2-x_1)² + (y_2-y_1)²}</p><h3>Explaination:</h3><p>The algorithm calculates how close points are using distance formulas.</p><h3>6. Real-Life Example Visualization</h3><p>Readers love practical examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sx-Ql4s-6RE2U8AF" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KSPyEqP3Bor8g5UF" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*QqLMNfTO-GvbVCVj" /></figure><h3>Real-world uses:</h3><ul><li>Movie recommendations</li><li>Face recognition</li><li>Medical diagnosis</li><li>Spam detection</li></ul><h3>7. KNN Classification Boundary</h3><p>This makes your article look professional.</p><h3>Explain:</h3><p>KNN creates boundaries between classes based on neighboring data points.</p><h3>8. Advantages vs Disadvantages Visual</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/0*cELock05rvl4_al5" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qCtPJ4fl6te04cf8" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*XxKE_5V4un0KNNZR" /></figure><h3>Advantages</h3><ul><li>Simple to understand</li><li>Easy to implement</li><li>No training phase</li></ul><h3>Disadvantages</h3><ul><li>Slow with large datasets</li><li>Sensitive to noise</li><li>Needs feature scaling</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=420dc32c6c15" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>