<?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 Akram KAID on Medium]]></title>
        <description><![CDATA[Stories by Akram KAID on Medium]]></description>
        <link>https://medium.com/@Akram.KAID?source=rss-0d432685e11b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*O7rFUcEvfkxKkb3_nWG6OQ.jpeg</url>
            <title>Stories by Akram KAID on Medium</title>
            <link>https://medium.com/@Akram.KAID?source=rss-0d432685e11b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 16:11:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Akram.KAID/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[Iris Flower Classification: A Beginner’s Guide to Machine Learning Models]]></title>
            <link>https://medium.com/@Akram.KAID/iris-flower-classification-a-beginners-guide-to-machine-learning-models-b74f8bf54956?source=rss-0d432685e11b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b74f8bf54956</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Akram KAID]]></dc:creator>
            <pubDate>Tue, 18 Feb 2025 19:15:28 GMT</pubDate>
            <atom:updated>2025-02-18T19:15:28.397Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning (ML) is revolutionizing industries, from healthcare to finance. But for beginners, understanding how ML models work can be overwhelming. One of the best ways to start is by working with the <strong>Iris Flower Dataset</strong>, a simple yet powerful dataset that allows you to explore different ML algorithms and key concepts such as <strong>overfitting, evaluation metrics, and model tuning.</strong></p><p>This article walks you through the entire ML pipeline: <strong>understanding models, evaluation metrics, optimization functions, and experimenting with different algorithms</strong> — all while explaining fundamental ML concepts with mathematical insights.</p><h3>1. What is Machine Learning?</h3><p>At its core, <strong>Machine Learning</strong> is a field of artificial intelligence where computers learn from data without being explicitly programmed. Instead of writing code with fixed rules, we train a model to recognize patterns in data.</p><h3>Types of Machine Learning</h3><ul><li><strong>Supervised Learning:</strong> The model learns from labeled data (e.g., classifying flowers based on features).</li><li><strong>Unsupervised Learning:</strong> The model finds patterns in unlabeled data (e.g., customer segmentation).</li><li><strong>Reinforcement Learning:</strong> The model learns by interacting with an environment (e.g., training robots to walk).</li></ul><p>Since the <strong>Iris dataset</strong> contains labeled samples, we use <strong>Supervised Learning</strong> for classification.</p><h3>2. Understanding the Iris Dataset</h3><p>The <strong>Iris dataset</strong> consists of <strong>150 samples</strong> of three flower species:</p><ul><li><strong>Setosa</strong></li><li><strong>Versicolor</strong></li><li><strong>Virginica</strong></li></ul><p>Each sample has <strong>four features</strong>:</p><ul><li>Sepal Length</li><li>Sepal Width</li><li>Petal Length</li><li>Petal Width</li></ul><p>Our goal is to build a model that <strong>classifies flowers based on these four features.</strong></p><h3>3. Key ML Concepts for Beginners</h3><h3>What is a Model?</h3><p>A <strong>model</strong> in ML is a mathematical function that maps inputs (features) to outputs (predictions). It learns from data by adjusting its parameters to minimize errors.</p><h3>What is Accuracy?</h3><p><strong>Accuracy</strong> is the ratio of correctly predicted samples to the total samples. While accuracy is useful, we must also look at other metrics to ensure the model generalizes well.</p><h3>What is Overfitting?</h3><p>A model is <strong>overfitting</strong> when it memorizes the training data instead of learning general patterns. This leads to <strong>100% accuracy</strong> on training data but poor performance on new data.</p><h3>Optimization Functions (Gradient Descent)</h3><ul><li><strong>Gradient Descent</strong> is the algorithm used to minimize the model’s loss function. It adjusts the model’s parameters step by step to improve predictions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*XNpaxAYSHjkYcP7_gIF5ZQ.png" /></figure><ul><li><strong>Loss Functions </strong>(Cross-Entropy Loss)</li></ul><p>For classification, we use <strong>Cross-Entropy Loss</strong>, which measures how different the predicted probabilities are from the actual labels:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*VQITKEv3P-6Ci2S0ew5smQ.png" /></figure><h3>4. Experimenting with Different Models</h3><p>We tested multiple models to classify the Iris dataset. Below are the results and key findings, along with relevant mathematical concepts.</p><h3>(a) Logistic Regression (Linear Model)</h3><ul><li>Uses the <strong>sigmoid function</strong> to predict probabilities:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*r2j5sWkGq4eMVTM0VfKclw.png" /></figure><ul><li>Works well for simple datasets but struggles with complex relationships.</li></ul><h3>(b) Decision Tree</h3><ul><li>Uses a tree-like structure to split the data based on information gain.</li><li>Splitting criterion often based on <strong>Gini Impurity</strong>:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*RtRBuYG0rb17cG0mP_P9hA.png" /></figure><ul><li>Overfits if not pruned properly.</li></ul><h3>(c )Random Forest (Ensemble of Decision Trees)</h3><ul><li>Combines multiple decision trees to improve generalization.</li><li>Uses <strong>Bagging</strong> to reduce variance.</li><li>Still overfits on small datasets.</li></ul><h3>(d) K-Nearest Neighbors (KNN)</h3><ul><li>Uses distance metrics to classify samples.</li><li>Common metric: <strong>Euclidean Distance</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*eVuT3SOQGh0P-q7XwUa3Tg.png" /></figure><ul><li>Overfits on small datasets.</li></ul><h3>(e) Support Vector Machine (SVM)</h3><ul><li>Finds the optimal hyperplane to separate classes.</li><li>Uses <strong>Kernel Trick</strong> for non-linear data:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*qBdunkjIfwPg9QohIixzRA.png" /></figure><h3>(f) Multilayer Perceptron (MLP — Neural Networks)</h3><ul><li>Uses multiple layers of neurons.</li><li>Applies <strong>Backpropagation</strong> to update weights using:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*_8v-9IiZ3gTk6JDAgqqSrQ.png" /></figure><ul><li>Overfits due to dataset size.</li></ul><h3>(g) XGBoost (Extreme Gradient Boosting)</h3><ul><li>Uses boosting to improve model performance.</li><li>Loss function:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*1XYgXZKeZD1oN6gwbUmCWQ.png" /></figure><ul><li>Still overfits due to high model complexity.</li></ul><h3>5. Overfitting &amp; Regularization Techniques</h3><p>Since several models showed <strong>100% accuracy</strong>, we explored ways to reduce overfitting:</p><ul><li><strong>L1 Regularization (Lasso Regression)</strong>: Encourages sparsity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*EO2_q9AqAhniilxc-VM7SQ.png" /></figure><ul><li><strong>L2 Regularization (Ridge Regression)</strong>: Penalizes large weights.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*hWKfenf1S-2DNmxQisVDiQ.png" /></figure><ul><li><strong>Pruning (for Decision Trees):</strong> Reduces complexity by limiting tree depth.</li><li><strong>Cross-Validation:</strong> Splits data into multiple training and validation sets to test generalization.</li><li><strong>Early Stopping (for XGBoost &amp; Neural Networks):</strong> Stops training when validation performance stops improving.</li></ul><h3>6. Model Performance Comparison</h3><p>After training all models, we visualized the results in a bar graph. Models with <strong>100% accuracy</strong> were labeled as overfitting.</p><h3>Key Observations:</h3><ul><li><strong>Logistic Regression &amp; SVM performed well without overfitting.</strong></li><li><strong>Tree-based models (Decision Trees, Random Forest) overfitted easily.</strong></li><li><strong>XGBoost and Neural Networks were too complex for this dataset.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2k4Ul4BupttHIgP9e3AKsw.png" /></figure><h3>7. Conclusion: What’s the Best Model for Small Datasets?</h3><h3>Final Recommendations:</h3><p>✅ <strong>For small datasets:</strong> Use <strong>Logistic Regression or SVM</strong> (good balance between accuracy and generalization).</p><p>❌ <strong>Avoid deep models (Neural Networks, XGBoost) on small datasets:</strong> They tend to overfit.</p><p>🎯 <strong>Takeaways:</strong></p><ul><li><strong>Start with simple models</strong> before moving to complex ones.</li><li><strong>Check for overfitting</strong> using cross-validation.</li><li><strong>Regularization techniques</strong> help control model complexity.</li></ul><p>For beginners in ML, this project is an excellent way to explore different algorithms and understand how models behave on small datasets.</p><p>If you’re interested in exploring the <strong>full code</strong>, you can check out the project on <strong>GitHub :</strong><a href="https://github.com/KaidAkram/IRIS_Flower"><strong> IRIS_Flower_repo</strong></a></p><p>This article should give beginners a <strong>strong foundation</strong> in ML while also showing practical applications using the Iris dataset. Let me know your thoughts or if you’d like more details on any section! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b74f8bf54956" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>