<?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 Pavithra M on Medium]]></title>
        <description><![CDATA[Stories by Pavithra M on Medium]]></description>
        <link>https://medium.com/@mpavi.pavithra?source=rss-2a7ac9887aaf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0roIVQ14KKc4Tw61</url>
            <title>Stories by Pavithra M on Medium</title>
            <link>https://medium.com/@mpavi.pavithra?source=rss-2a7ac9887aaf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:33:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mpavi.pavithra/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[Understanding the Core Building Blocks of Neural Networks]]></title>
            <link>https://medium.com/@mpavi.pavithra/understanding-the-core-building-blocks-of-neural-networks-3bee5fbba82b?source=rss-2a7ac9887aaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bee5fbba82b</guid>
            <dc:creator><![CDATA[Pavithra M]]></dc:creator>
            <pubDate>Fri, 13 Feb 2026 14:58:06 GMT</pubDate>
            <atom:updated>2026-02-13T14:58:06.619Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Neural Networks</strong></p><p>A neural network is a machine learning model that mimics the human brain to learn patterns from data and make predictions</p><p>Just like the brain has <strong>neurons</strong>, a neural network has <strong>artificial neurons (nodes)</strong> that:</p><ul><li>Receive inputs</li><li>Process them using weights</li><li>Pass the result through an activation function</li><li>Produce an output</li></ul><p>By adjusting the weights during training, the network learns from data.</p><h3>Neuron</h3><p>The building block of a neural network is a neuron.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/0*-5Xh3jRuKxnnyai1.png" /></figure><p>How Neuron works</p><p>In the above illustration, we see</p><blockquote><em>x is the input given to neuron</em></blockquote><blockquote><em>y is the output derived from the neuron</em></blockquote><p>Let’s learn about the other parameters</p><p><strong>1.Connection</strong></p><p>Each Connection is a link between the neuron through which the information flows.</p><p><strong>2.Weight</strong></p><p>Each connection carries a weight, and the weight determines how important the input is. Each input is multiplied by weight.</p><p>So, if the value of the weight is</p><ul><li><strong>Large positive weight</strong> → input strongly increases the output</li><li><strong>Large negative weight</strong> → input strongly decreases the output</li><li><strong>Weight near 0</strong> → input has little or no effect</li></ul><p>It is a learnable parameter that gets adjusted during training — in other words, it represents the model’s understanding of how important each input is, gained through the training process.</p><p><strong>3. Bias</strong></p><p>A <strong>bias</strong> is an extra value added to the weighted sum of inputs before applying the activation function.</p><p><strong>Structure of a Neural Network</strong></p><p>A neural network is made up of <strong>layers</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*SYGIGSVlXLqXghJn.png" /></figure><p><strong>Input Layer</strong></p><ul><li>Takes raw input data (e.g., age, pixels, text features)</li></ul><p><strong>Hidden Layer(s)</strong></p><ul><li>Performs computations and feature learning</li><li>Can be one or many layers (deep learning)</li></ul><p><strong>Output Layer</strong></p><ul><li>Produces the final prediction (e.g., class label, number)</li></ul><p><strong>How It Works (Step-by-Step)</strong></p><ol><li>Input data is fed into the network</li><li>Each neuron multiplies input by weights and adds a bias</li><li>An <strong>activation function</strong> (ReLU, Sigmoid, Tanh, etc.) is applied</li><li>Output is generated</li><li>Error is calculated using a <strong>loss function</strong></li><li>Weights are updated using <strong>backpropagation</strong> and <strong>gradient descent</strong></li></ol><p><strong>Common Activation Functions</strong></p><ul><li><strong>ReLU</strong> — Most commonly used</li><li><strong>Sigmoid</strong> — Binary classification</li><li><strong>Softmax</strong> — Multi-class classification</li><li><strong>Tanh</strong> — Centered output between -1 and 1</li></ul><p><strong>Where Neural Networks Are Used</strong></p><ul><li>Image recognition (face detection, medical imaging)</li><li>Speech recognition</li><li>Natural language processing (chatbots, translation)</li><li>Recommendation systems</li><li>Fraud detection</li><li>Autonomous vehicles</li></ul><p><strong>Advantages</strong></p><ul><li>Can model complex, non-linear relationships</li><li>High accuracy with large datasets</li><li>Automatically learns features</li></ul><p><strong>Limitations</strong></p><ul><li>Requires large amounts of data</li><li>Computationally expensive</li><li>Hard to interpret (black-box nature)</li><li>Prone to overfitting without regularizatio</li></ul><p><strong>Activation Function</strong></p><p>An activation function is a crucial component of a neural network. It decides whether a neuron should be activated or not and introduces non-linearity, which allows neural networks to learn complex patterns<strong>.</strong></p><p><strong>Why Activation Functions Are Important</strong></p><p>Without activation functions:</p><ul><li>A neural network becomes just a linear model, no matter how many layers it has.</li><li>It cannot learn complex relationships (like images, speech, or text).</li></ul><p>Activation functions enable:</p><ul><li>Learning non-linear patterns</li><li>Controlling output range</li><li>Better gradient flow during training</li></ul><p><strong>How an Activation Function Works</strong></p><p>Each neuron computes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*UVJeo-YGfiWU9kE0zZi9qA.png" /></figure><p>Then the activation function transforms it:</p><p>a = f(z)</p><p><strong><em>Common Activation Functions</em></strong></p><p><strong><em>Sigmoid</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*9Cochtq6H_9mPWsgY54p6g.png" /></figure><p><strong><em>Range:</em></strong><em> (0, 1)</em></p><p><strong><em>Used for:</em></strong><em> Binary classification (output layer)</em></p><p><strong><em>Pros</em></strong></p><ul><li><em>Smooth</em></li><li><em>Outputs probability-like values</em></li></ul><p><strong><em>Cons</em></strong></p><ul><li><em>Vanishing gradient problem</em></li><li><em>Not zero-centered</em></li></ul><p><strong><em>Tanh (Hyperbolic Tangent)</em></strong></p><p><strong><em>Range:</em></strong><em> (-1, 1)</em></p><p><strong><em>Pros</em></strong></p><ul><li><em>Zero-centered</em></li><li><em>Stronger gradients than sigmoid</em></li></ul><p><strong><em>Cons</em></strong></p><ul><li><em>Still suffers from vanishing gradients</em></li></ul><p><strong><em>ReLU (Rectified Linear Unit)</em></strong></p><p>f(x) = max(0,x)</p><p><strong><em>Range:</em></strong><em> [0, ∞)</em></p><p><strong><em>Most commonly used activation</em></strong></p><p><strong><em>Pros</em></strong></p><ul><li><em>Fast computation</em></li><li><em>Reduces vanishing gradient problem</em></li><li><em>Sparse activation</em></li></ul><p><strong><em>Cons</em></strong></p><ul><li><strong><em>Dying ReLU</em></strong><em> problem (neurons stuck at 0)</em></li></ul><p><strong>Softmax</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/107/1*AeNcOawtbmJAj4JE2ffdag.png" /></figure><p>· <strong>Used for:</strong> Multi-class classification (output layer)</p><p>· <strong>Output:</strong> Probability distribution (sum = 1).</p><p><strong>Key Problems Solved by Activation Functions</strong></p><ul><li>Vanishing gradient problem → ReLU</li><li>Exploding gradients → Proper initialization &amp; normalization</li><li>Non-linearity → All activation functions</li></ul><p><strong>Overfitting</strong></p><p><strong>Overfitting</strong> happens when a deep learning model learns the <strong>training data too well</strong>, including noise, and performs poorly on unseen data. Below are the <strong>most effective techniques to prevent overfitting</strong>, explained clearly and practically.</p><p><strong>How to Prevent overfitting?</strong></p><p>· Regularization</p><p>· Cross validation</p><p>· Ensemble learning</p><p>· Drop out</p><ol><li><strong>Regularization</strong></li></ol><p><strong>Regularization</strong> adds a <strong>penalty term</strong> to the loss function to discourage overly complex models and large weights.</p><p><strong>L1 Regularization (Lasso)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/1*VZ5WUvMrEMdUk90yLBqb8Q.png" /></figure><p><strong>Effects</strong></p><ul><li>Produces sparse models (some weights = 0)</li><li>Performs feature selection</li></ul><p><strong>L2 Regularization (Ridge)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*TnM4X40SwWXgs1qVzN7Vog.png" /></figure><p><strong>Effects</strong></p><ul><li>Shrinks weights smoothly</li><li>Most commonly used in deep learning</li></ul><p><strong>2. Cross-Validation</strong></p><p><strong>Cross-validation</strong> evaluates model performance by training and testing on <strong>different subsets of data</strong>.</p><p><strong>K-Fold Cross-Validation</strong></p><ol><li>Split data into <strong>K folds</strong></li><li>Train on K–1 folds</li><li>Validate on remaining fold</li><li>Repeat K times</li><li>Average the results</li></ol><p><strong>Advantages</strong></p><ul><li>Reliable performance estimate</li><li>Reduces dependency on one train-test split</li><li>Best for small datasets</li></ul><p><strong>Disadvantages</strong></p><ul><li>Computationally expensive</li><li>Less common in deep learning due to large datasets</li></ul><p><strong>3. Ensemble Learning</strong></p><p>Ensemble learning combines predictions from multiple models to produce a stronger and more robust model<strong>.</strong></p><p><strong>Types of Ensemble Methods</strong></p><p>Bagging (Bootstrap Aggregation)</p><ul><li>Trains models on different data samples</li><li>Reduces variance<br> Example: Random Forest</li></ul><p><strong>Boosting</strong></p><ul><li>Models are trained sequentially</li><li>Focuses on previous errors<br> Examples: AdaBoost, Gradient Boosting, XGBoost</li></ul><p><strong>Stacking</strong></p><ul><li>Combines different model types</li><li>Uses a meta-model for final prediction</li></ul><p><strong>4. Dropout</strong></p><p>· <strong>Dropout</strong> randomly deactivates a percentage of neurons during training.</p><p><strong>How Dropout Works</strong></p><ul><li>During each training step:</li><li>Random neurons are set to zero</li><li>During inference:</li><li>All neurons are active (scaled weights)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*lnPTyfOd8PmuY4nkT2Wj8A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bee5fbba82b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PCA (Principal Component Analysis) is a dimensionality reduction technique and helps us to reduce…]]></title>
            <link>https://medium.com/@mpavi.pavithra/pca-principal-component-analysis-is-a-dimensionality-reduction-technique-and-helps-us-to-reduce-8f4cfd60de75?source=rss-2a7ac9887aaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f4cfd60de75</guid>
            <dc:creator><![CDATA[Pavithra M]]></dc:creator>
            <pubDate>Tue, 27 Jan 2026 13:29:55 GMT</pubDate>
            <atom:updated>2026-01-27T13:29:55.163Z</atom:updated>
            <content:encoded><![CDATA[<h3>PCA Made Easy: Dimensionality Reduction Step by Step</h3><p><strong>PCA (Principal Component Analysis) is a dimensionality reduction technique and helps us to reduce the number of features in a dataset while keeping the most important information. It changes complex datasets by transforming correlated features into a smaller set of uncorrelated components.</strong></p><p>PCA works by finding <strong>new axes (directions)</strong> in the data that capture the <strong>maximum variance</strong>. These directions are determined using <strong>eigenvectors</strong> of the covariance matrix, and their importance is measured by <strong>eigenvalues</strong>.</p><p><strong>Steps of PCA</strong></p><ol><li><strong>Standardize the Data</strong></li><li><strong>Compute Covariance Matrix</strong></li><li><strong>Find Eigenvalues &amp; Eigenvectors</strong></li><li><strong>Sort and Select Top k Components</strong></li><li><strong>Transform Data</strong></li></ol><p><strong>Step-by-Step Algorithm of PCA</strong></p><p>Assume:</p><ul><li>Dataset <strong>X</strong> with<br> <strong>n samples</strong> and <strong>p features</strong></li><li>Goal: Reduce dimensions from <strong>p → k</strong> (k &lt; p)</li></ul><p><strong>Step 1: Prepare the Dataset</strong></p><ul><li>Collect the data in matrix form</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*R6-CQJomrMbCYe5lK3q-MQ.png" /></figure><p><strong>Step 2: Standardize the Data (Very Important)</strong></p><p>PCA is sensitive to scale.</p><p>For each feature:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/97/1*y3pqsVMU4DP2_QtFl3Ulkg.png" /></figure><p>Mean = 0</p><p>Variance = 1</p><p><strong>Step 3: Compute the Covariance Matrix</strong></p><p>Covariance shows how features vary together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*NrYWuyk9m30tKOfIo4UwVA.png" /></figure><ul><li>Size of covariance matrix = <strong>p × p</strong></li><li>Diagonal → variance of each feature</li><li>Off-diagonal → covariance between features</li></ul><p><strong>Step 4: Compute Eigenvalues and Eigenvectors</strong></p><p>From covariance matrix <strong>C</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/57/1*N69Labb0w0TUkdSYG0OnWw.png" /></figure><ul><li><strong>Eigenvectors (v)</strong> → directions (principal components)</li><li><strong>Eigenvalues (λ)</strong> → amount of variance captured</li></ul><p><strong>Step 5: Sort Eigenvalues &amp; Eigenvectors</strong></p><ul><li>Sort eigenvalues in <strong>descending order</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*IHSFP9AeUt9TMdJNBaMj0g.png" /></figure><ul><li>Arrange eigenvectors accordingly</li></ul><p><strong>First eigenvector = 1st principal component</strong></p><p><strong>Step 6: Select Top k Principal Components</strong></p><p>Choose <strong>k</strong> eigenvectors that capture most variance.</p><p>Variance explained:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/201/1*6mMhYANP6SoPBPpM5-P3QQ.png" /></figure><p>Example:</p><ul><li>PC1 → 70%</li><li>PC2 → 20%<br> Choose k = 2 (90% variance)</li></ul><p>· <strong>Step 7: Form Projection Matrix</strong></p><p>· Create matrix <strong>W</strong> using top k eigenvectors:</p><p>· W =[v1,v2,v3,…,vk]</p><p>· Size → <strong>p × k</strong></p><p><strong>Step 8: Transform the Original Data</strong></p><p>Project data onto new feature space:</p><p>Y =Z.W</p><ul><li><strong>Y</strong> = reduced dataset</li><li>Size → <strong>n × k</strong></li></ul><p><strong>When SHOULD You Use PCA?</strong></p><p>· Many features</p><p>· Features are correlated</p><p>· Need speed or visualization</p><p>· Noise reduction required</p><p><strong>Applications of Principal Component Analysis</strong></p><p><strong>1. Data Visualization</strong></p><p>PCA reduces high-dimensional data to a two-dimensional or three-dimensional space for easier visualization, helping to reveal data trends, clusters or outliers.</p><p><strong>2. Preprocessing for Machine Learning</strong></p><p>PCA is often used before applying machine learning algorithms in order to reduce dimensionality, speed up training and improve model generalization.</p><p><strong>3. Feature Extraction</strong></p><p>PCA transforms correlated data features into a smaller set of uncorrelated components, which can help improve model performance and interpretability.</p><p><strong>4. Data Compression</strong></p><p>PCA reduces data storage needs by representing data with fewer dimensions while preserving most of its variability, making it effective in image and signal compression.</p><p><strong>5. Noise Reduction</strong></p><p>By filtering out low-variance components, PCA can reduce noise in data for applications like image and audio.</p><p><strong>Advantages of Principal Component Analysis</strong></p><ol><li><strong>Multicollinearity Handling:</strong> Creates new, uncorrelated variables to address issues when original features are highly correlated.</li><li><strong>Noise Reduction:</strong> Eliminates components with low variance enhance data clarity.</li><li><strong>Data Compression:</strong> Represents data with fewer components reduce storage needs and speeding up processing.</li><li><strong>Outlier Detection:</strong> Identifies unusual data points by showing which ones deviate significantly in the reduced space.</li></ol><p><strong>Disadvantages of Principal Component Analysis</strong></p><ol><li><strong>Interpretation Challenges:</strong> The new components are combinations of original variables which can be hard to explain.</li><li><strong>Data Scaling Sensitivity:</strong> Requires proper scaling of data before application or results may be misleading.</li><li><strong>Information Loss:</strong> Reducing dimensions may lose some important information if too few components are kept.</li><li><strong>Assumption of Linearity:</strong> Works best when relationships between variables are linear and may struggle with non-linear data.</li><li><strong>Computational Complexity:</strong> Can be slow and resource-intensive on very large datasets.</li><li><strong>Risk of Overfitting:</strong> Using too many components or working with a small dataset might lead to models that don’t generalize well.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f4cfd60de75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decision Tree Algorithm — ML]]></title>
            <link>https://medium.com/@mpavi.pavithra/decision-tree-algorithm-ml-89d62fb449fb?source=rss-2a7ac9887aaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/89d62fb449fb</guid>
            <dc:creator><![CDATA[Pavithra M]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 14:02:36 GMT</pubDate>
            <atom:updated>2025-12-12T14:48:58.783Z</atom:updated>
            <content:encoded><![CDATA[<h3>Decision Tree Algorithm — ML</h3><p><strong>Definition of Decision Tree Algorithm:</strong></p><p>A Decision Tree is a model that makes decisions by asking a series of questions, just like how humans think.</p><p>It splits the data into branches based on the answers (Yes/No, True/False, or conditions like Age &lt; 30), until it reaches a final decision.</p><p>The example of a binary tree for predicting whether a person is fit or unfit providing various information like age, eating habits and exercise habits, is given below −</p><p>In the above decision tree, the question are decision nodes and final outcomes are leaves.</p><p><strong>Types of Decision Tree Algorithm</strong></p><p><strong>Classification Tree</strong></p><ul><li>Used when the target/output is categorical<br> e.g., <em>Yes/No</em>, <em>Buy/Not Buy</em>, <em>Disease/No Disease</em>, <em>Dog/Cat</em></li></ul><p><strong>Regression Tree</strong></p><ul><li>Used when the target/output is continuous/numerical<br> e.g., <em>House Price</em>, <em>Salary</em>, <em>Temperature</em>, <em>Sales Amount</em></li></ul><p><strong>Splitting Criteria</strong></p><p><strong>Classification Tree uses:</strong></p><ul><li>Gini Index</li><li>Entropy (Information Gain)<br> These measure how <em>pure</em> the class labels are.</li></ul><p><strong>Regression Tree uses:</strong></p><ul><li>MSE (Mean Squared Error)</li><li>MAE (Mean Absolute Error)<br> These measure how close the predicted numbers are.</li></ul><p><strong>What is Entropy?</strong></p><p>Entropy measures impurity or disorder in the data.</p><ul><li>High entropy = data is very mixed (impure)</li><li>Low entropy = data is more pure</li></ul><p><strong>Example</strong></p><p>If you have a basket of fruits:</p><ul><li>50% apple</li><li>50% orange<br> → Very mixed → High entropy</li></ul><p>If you have:</p><ul><li>100% apples<br> → Pure group → Low entropy</li></ul><p><strong>Entropy Formula</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*WwE4KnQJAfCIOUurOOcgqg.png" /></figure><p>Where,</p><p>pi = probability of each class.</p><p>Example: If 80% apples, 20% oranges:</p><p><strong>What is Gini?</strong></p><p>Gini measures how often a randomly chosen sample would be misclassified if it was labeled randomly based on class proportions.</p><p>· Gini = 0 → Pure node</p><p>· Higher Gini → More impurity</p><p><strong>Gini Formula</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/115/1*xkF3__IS0gusoXG_mH43tg.png" /></figure><p>Example: If 80% apples, 20% oranges</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*L082FPqSOCu5Agk9TFgMIg.png" /></figure><p><strong>What Is Pruning?</strong></p><p>Pruning means cutting off unnecessary branches from a decision tree.</p><p>Think of a tree that has too many branches — it becomes messy and too specific.<br> Similarly, a decision tree can grow too deep and memorize noise in the training data → this is called <strong>overfitting</strong>.</p><p>Pruning removes those extra branches so the model becomes more general and performs better on unseen data.</p><p><strong>Types of Pruning</strong></p><p><strong>Pre-Pruning (Early Stopping)</strong></p><p>Stop the tree from growing too much.</p><p>Examples:</p><ul><li>max_depth</li><li>min_samples_split</li><li>min_samples_leaf</li><li>max_leaf_nodes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*hNgfHEu8z_4jX77fp_x4-g.png" /></figure><p><strong>Post-Pruning (Cost Complexity Pruning)</strong></p><p>· First grow the full tree → then cut unnecessary branches.</p><p><strong>Cost Complexity Pruning (ccp_alpha)</strong></p><p>Formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*w5IiHEqRVyKvlhbGIy4oEg.png" /></figure><p><strong>Most common method of hyperparameter Pruning</strong></p><p>Grid Search</p><p>Example:</p><p>from sklearn.tree import DecisionTreeClassifier</p><p>from sklearn.model_selection import GridSearchCV</p><p>model = DecisionTreeClassifier()</p><p>param_grid = {</p><p>‘max_depth’: [3, 5, 7, 10, None],</p><p>‘min_samples_split’: [2, 5, 10, 20],</p><p>‘min_samples_leaf’: [1, 2, 4, 10],</p><p>‘max_features’: [‘sqrt’, ‘log2’, None]</p><p>}</p><p>grid = GridSearchCV(model, param_grid, cv=5, scoring=’accuracy’)</p><p>grid.fit(X_train, y_train)</p><p>print(“Best parameters:”, grid.best_params_)</p><p>print(“Best accuracy:”, grid.best_score_)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89d62fb449fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting Survival on the Titanic: A Beginner-Friendly Machine Learning Project]]></title>
            <link>https://medium.com/@mpavi.pavithra/predicting-survival-on-the-titanic-a-beginner-friendly-machine-learning-project-65bd2ace5e59?source=rss-2a7ac9887aaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/65bd2ace5e59</guid>
            <dc:creator><![CDATA[Pavithra M]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 06:11:09 GMT</pubDate>
            <atom:updated>2025-12-01T06:11:09.146Z</atom:updated>
            <content:encoded><![CDATA[<p>Predicting Survival on the Titanic: A Beginner-Friendly Machine Learning Project</p><p>In this blog, I’ll walk you through the complete pipeline of predicting Titanic passenger survival using Python and machine learning.</p><p><strong>Goal:</strong><br> <strong>Build a model that predicts whether a passenger survived based on these features.</strong></p><p><strong>1. What is the Titanic Dataset?</strong></p><p>Kaggle’s Titanic dataset contains information about passengers aboard the RMS Titanic, including:</p><ul><li><strong>Age</strong></li><li><strong>Sex</strong></li><li><strong>Passenger class (Pclass)</strong></li><li><strong>Fare</strong></li><li><strong>Family members onboard (SibSp &amp; Parch)</strong></li><li><strong>Embarkation port</strong></li><li><strong>Whether they survived</strong></li></ul><p><strong>2. Loading &amp; Understanding the Data</strong></p><p>Before modeling, we explore the dataset.</p><p>import pandas as pd</p><p>train = pd.read_csv(“train.csv”)</p><p>test = pd.read_csv(“test.csv”)</p><p>train.head()</p><p>Key things to check:</p><p><strong>Missing values</strong></p><p>For example: Age and Cabin contain many missing entries.</p><p><strong>Data types</strong></p><p>Categorical: Sex, Embarked<br> Numeric: Age, Fare, SibSp, Parch</p><p><strong>Target variable</strong></p><p>Survived (0 = No, 1 = Yes)</p><p><strong>3. Exploratory Data Analysis (EDA)</strong></p><p>A few interesting insights:</p><p><strong>1. Women had a much higher survival rate</strong></p><p>train.groupby(“Sex”)[“Survived”].mean()</p><p>Women: ~74%<br> Men: ~19%</p><p><strong>2. First-class passengers survived more</strong></p><p>train.groupby(“Pclass”)[“Survived”].mean()</p><p><strong>3. Families had better chances</strong></p><p>People traveling with siblings/parents had slightly higher survival probability.</p><p><strong>4. Younger passengers survived more</strong></p><p>Age distribution reveals that children had priority during rescue.</p><p>EDA like this is essential — it guides feature selection.</p><p><strong>4. Preprocessing &amp; Feature Engineering</strong></p><p><strong>Handle missing values:</strong></p><ul><li>Fill Age using median</li><li>Fill Embarked with mode</li><li>Replace missing Fare values</li><li>Drop Cabin (too many missing)</li></ul><p><strong>Create useful features:</strong></p><ul><li><strong>FamilySize = SibSp + Parch + 1</strong></li><li><strong>IsAlone = 1 if FamilySize == 1 else 0</strong></li></ul><p><strong>Encoding categorical variables:</strong></p><p>We use <strong>OneHotEncoding</strong> for:</p><p>· Sex</p><p>· Embarked</p><p><strong>5. Building a Machine Learning Pipeline</strong></p><p>We’ll use <strong>Logistic Regression</strong>, which works great for binary classification.</p><p>from sklearn.compose import ColumnTransformer</p><p>from sklearn.preprocessing import OneHotEncoder</p><p>from sklearn.pipeline import Pipeline</p><p>from sklearn.impute import SimpleImputer</p><p>from sklearn.linear_model import LogisticRegression</p><p>y=Train[‘Survived’]</p><p>X = Train.drop(columns = [‘Survived’], axis =1)</p><p>train_X, test_X, train_y, test_y = train_test_split(X,y,test_size = 0.3, random_state = 42)</p><p>numeric_features = [“Age”, “Fare”]</p><p>categorical_features = [“Sex”, “Embarked”, “Pclass”]</p><p>numeric_transformer = Pipeline(steps=[</p><p>(“imputer”, SimpleImputer(strategy=”median”))])</p><p>categorical_transformer = Pipeline(steps=[</p><p>(“imputer”, SimpleImputer(strategy=”most_frequent”)),</p><p>(“encoder”, OneHotEncoder(handle_unknown=”ignore”))])</p><p>preprocessor = ColumnTransformer(</p><p>transformers=[</p><p>(“num”, numeric_transformer, numeric_features),</p><p>(“cat”, categorical_transformer, categorical_features)</p><p>]</p><p>)</p><p>model = Pipeline(steps=[</p><p>(“preprocessor”, preprocessor),</p><p>(“classifier”, LogisticRegression(max_iter=1000))</p><p>])</p><p>model.fit(train_X, train_y)</p><p><strong>6. Evaluation</strong></p><p>Since Kaggle doesn’t give labels for test.csv, we use cross-validation on the training data:</p><p>from sklearn.metrics import accuracy_score, confusion_matrix, classification_report</p><p>print(accuracy_score(train_y, train_pred))</p><p>print(accuracy_score(test_y, test_pred))</p><p>print(classification_report(train_y, train_pred))</p><p>print(classification_report(test_y, test_pred))</p><p>print(confusion_matrix(train_y, train_pred))</p><p>print(confusion_matrix(test_y, test_pred))</p><p><strong>7. Making Predictions &amp; Creating Submission File</strong></p><p>train_pred = model.predict(train_X)</p><p>test_pred = model.predict(test_X)</p><p>test_X_Kaggle = Test.drop(columns = [‘PassengerId’])</p><p>test_pred_Kaggle = model_preprocess.predict(test_X_Kaggle)</p><p>submission[‘Survived’] = test_pred_Kaggle</p><p>submission.to_csv(‘submission_Titanic.csv’, index = False)</p><p>By completing the Titanic ML project, you’ve covered:</p><p>Data cleaning<br> Feature engineering<br> Encoding categorical variables<br> Model building<br> Cross-validation</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65bd2ace5e59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supervised Learning]]></title>
            <link>https://medium.com/@mpavi.pavithra/supervised-learning-78e1601ca2f6?source=rss-2a7ac9887aaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/78e1601ca2f6</guid>
            <dc:creator><![CDATA[Pavithra M]]></dc:creator>
            <pubDate>Sun, 23 Nov 2025 02:47:31 GMT</pubDate>
            <atom:updated>2025-11-23T02:47:31.981Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Supervised Learning</strong></p><p>Supervised Learning is one type of machine learning techniques where the target is known.</p><p>It is classified into two types:</p><p>1. Classification</p><p>2. Regression</p><p><strong>Regression </strong>— Regression finds a relationship between input and output and predicts a numeric value</p><p>eg. Predict House Price</p><p><strong>Classification </strong>— learns patterns to decide which class the new data belongs to.</p><p>eg. Email Filtering — spam or not</p><p><strong>Logistic Regression:</strong></p><p>Logistic Regression is a popular machine learning algorithm used for classification problems — especially when the output has two classes (like Yes/No, 0/1, Spam/Not Spam).</p><p>Even though the name says “regression”, logistic regression is not used for predicting numbers.</p><p>It is used to predict probabilities and classify data into categories.</p><p><strong>Example</strong></p><p>You want to predict whether a student will pass or fail based on study hours.</p><p>Logistic regression learns from data and outputs a probability, like:</p><p>Probability of passing = 0.85 (85%) → model predicts Pass</p><p>Probability of passing = 0.30 (30%) → model predicts Fail</p><p><strong>How it works </strong>(simple steps)</p><p>It finds a relationship between the input (study hours) and output (pass/fail)</p><p>It uses a sigmoid function to convert the result into a probability between 0 and 1</p><p>If probability ≥ 0.5 → classify as 1 (Yes/Pass)</p><p>If probability &lt; 0.5 → classify as 0 (No/Fail)</p><p><strong>Sigmoid Function (Formula)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*Kddbqh7okFUvPpkJ17pnGA.png" /></figure><p>Probability = 1 / (1 + e^(-x))</p><p>It makes a smooth curve between 0 and 1, like an S-shape.</p><p><strong>Metrics in classification</strong></p><p>In classification problems, we evaluate how well the model predicts categories using classification metrics. These metrics tell us how accurate and reliable the model is.</p><ol><li><strong>Confusion Matrix</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*7Umdjei0QTvVHpkWnzJQjg.png" /></figure><p>Here,</p><p>When we predict the Actual Yes as True, then it’s True Positive (TP)</p><p>When we predict the Actual Yes as False, then it’s False Negative (FN)</p><p>When we predict the Actual No as True, then it’s False Positive (FP)</p><p>When we predict the Actual No as False, then it’s True Negative (TN)</p><p>We can derive the classification metrics based on the confusion matrix as below</p><p><strong>2. Accuracy</strong></p><p>Measures how many predictions were correct out of total predictions.</p><p>Accuracy = (TP + TN)/(TP+TN+FP+FN)</p><p><strong>3. Recall or Sensitivity</strong></p><p>Based on the actual data of all the positive values, how many recalled correctly</p><p>Recall = TP/ (TP + FN)</p><p><strong>4. Precision</strong></p><p>Out of all samples that the model predicted as Positive, how many were actually Positive?</p><p>Precision = TP/(TP+FP)</p><p>How to decide if the model is good based on Recall and Precision?</p><p>When we want high True Positive rate where we cannot afford to lose any True Positive then we choose Recall as evaluation metrics, likewise if we want high True Negative Rate, then Specificity helps and in other case we can opt for precision as evaluation metrics.</p><p><strong>Example Case</strong></p><p>Email Spam Classification</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*n-U1rWcmDIM2YFFPDdGqgw.png" /></figure><p>Means: Many non-spam emails are wrongly predicted as spam → Not a good model</p><p>Medical test (cancer detection)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*wPYZsdmwKHvy615H3sP8MQ.png" /></figure><p>Mean: Poor model even though accuracy is high.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78e1601ca2f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting Taxi Trip Distance Using Polynomial Regression with a Machine Learning Pipeline]]></title>
            <link>https://medium.com/@mpavi.pavithra/predicting-taxi-trip-distance-using-polynomial-regression-with-a-machine-learning-pipeline-1e401e6fc63d?source=rss-2a7ac9887aaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e401e6fc63d</guid>
            <dc:creator><![CDATA[Pavithra M]]></dc:creator>
            <pubDate>Fri, 21 Nov 2025 14:04:56 GMT</pubDate>
            <atom:updated>2025-11-21T14:04:56.241Z</atom:updated>
            <content:encoded><![CDATA[<p>Predicting the distance traveled by a taxi based on pickup and drop-off information is a classic machine learning problem often used in data science competitions and real-world analytics within the transportation industry. In this project, we build a <strong>Polynomial Linear Regression model using Scikit-Learn Pipelines</strong>, transforming raw numerical &amp; categorical data into a format suitable for training a predictive model.</p><p>In this article, we will walk through:</p><ul><li>Understanding the dataset</li><li>Exploratory Data Analysis (EDA)</li><li>Data preprocessing &amp; feature engineering</li><li>Building a Polynomial Regression Pipeline</li><li>Model training &amp; prediction</li><li>Preparing a submission file</li><li>Regularization Techniques</li></ul><p><strong>1. Understanding the Dataset</strong></p><p>We are provided with two CSV files:</p><p>TaxiTrain.csv — used to train our model</p><p>TaxiTest.csv — used to generate predictions</p><p>The goal is to predict the value of:</p><p><strong>trip_distance_miles</strong></p><p>Some features include:</p><p>Pickup &amp; drop-off coordinates</p><p>Passenger count</p><p>Rate code</p><p>Datetime columns are removed since they are not required in this version of modeling.</p><p><strong>2. Importing Libraries &amp; Loading Data</strong></p><p>import numpy as np</p><p>import pandas as pd</p><p>import matplotlib.pyplot as plt</p><p>import seaborn as sns</p><p>import warnings</p><p>warnings.filterwarnings(‘ignore’)</p><p>from sklearn.preprocessing import OneHotEncoder, StandardScaler, PolynomialFeatures</p><p>from sklearn.pipeline import Pipeline</p><p>from sklearn.compose import ColumnTransformer</p><p>from sklearn.model_selection import train_test_split</p><p>from sklearn.linear_model import LinearRegression</p><p>from sklearn.metrics import mean_squared_error, r2_score</p><p>Train_df = pd.read_csv(‘TaxiTrain.csv’)<br>Test_df = pd.read_csv(‘TaxiTest.csv’)</p><p><strong>3. Data Cleaning</strong></p><p>Removing datetime columns that are not needed for modeling:</p><p>Train_df.drop([‘pickup_datetime’, ‘dropoff_datetime’], axis=1, inplace=True)</p><p>Test_df.drop([‘pickup_datetime’, ‘dropoff_datetime’], axis=1, inplace=True)</p><p><strong>Splitting the dataset:</strong></p><p>X = Train_df.drop(‘trip_distance_miles’, axis=1)</p><p>y = Train_df[‘trip_distance_miles’]</p><p><strong>4. Identifying Numerical and Categorical Columns</strong></p><p>num_cols = Train_df.select_dtypes(include=np.number).columns</p><p>num_cols = [c for c in num_cols if c != ‘trip_distance_miles’]</p><p>If you <strong>do not remove</strong> trip_distance_miles, the scaler will try to scale the target column as well, <strong>which is incorrect</strong> and will cause errors or data leakage.</p><p>cat_cols = Train_df.select_dtypes(exclude=np.number).columns</p><p><strong>5. Exploratory Data Analysis</strong></p><p>correlation_matrix = Train_df.corr(numeric_only=True)</p><p>sns.heatmap(correlation_matrix, annot=True, cmap=’coolwarm’, fmt=”.2f”)</p><p>This helps us understand relationships between numeric features and the target variable</p><p><strong>6. Building the Preprocessing &amp; Modeling Pipeline</strong></p><p>To handle mixed data types, we use ColumnTransformer.<br> We apply:</p><p>· <strong>StandardScaler</strong> to numeric columns</p><p>· <strong>OneHotEncoder</strong> to categorical columns</p><p>· <strong>PolynomialFeatures(degree=2)</strong> to allow interaction terms</p><p>· <strong>LinearRegression</strong> as the regression estimator</p><p>preprocessor = ColumnTransformer([</p><p>(“num”, StandardScaler(), num_cols),</p><p>(“categorical”, OneHotEncoder(handle_unknown=”ignore”, drop=’first’, sparse_output=False), cat_cols)</p><p>])</p><p>pipe = Pipeline([</p><p>(“preprocess”, preprocessor),</p><p>(“poly”, PolynomialFeatures(degree=2)),</p><p>(“model”, LinearRegression())</p><p>])</p><p><strong>7. Train-Test Split and Model Training</strong></p><p>train_X, test_X, train_y, test_y = train_test_split(X, y, test_size=0.3, random_state=42)</p><p>pipe.fit(train_X, train_y)</p><p>train_predict = pipe.predict(train_X)</p><p>test_predict = pipe.predict(Test_df)</p><p><strong>8. Creating a Submission File</strong></p><p>submission = pd.DataFrame({</p><p>‘Id’: range(1, len(test_predict)+1),</p><p>‘trip_distance_miles’: test_predict</p><p>})</p><p>submission.to_csv(‘submission.csv’, index=False)</p><p>print(“submission.csv created”)</p><p><strong>9. Evaluation</strong></p><p>r2 = r2_score(train_y,train_predict)</p><p>rmse = np.sqrt(mean_squared_error(train_y,train_predict))</p><p><strong>10. Adding Regularization Models: Ridge, Lasso &amp; ElasticNet</strong></p><p>Polynomial regression can easily overfit due to the large number of generated interaction features — especially with degree=2 or higher.<br> To reduce overfitting and improve generalization, we apply <strong>regularization</strong>, which penalizes large model coefficients.</p><p><strong>Ridge Regression</strong></p><p>pipe_ridge = Pipeline([</p><p>(“preprocess”, preprocessor),</p><p>(“poly”, PolynomialFeatures(degree=2)),</p><p>(“ridge”, Ridge(alpha=10))</p><p>])</p><p>pipe_ridge.fit(train_X, train_y)</p><p>ridge_pred = pipe_ridge.predict(test_X)</p><p><strong>Lasso Regression</strong></p><p>pipe_lasso = Pipeline([</p><p>(“preprocess”, preprocessor),</p><p>(“poly”, PolynomialFeatures(degree=2)),</p><p>(“lasso”, Lasso(alpha=10))</p><p>])</p><p>pipe_lasso.fit(train_X, train_y)</p><p>lasso_pred = pipe_lasso.predict(test_X)</p><p><strong>ElasticNet Regression</strong></p><p>pipe_elastic = Pipeline([</p><p>(“preprocess”, preprocessor),</p><p>(“poly”, PolynomialFeatures(degree=2)),</p><p>(“elastic”, ElasticNet(alpha=10, l1_ratio=0.5))</p><p>])</p><p>pipe_elastic.fit(train_X, train_y)</p><p>elastic_pred = pipe_elastic.predict(test_X)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e401e6fc63d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>