<?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 Sachin Urunkar on Medium]]></title>
        <description><![CDATA[Stories by Sachin Urunkar on Medium]]></description>
        <link>https://medium.com/@saurunkar?source=rss-dece8fad3e50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*q15rkOto4vbnymC5rDMpxA.jpeg</url>
            <title>Stories by Sachin Urunkar on Medium</title>
            <link>https://medium.com/@saurunkar?source=rss-dece8fad3e50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:18:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saurunkar/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[Building your first Machine Learning model]]></title>
            <link>https://medium.com/@saurunkar/building-your-first-machine-learning-model-cd71fc6663eb?source=rss-dece8fad3e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd71fc6663eb</guid>
            <category><![CDATA[iris-flower]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <dc:creator><![CDATA[Sachin Urunkar]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 18:03:31 GMT</pubDate>
            <atom:updated>2022-08-27T14:58:19.936Z</atom:updated>
            <content:encoded><![CDATA[<h3>A step-by-step guide to build Machine Learning model from scratch</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*OrF3JARgoTpwH5MGa7-EBg.png" /></figure><p>Are you a Machine Learning enthusiast and looking to start your journey with the help of Python ? Confused about how to start building your first ML model, reading through lots of blogs about different ML algorithms which explains every bit of models, their mathematical intuition but failed to show how exactly use it with datasets?</p><p>You may have came across lots of reading material, free online courses, videos which will give you lots of recipes and snippets, but you never get to see how this all fits together. I will help you, with this story here, to complete your first machine learning project using Python.</p><p>In this step-by-step tutorial you will get to know:</p><ul><li>How to load a dataset and understand it’s structure using statistical summaries and data visualization.</li><li>How to create different machine learning models, pick the best and build confidence that the accuracy is reliable.</li></ul><p>When we start working with data for machine learning problem, we call it a project. And irrespective of the type of problem (ie. linear, classification, clustering etc.), steps involved in ML project are:</p><ol><li>Define a problem</li><li>Understand and prepare data</li><li>Choose and train the model</li><li>Evaluate your models performance</li><li>Improve your model</li><li>Predict results</li></ol><p>Before starting make sure you have all the libraries required are installed. We will use following libraries :</p><ul><li>numpy</li><li>matplotlib</li><li>pandas</li><li>seaborn</li><li>sklearn</li></ul><p>If you are using Jupyter Notebook (Anaconda 3), it includes everything we need.</p><p>As a beginner, when I started my journey in Machine Learning, I built first model on Iris flower dataset. It is classical example to understand classification model and has multi nominal classification. A small dataset with five columns (features) and 150 rows (instances) will not take much time in training a model and can run on virtually any machine. In this dataset, all of the numeric attributes are in the same units and the same scale, not requiring any special scaling or transforms to get started.</p><p>Let’s get started with your first machine learning project in Python.</p><ol><li><strong>Import Libraries</strong></li></ol><p>Let’s import all the modules, functions and objects we are going to use in this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*SV2arSYtDLd6u1aUaquoQw.png" /></figure><p>It is good practice to import all we need first hand. Preprocessing libraries, ML Models and Performance Metrics are imported in the sequence we use them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*RSsXBnB_IOtjd1HNQFQoog.png" /></figure><p><strong>2. Import dataset</strong></p><p>we will use seaborn method to load iris dataset. There are other ways available as well, but seaborn will give you a ready dataframe object, and I found this the easiest way to do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*1I4D3tF2_NJrNAGMbMbKRA.png" /></figure><p><strong>3. Data Description</strong></p><p>It is good practice to check your data and peek at it. shape, columns, head() will give you idea of number of features and instances (columns,rows), what are the features and type of data you have in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*n7ymRJ0VhrfRnoAsl52m3A.png" /></figure><p>info function will give all this information with additional information of null values present in data (there is no null instances in iris dataset) and describe function will summarize the statistical information about the numerical attributes. It includes count, min, mean, max, std (standard deviation) and some percentiles as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*HpbLQiETx9z9vk8V7C7bsw.png" /></figure><p>All the numerical attributes are in same scale and range. Hence, we need no scaling, standardization or normalization methods to be used here.</p><p>The only categorical feature we have is <em>“species”, </em>let’s see how many categories it has and number of instances of each category.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*skkIXtQ6SCsID6R2jG-Juw.png" /></figure><p>Setosa, Versicolor and Virginica are three categories and all of them have fifty instances each. This is an example of balanced data and thus no balancing techniques are required to be used.</p><p><strong>4. Data Visualization</strong></p><p>Visualization will extend the findings in last step and help us in finalizing the problem we need to solve. Two types of plots namely <em>“Uni-variate”</em> and <em>“Bi-variate”</em> are helpful in understanding each attribute and relationship between attributes respectively.</p><p>Box plot and histogram are used for uni-variate plots and for bi-variate analysis we use pair plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*dGL-yEupbiZgssHwjgWC4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*pHMaDYd29OfW6uN9F9cfiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*_7T-z0Ew9SsWi9Viut71KA.png" /></figure><p><strong>5. Evaluating Algorithms</strong></p><p>In this steps, we need to prepare our data for model training and testing before building a model. First four numeric attributes will make our X part (ie. independent attributes or input) and categorical attribute (<em>“species”</em>) will form our Y (ie. dependent variable or output ). We will keep 20 % data for testing part and remaining 80% will be used for testing purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*Avc5D49Wq2ZJAs6B8s39ww.png" /></figure><p>We will use stratified K-fold cross validation to estimate model accuracy with K=10.This will split our dataset into 10 parts, train on 9 and test on 1 and repeat for all combinations of train-test splits. Stratified means that each fold or split of the dataset will aim to have the same distribution of example by class as exist in the whole training dataset.</p><p>To evaluate model, we will use metric of “Accuracy”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*7gW8mAtjB86TaB2hhR2qUA.png" /></figure><p>Five different algorithms are tested above, namely, Logistic Regression (LR), K-Nearest Neighbors (KNN), Decision Tree (DT), Gaussian Naive Bayes (NB) and Support Vector Machines (SVM) with accuracy estimation for each model.</p><p><em>Note: Your results can be way different than this given the stochastic nature of algorithms or randomness of data in train test split.</em></p><p><strong>6. Predictions</strong></p><p>As SVM resulted the highest accuracy, we will use this as our final model and will check it for our validation dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*Q3YxKXBR-IKx-lhNssjk7w.png" /></figure><p>We can evaluate the predictions by comparing them to the expected results in the validation set, then calculate classification accuracy, as well as a confusion matrix and a classification report.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*BnIL-PQintX1KAhoo4HhxQ.png" /></figure><p>We can see the accuracy on the hold out dataset. The confusion matrix provides an indication of the errors made.</p><p>Finally, the classification report provides a breakdown of each class by precision, recall, f1-score and support showing results</p><p><em>Note: As the validation dataset was small, we can often see overfitting to the training set or a data leak issues. Both of these issues will result in an overly optimistic result.</em></p><p>Find the relevant notebook <a href="https://github.com/saurunkar/Your-first-ML-project">here</a></p><h3>Summery</h3><p>In this post, I tried to cover every step for your first machine learning project with Python. As the Iris dataset itself is clean and balanced, it does not require any preprocessing, and that one step can be the biggest work to do, if you came across some other messy dataset.</p><p>With real datasets, you may have to spend a lot of time understanding the data, cleaning and balancing it, scaling or transforming data and do feature selection / feature engineering, before actually deciding about the ML model to be fit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd71fc6663eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>