<?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 Muniappan Mohanraj on Medium]]></title>
        <description><![CDATA[Stories by Muniappan Mohanraj on Medium]]></description>
        <link>https://medium.com/@kavmuni?source=rss-ca48e9211f63------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Muniappan Mohanraj on Medium</title>
            <link>https://medium.com/@kavmuni?source=rss-ca48e9211f63------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:45:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kavmuni/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[ The Evolution of Text Representation in NLP: From One-Hot Encoding to Word Embeddings]]></title>
            <link>https://medium.com/@kavmuni/the-evolution-of-text-representation-in-nlp-from-one-hot-encoding-to-word-embeddings-dcc57aba352b?source=rss-ca48e9211f63------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcc57aba352b</guid>
            <dc:creator><![CDATA[Muniappan Mohanraj]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 08:46:00 GMT</pubDate>
            <atom:updated>2026-04-13T08:46:00.365Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 Introduction</h3><p>Have you ever wondered how machines understand human language?</p><p>When you ask a voice assistant a question or chat with a bot, you’re interacting with systems powered by <strong>Natural Language Processing (NLP)</strong> — a branch of Artificial Intelligence that enables computers to interpret and respond to human language.</p><p>But here’s the catch:<br>👉 Machines don’t understand words — they understand <strong>numbers</strong>.</p><p>So how do we convert language into something machines can process?</p><p>Let’s walk through the fascinating evolution of how text is represented in NLP — from simple techniques to powerful modern embeddings.</p><h3>🔄 The Evolution of Text Representation</h3><pre>One-Hot Encoding → Bag of Words → TF-IDF → Word Embeddings → Advanced Embeddings</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*4X6Umfp1Mr9YhRq35WQsZQ.png" /></figure><h3>1️⃣ One-Hot Encoding — The Beginning</h3><p>The earliest method to represent text numerically was <strong>One-Hot Encoding</strong>.</p><p>Each word is represented as a vector where:</p><ul><li>Only one position is <strong>1</strong></li><li>All others are <strong>0</strong></li></ul><p><strong>Example:</strong></p><p>Vocabulary: [cat, dog, fish]</p><ul><li>cat → [1, 0, 0]</li><li>dog → [0, 1, 0]</li></ul><h3>❌ Limitations</h3><ul><li>No understanding of meaning</li><li>Cannot capture similarity</li><li>High-dimensional and sparse</li></ul><p>👉 To a machine, <em>“cat”</em> and <em>“dog”</em> are completely unrelated.</p><h3>2️⃣ Bag of Words (BoW) — Introducing Frequency</h3><p>To improve on One-Hot Encoding, <strong>Bag of Words</strong> was introduced.</p><p>Instead of just presence, it counts how often a word appears.</p><p><strong>Example:</strong></p><p>Text: <em>“cat cat dog”</em><br>Vector: [2, 1]</p><h3>✅ Improvement</h3><ul><li>Captures word frequency</li></ul><h3>❌ Still Missing</h3><ul><li>Word order</li><li>Meaning and relationships</li></ul><p>👉 “cat dog” and “dog cat” look identical to the model.</p><h3>3️⃣ TF-IDF — Measuring Importance</h3><p>Next came <strong>TF-IDF (Term Frequency–Inverse Document Frequency)</strong>, which adds the idea of <em>importance</em>.</p><h3>🔹 Term Frequency (TF)</h3><p>Measures how often a word appears in a document.</p><p>Example:<br>“cat” appears once in 6 words → TF = 1/6</p><h3>🔹 Inverse Document Frequency (IDF)</h3><p>Measures how rare a word is across documents.</p><p>Example:<br>If “cat” appears in 2 out of 3 documents:</p><p>IDF = log(3 / 2)</p><p>👉 Common words like “the” get very low importance.</p><h3>🧮 Final Formula</h3><p>TF-IDF = TF × IDF</p><h3>❌ Limitation</h3><ul><li>Still no understanding of <strong>meaning</strong></li></ul><h3>4️⃣ Word Embeddings — The Game Changer</h3><p>This is where things get exciting.</p><p><strong>Word Embeddings</strong> represent words as <strong>dense vectors</strong> that capture meaning.</p><h3>💡 Key Idea</h3><p>Words used in similar contexts have similar meanings.</p><p><strong>Example:</strong></p><ul><li>“cat” → [0.2, 0.8, 0.1]</li><li>“dog” → [0.25, 0.75, 0.15]</li></ul><p>👉 These vectors are close, meaning the words are related.</p><h3>🔥 Famous Insight</h3><pre>king - man + woman ≈ queen</pre><p>Machines can now understand relationships!</p><h3>🧩 Advanced Word Embedding Techniques</h3><h3>🔹 Word2Vec</h3><p>Developed by Google, Word2Vec learns embeddings using context.</p><h4>✅ CBOW (Continuous Bag of Words)</h4><p>Predicts a word using surrounding words.</p><p>Example:<br>“The ___ sits on the mat” → predicts <em>cat</em></p><h4>✅ Skip-Gram</h4><p>Predicts surrounding words from a given word.</p><p>Example:<br>Input: <em>cat</em> → Output: “The”, “sits”, “on”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*GQ_IlVvoYYhMd4G8O4RdDg.png" /></figure><h3>🔹 GloVe (Global Vectors)</h3><p>GloVe uses <strong>global co-occurrence statistics</strong>.</p><p>👉 It looks at how often words appear together across the entire dataset.</p><p><strong>Example Insight:</strong></p><ul><li>“ice” → closer to “cold”</li><li>“steam” → closer to “hot”</li></ul><h3>🔹 FastText</h3><p>FastText improves Word2Vec by using <strong>subwords (character n-grams)</strong>.</p><p><strong>Example:</strong><br>“playing” → “play”, “lay”, “ing”</p><h3>✅ Benefits</h3><ul><li>Handles rare words</li><li>Works with misspellings</li><li>Better for complex languages</li></ul><h3>🏁 Final Takeaway</h3><p>The journey of NLP text representation shows a clear evolution:</p><ul><li><strong>One-Hot &amp; BoW</strong> → Basic counting</li><li><strong>TF-IDF</strong> → Importance weighting</li><li><strong>Word Embeddings</strong> → Meaning</li><li><strong>Advanced Models</strong> → Context and relationships</li></ul><p>👉 The shift is from <strong>counting words → understanding language</strong></p><h3>✍️ Final Thought</h3><p>What once looked like simple text is now a rich mathematical representation of meaning, context, and relationships.</p><p>And this evolution is what powers everything from search engines to modern AI assistants.</p><h3>📌 Tags</h3><p>#NLP #MachineLearning #DeepLearning #AI #WordEmbeddings #DataScience #TFIDF #Word2Vec #GloVe #FastText</p><p>Resource: <a href="https://www.youtube.com/watch?v=wgfSDrqYMJ4&amp;t=234s">https://www.youtube.com/watch?v=wgfSDrqYMJ4&amp;t=234s</a> and LLMs</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcc57aba352b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizer — Core of ANN]]></title>
            <link>https://medium.com/@kavmuni/optimizer-core-of-ann-71c94a39d153?source=rss-ca48e9211f63------2</link>
            <guid isPermaLink="false">https://medium.com/p/71c94a39d153</guid>
            <dc:creator><![CDATA[Muniappan Mohanraj]]></dc:creator>
            <pubDate>Tue, 24 Feb 2026 16:29:30 GMT</pubDate>
            <atom:updated>2026-02-24T16:29:30.184Z</atom:updated>
            <content:encoded><![CDATA[<p>Traditional Machine learning algorithms like Liner Regression is mostly used to do the prediction when we’ve sizeable data in hand. We can consider these algorithms as very small ANN (Artificial Neural Network) with only one node but without any back propagation.</p><p>In real time when we’ve very huge data, in GBs or TBs, using a simple Machine Learning algorithm will be very difficult in training the model, tuning it and getting the required output. To our rescue there comes ANN which behaves pretty much similar to our brain. Ok! not pretty similar to Human brain but at least to 5% of Human brain :).</p><p>Core component of this ANN is Neurons. This made me say that ANN works similar to Human Brain :). Each Neuron in the ANN can act individually and product a output. Unlike traditional machine learning, where entire input is fed into the algorithm, in ANN each input column is fed into individual neurons so that it acts on the given input and produces a result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*DmuPEZVj7_vyyFFd7koJlA.png" /><figcaption>ANN — Artificial Neural Network</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*YNtEX8k6Vp9igFpN2XCoOA.png" /><figcaption>Simple example of ANN</figcaption></figure><p>As seen in the above figure, there are 3 main layers in the ANN. Input layer, Hidden layer and Output layer. As the name suggests input layer has neurons with respect to the number of input columns. Hidden layer is not exposed and it can have any number of neurons per layer and there can be n number of hidden layers as per our requirement and tuning. Finally there comes the output layer where the prediction is given out of the ANN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*9u47BV2_ipZif6Is-44ifQ.png" /><figcaption>Single Neuron</figcaption></figure><p>The diagram accurately depicts a hidden layer neuron receiving weighted inputs from the previous layer (e.g., input layer neurons). Each input “<strong>xi” </strong>is multiplied by its weight “<strong>wi”</strong>, then all weighted sums are <strong>collectively added</strong> with <strong>one bias </strong>b per neuron. The result <strong>z=∑wixi+b</strong> passes through activation f(z) to produce output. For now lets park discussion regarding activation function and concentrate on optimizer which is used is used to reduce the loss of the whole network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JDCYnK_I5mxjuBbf6Yf7w.png" /><figcaption>Process of gradient calculation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*TQI6SGIGbRpq3Fd0n226Gw.png" /><figcaption>Flow in an ANN</figcaption></figure><p>An optimizer is an <strong>algorithm </strong>that updates the <strong>weights </strong>and <strong>biases </strong>of a neural network to minimize the loss function. It uses gradients (most commonly computed via backpropagation) to determine how to adjust the parameters.</p><p>Commonly used optimizers are <strong>SGD </strong>(Stochastic Gradient Descent), <strong>ADAM</strong>, <strong>RMSprop</strong>.</p><p>SGD (Stochastic Gradient Descent) is one of the simplest optimizer algorithms where weight is adjusted by the below formula.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*l_O9LHLvdpIB0APD9lUY_A.png" /><figcaption>Batch GD Formula</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*4XpoXJ1ZU7ahQ7mfGJfDGA.png" /><figcaption>SGD formula</figcaption></figure><p>Here η (eta) is the learning rate (a hyperparameter controlling step size).</p><p>Unlike the normal Batch gradient descent, which uses the whole data to adjust weight and bias, SGD uses a random sample to update the weights and bias in a iterative manner by tuning the learning rate.</p><p>Mini batch gradient descent choose the samples with a size of 32 to 256 records per batch and follows the SGD approach to minimize the loss function. This is usually used in training the ANN for larger datasets.</p><p>RMSprop (Root Mean Square Propagation) is an adaptive optimizer which dynamically adjusts the learning rates. This algorithm normalizes the gradient per parameter to avoid excessive updates enabling smoother gradients. This optimizer is commonly used in KERAS framework for its balance and stability.</p><p>ADAM (Adaptive Moment Estimation) combines momentum and RMSprop optimizer. This is the default optimizer used in the ANN is no optimizer is specified. Adam outperforms them significantly in terms of both training time and convergence accuracy. Its ability to adjust the learning rate per parameter combined with the bias-correction mechanism leading to faster convergence and more stable optimization. This makes Adam especially useful in complex models with large datasets as it avoids slow convergence and instability while reaching the global minimum.</p><p>Source and Reference: <a href="https://www.geeksforgeeks.org/deep-learning/adam-optimizer/">https://www.geeksforgeeks.org/deep-learning/adam-optimizer/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71c94a39d153" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decision Tree Regressor— Threshold Explanation]]></title>
            <link>https://medium.com/@kavmuni/decision-tree-regressor-threshold-explanation-ce320d70fde0?source=rss-ca48e9211f63------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce320d70fde0</guid>
            <dc:creator><![CDATA[Muniappan Mohanraj]]></dc:creator>
            <pubDate>Fri, 19 Dec 2025 08:32:45 GMT</pubDate>
            <atom:updated>2025-12-19T08:32:45.284Z</atom:updated>
            <content:encoded><![CDATA[<p>In our previous attempt to revise the Linear regression we took a small IPO listing price prediction data set. Lets consider the same dataset to predict the same target variable of List Price through Decision Tree Regressor.</p><p><a href="https://medium.com/@kavmuni/predicting-ipo-listing-prices-with-linear-regression-cf44d01e8967">Link to the the Linear Regression details.</a></p><p>Similar to Linear Regression, the pre processing steps of NULL data removing, dropping unwanted columns are performed on our data set.</p><pre># Have all the imports configured here<br>import pandas as pd<br>import numpy as np<br>from matplotlib import pyplot as plt<br>import seaborn as sns<br>from sklearn.preprocessing import StandardScaler, PolynomialFeatures<br>from sklearn.compose import ColumnTransformer<br>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LinearRegression, Ridge, Lasso<br>from sklearn.metrics import mean_squared_error, r2_score<br>from sklearn.pipeline import Pipeline<br>from sklearn.model_selection import GridSearchCV<br>from sklearn.tree import DecisionTreeRegressor<br>import graphviz<br>from sklearn.tree import export_graphviz<br><br>ipo_dataframe = pd.read_excel(&#39;Initial Public Offering.xlsx&#39;)<br>ipo_dataframe.drop(columns=[&#39;Unnamed: 13&#39;, &#39;Unnamed: 14&#39;, &#39;Unnamed: 15&#39;, &#39;Unnamed: 16&#39;, &#39;Unnamed: 17&#39;, &#39;Unnamed: 18&#39;, &#39;Unnamed: 19&#39;, &#39;Unnamed: 20&#39;], inplace=True, axis = 1)<br>ipo_dataframe.info()<br><br><br>ipo_df_imp = ipo_dataframe.drop(columns=[&#39;Listing Gain&#39;, &#39;CMP(BSE)&#39;, &#39;CMP(NSE)&#39;, &#39;Current Gains&#39;], axis = 1)<br><br>ipo_df_imp.dropna(inplace=True)<br>numerical_columns=ipo_df_imp.select_dtypes(include=np.number).columns.to_list()</pre><p>Decision Tree algorithm model doesn&#39;t required data scaling since it follows a different strategy (Assumption: Basic understanding of Decision Tree algorithm is already given). So in data pre processing we ignore the scaling of all columns to a common scale and proceed with other usual steps of X, y formation, split into Train and Test set, model fit and prediction.</p><pre>X = ipo_df_imp[numerical_columns]<br>y = ipo_df_imp[&#39;List Price&#39;]<br>numerical_columns=ipo_df_imp.select_dtypes(include=np.number).columns.to_list()<br>numerical_columns.remove(&#39;List Price&#39;)<br>numerical_transformer=ColumnTransformer(transformers=[(&#39;numerical&#39;, StandardScaler(), numerical_columns)])<br>decision_tree=DecisionTreeRegressor()<br>decision_tree_pipeline=Pipeline(<br>    steps=[<br>        #(&#39;numerical_transformer&#39;, numerical_transformer),<br>        (&#39;decision_regression_model&#39;, decision_tree)<br>    ]<br>)<br>train_x, test_x, train_y, test_y=train_test_split(X, y, test_size=0.2, random_state=42)<br><br>decision_tree_pipeline.fit(train_x, train_y)<br>y_train_pred=decision_tree_pipeline.predict(train_x)<br>print(&quot;Train dataset&quot;)<br>print(f&quot;RMSE - {np.sqrt(mean_squared_error(train_y, y_train_pred))}&quot;)<br>print(f&quot;R2 - {r2_score(train_y, y_train_pred)}&quot;)<br>print(&quot;Test dataset&quot;)<br>y_test_pred=decision_tree_pipeline.predict(test_x)<br>print(f&quot;RMSE - {np.sqrt(mean_squared_error(test_y, y_test_pred))}&quot;)<br>print(f&quot;R2 - {r2_score(test_y, y_test_pred)}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*SP8QzmezWyaJBQbtrJqRlg.png" /><figcaption>Result of Train and Test dataset</figcaption></figure><p>The model sees to be overfit and that is ok as our motive here is to know the mathematical calculations done behind the screen.</p><h3><strong>Root Note calculation</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*dMnCb5dmtwiGTCkEgmPYjg.png" /><figcaption>Root Node of the Tree</figcaption></figure><p>Our algorithm takes Offer price as Root Node of the Tree and traveres the path accordingly. Here the value taken for consideration is MSE (Mean Squared Error). The value arrived here is 181678.772. There are 447 records in the TRAIN dataset. Mean value of the target variable (List Price — train_y) is 443.59. Sum of Squared Difference value is arrived by subtracting the value of each row in TRAIN_Y with the whole mean and then squaring it. MSE is obtained by dividing the Sum of Squared Difference with the total number of elements.</p><pre># Calculate the mean of the &#39;List Price&#39; in the training data (train_y)<br>list_price_mean = train_y.mean()<br>print(f&quot;Mean of &#39;List Price&#39; (train_y): {list_price_mean}&quot;)<br><br># Calculate the squared difference for each &#39;List Price&#39; value from its mean<br>squared_differences = (train_y - list_price_mean) ** 2<br>print(squared_differences)<br><br># Sum all the squared differences<br>sum_squared_differences = squared_differences.sum()<br>print(f&quot;Sum of squared differences: {sum_squared_differences}&quot;)<br><br># Get the total number of samples in the training data<br>num_samples = len(train_y)<br>print(f&quot;Number of samples: {num_samples}&quot;)<br><br># Calculate the Mean Squared Error (MSE) for the root node<br>mse_root_node = sum_squared_differences / num_samples<br>print(f&quot;Calculated MSE for the root node: {mse_root_node}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sc2N772vL9qDblg4k76W2g.png" /><figcaption>COLAB sheet screenshot for whole MSE arrival</figcaption></figure><p>This value of 181678.722 is the MSE of whole train dataset and this is shown in the root Node of the tree.</p><h3><strong>Offer Prices — Best Threshold</strong></h3><p>Lets take the Offer Price column, which has high correlation with the target variable (List Price), to explain the method of arriving best threshold.</p><p>Get the unique values of Offer Price columns and sort it in ascending order. Find the mid point value between 2 successive rows and get the values stored to a data frame.</p><pre># calculating threshold manually for th eoffer price feature<br>offer_prices = train_x[&#39;Offer Price&#39;]<br>offer_prices = offer_prices.drop_duplicates()<br>offer_prices.sort_values(ascending=True, inplace=True)<br>offer_prices_dt_with_mid_values = pd.DataFrame(offer_prices)<br>print(len(offer_prices_dt_with_mid_values))<br><br># Initialize the &#39;mid_point&#39; column with NaN to allow assignment in the loop<br>offer_prices_dt_with_mid_values[&#39;mid_point&#39;] = np.nan<br><br>for rec in range(0, len(offer_prices_dt_with_mid_values)-1):<br>    # Get the actual index label for the current positional index &#39;rec&#39;<br>    current_index_label = offer_prices_dt_with_mid_values.index[rec]<br><br>    # Access the &#39;Offer Price&#39; values using iloc (positional indexing)<br>    val1 = offer_prices_dt_with_mid_values.iloc[rec][&#39;Offer Price&#39;]<br>    val2 = offer_prices_dt_with_mid_values.iloc[rec+1][&#39;Offer Price&#39;]<br><br>    # Calculate the midpoint<br>    mid_point_value = (val1 + val2) / 2<br><br>    # Assign the calculated midpoint to the &#39;mid_point&#39; column using loc and the actual index label<br>    offer_prices_dt_with_mid_values.loc[current_index_label, &#39;mid_point&#39;] = mid_point_value<br><br>offer_prices_dt_with_mid_values</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*CMEO1oDcrYNO2RKtXrYZuw.png" /></figure><p>For each of the mid point we’ve to calculate the MSE and get all the values stored in a data frame so it will be easy for our manual calculation.</p><pre>offer_price_data = pd.DataFrame({<br>    &#39;Offer Price&#39;: train_x[&#39;Offer Price&#39;],<br>    &#39;List Price&#39;: train_y<br>})<br><br>midpoint_mse_results = []<br><br># Sort offer_price_data by &#39;Offer Price&#39; for efficient splitting<br>off_price_data_sorted = offer_price_data.sort_values(by=&#39;Offer Price&#39;).reset_index(drop=True)<br><br>for index, row in offer_prices_dt_with_mid_values.dropna(subset=[&#39;mid_point&#39;]).iterrows():<br>    mid_point = row[&#39;mid_point&#39;]<br><br>    # Split the data into two groups based on the midpoint<br>    left_group = off_price_data_sorted[off_price_data_sorted[&#39;Offer Price&#39;] &lt;= mid_point]<br>    right_group = off_price_data_sorted[off_price_data_sorted[&#39;Offer Price&#39;] &gt; mid_point]<br><br>    mse_left = 0<br>    if not left_group.empty:<br>        # Calculate MSE for the left group<br>        mean_left = left_group[&#39;List Price&#39;].mean()<br>        mse_left = np.mean((left_group[&#39;List Price&#39;] - mean_left) ** 2)<br><br>    mse_right = 0<br>    if not right_group.empty:<br>        # Calculate MSE for the right group<br>        mean_right = right_group[&#39;List Price&#39;].mean()<br>        mse_right = np.mean((right_group[&#39;List Price&#39;] - mean_right) ** 2)<br><br>    # Calculate weighted MSE<br>    total_samples = len(left_group) + len(right_group)<br>    if total_samples &gt; 0:<br>        weighted_mse = (len(left_group) / total_samples * mse_left) + \<br>                       (len(right_group) / total_samples * mse_right)<br>    else:<br>        weighted_mse = np.inf # Handle case where both groups are empty<br><br>    midpoint_mse_results.append({&#39;mid_point&#39;: mid_point, &#39;weighted_mse&#39;: weighted_mse})<br><br># Convert results to DataFrame for easier analysis<br>mse_df = pd.DataFrame(midpoint_mse_results)<br><br># Find the midpoint with the minimum weighted MSE<br>optimal_threshold_row = mse_df.loc[mse_df[&#39;weighted_mse&#39;].idxmin()]<br>optimal_threshold = optimal_threshold_row[&#39;mid_point&#39;]<br>min_weighted_mse = optimal_threshold_row[&#39;weighted_mse&#39;]<br><br>print(f&quot;Optimal threshold for &#39;Offer Price&#39;: {optimal_threshold}&quot;)<br>print(f&quot;Minimum weighted MSE: {min_weighted_mse}&quot;)<br><br>Optimal threshold for &#39;Offer Price&#39;: 573.5<br>Minimum weighted MSE: 71681.54887121008</pre><p>Minimum value of 71681.54887121008 is obtained for the Offer Price’s threshold value of 573.5 and so that value is chosen as the best threshold for split. PFB the visualization of the different threshold values and its MSE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*lGyspAnKHBy51skXZRqolA.png" /></figure><p>This process will be repeated for all other columns to arrive the leaf nodes for each split.</p><h3><strong>Next Step</strong></h3><p>Since the Decision Trees is Overfitting for this data set lets try to fit the same data with Ensemble models and see th eresults.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce320d70fde0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting IPO Listing Prices with Linear Regression]]></title>
            <link>https://medium.com/@kavmuni/predicting-ipo-listing-prices-with-linear-regression-cf44d01e8967?source=rss-ca48e9211f63------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf44d01e8967</guid>
            <dc:creator><![CDATA[Muniappan Mohanraj]]></dc:creator>
            <pubDate>Tue, 16 Dec 2025 14:31:06 GMT</pubDate>
            <atom:updated>2025-12-16T14:31:06.442Z</atom:updated>
            <content:encoded><![CDATA[<p>Linear Regression, a foundational supervised machine learning algorithm, excels at predicting continuous numeric outcomes like share listing prices. It assumes a linear relationship between input features and the target, fitting a best-fit line through the data centroid via the equation <strong>y=<em>mx</em>+<em>b</em></strong>, where <strong>m </strong>represents feature coefficients and <strong>b</strong> is the intercept. An ideal model balances low bias and low variance for reliable predictions.</p><p>With this foundational algorithm lets try to predict the list price of the IPO in the given sample dataset.</p><h3>Dataset Overview</h3><p>This compact IPO dataset spans 561 rows across 8 columns: “Date” (Date Time), “IPO_Name” (object), and numeric features — “Issue Size (Crores)”, “QIB”, “HNI”, “RII”, “Total”, “Offer Price” — with “List Price” as the target.</p><p>This dataset has 2 rows which has NaN (Not a Number) value. Dropping those 2 rows from the dataset as this might impact the overall result (Not having the step to replace the NaN value).</p><pre>import pandas as pd<br>import numpy as np<br>ipo_dataframe = pd.read_excel(&#39;Initial Public Offering.xlsx&#39;)<br>ipo_dataframe.drop(columns=[&#39;Unnamed: 13&#39;, &#39;Unnamed: 14&#39;, &#39;Unnamed: 15&#39;, &#39;Unnamed: 16&#39;, &#39;Unnamed: 17&#39;, &#39;Unnamed: 18&#39;, &#39;Unnamed: 19&#39;, &#39;Unnamed: 20&#39;], inplace=True, axis = 1)<br>ipo_dataframe.info()<br>ipo_df_imp[ipo_df_imp[&#39;QIB&#39;].isna()]</pre><ul><li>Numeric columns show positive correlations with “List Price”, led by “Offer Price”.</li><li>“RII” stands out with negative correlation but remains included for completeness.</li><li>Distributions are right-skewed with outliers, especially in “Issue Size (Crores)”, concentrating data on the left with long right tails.</li></ul><figure><img alt="Correlation heatmap" src="https://cdn-images-1.medium.com/max/620/1*TU-ATpNx9S_AbITyLDTdVQ.png" /><figcaption>Correlation Heatmap</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t96YI3lz-yysLmw0xqoRmw.png" /><figcaption>Histplot of the numerical features with target variable</figcaption></figure><p>Let’s split the data into <strong>X </strong>and <strong>y</strong> for our prediction process. <br><strong>X </strong>should have the independent variable and ‘<strong>y</strong>’ should have the target variable.</p><pre>X = ipo_df_imp.drop(columns=[&#39;List Price&#39;], axis=1)<br>y = ipo_df_imp[&#39;List Price&#39;]</pre><h3>Pre processing Steps</h3><p>The data is much skewed towards the right. This skewness will affect the prediction using Linear Regression. So in the next step lets do the pre processing to convert all the data into same scale using Standard Scaler from SKLEARN library.</p><p>This Standard Scaler uses Z-Scale by default to convert the data and make all the data points into a common scale which makes it easy for the model to predict.</p><pre>from sklearn.preprocessing import StandardScaler<br>from sklearn.compose import ColumnTransformer<br>from sklearn.pipeline import Pipeline<br>numerical_columns=ipo_df_imp.select_dtypes(include=np.number).columns.to_list()<br>numerical_columns.remove(&#39;List Price&#39;)<br>numerical_transformer=ColumnTransformer(transformers=[(&#39;numerical&#39;, StandardScaler(), numerical_columns)])<br>linear_regressor=LinearRegression()<br>Linear_pipeline=Pipeline(<br>    steps=[<br>        (&#39;numerical_transformer&#39;, numerical_transformer),<br>        (&#39;linear_regression_model&#39;, linear_regressor)<br>    ]<br>)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*e1k0Keig3eaoPL7jQCkA-Q.png" /><figcaption>Data in its original scale</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*zLDDb9IYhr-j0OPiZ0uVxQ.png" /><figcaption>Data converted to Z-scale</figcaption></figure><h3>Prediction with the regression</h3><p>Here we’re going to predict the List price using Linear Regression, from the SKLEARN library.</p><p>First split the data into Train and Test Dataset, usually in the ratio of 80:20. This is done to validate the correctness of our prediction.</p><p>Once the model is fitted with the train dataset we predict the List Price of the data points present in the train data set. This is compared with the actual values of the train data set which gives us a R2 score of 0.92.</p><pre>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LinearRegression<br>from sklearn.metrics import mean_squared_error, r2_score<br>linear_regressor=LinearRegression()<br>Linear_pipeline=Pipeline(<br>    steps=[<br>        (&#39;numerical_transformer&#39;, numerical_transformer),<br>        (&#39;linear_regression_model&#39;, linear_regressor)<br>    ]<br>)<br>train_x, test_x, train_y, test_y=train_test_split(X, y, test_size=0.2, random_state=42)<br><br>Linear_pipeline.fit(train_x, train_y)<br>y_train_pred=Linear_pipeline.predict(train_x)<br>print(np.sqrt(mean_squared_error(train_y, y_train_pred)))<br>print(r2_score(train_y, y_train_pred))<br><br>y_test_pred=Linear_pipeline.predict(test_x)<br>print(np.sqrt(mean_squared_error(test_y, y_test_pred)))<br>print(r2_score(test_y, y_test_pred))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*dN--8CKmR_Qcw5P0RRDpsA.png" /><figcaption>RMSE and R2 score of both dataset</figcaption></figure><p>R2 score of the test dataset is also pretty good which makes our model a good one.</p><p>Please find below the code for manual calculation of R2 score for the test dataset.</p><pre># Lets combine the actual and predicted values for test dataset and find the difference of the suared squared<br>test_y_df=pd.DataFrame(test_y)<br>test_y_df[&#39;Predicted_List_Price&#39;]=y_test_pred<br>test_y_df[&#39;Difference&#39;]=(test_y_df[&#39;List Price&#39;]-test_y_df[&#39;Predicted_List_Price&#39;]) ** 2<br><br># in the saem dataframe lets have one more column to have the difference of actual value subtracted from mean of teh actual value<br>test_y_df[&#39;Actual_Minus_Mean&#39;]=(test_y_df[&#39;List Price&#39;]-test_y_df[&#39;List Price&#39;].mean()) ** 2<br><br>SSR = (test_y_df[&#39;Difference&#39;].sum())/test_y_df.shape[0]<br>SST = (test_y_df[&#39;Actual_Minus_Mean&#39;].sum())/test_y_df.shape[0]<br>R2 = 1 - (SSR/SST)<br>print(R2)<br><br>#0.9127449467387336</pre><p>Below is the actual formula of our model with all the feature’s coefficient and intercept.</p><p><strong>y_pred = -12.88*issue_size + 34.31*QIB + 0.097*HNI — 13.25*RII + 54.59*total + 395.84*Offer_price + 433.59</strong></p><p>To make sure our understanding about the best fit line, which passes through the centroid, lets plot the target vs one of the dependent variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*gWADsyKYWU_XAsfvJfkLCQ.jpeg" /></figure><h3>Key Insights and Next Steps</h3><p>High R² and low RMSE highlight “Offer Price” dominance, but skewness scaling was crucial. Negative “RII” coefficient aligns with its correlation. For production, validate with cross-validation, explore polynomial features for non-linearity, or test Ridge regression to curb potential multicollinearity among totals. This workflow demonstrates scalable pre processing and evaluation in Python — ideal for financial ML pipelines.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf44d01e8967" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evaluating Logistic Regression: A Complete Guide to Classification Metrics]]></title>
            <link>https://medium.com/@kavmuni/evaluating-logistic-regression-a-complete-guide-to-classification-metrics-9af39396956e?source=rss-ca48e9211f63------2</link>
            <guid isPermaLink="false">https://medium.com/p/9af39396956e</guid>
            <dc:creator><![CDATA[Muniappan Mohanraj]]></dc:creator>
            <pubDate>Sat, 22 Nov 2025 17:42:39 GMT</pubDate>
            <atom:updated>2025-11-22T17:42:39.023Z</atom:updated>
            <content:encoded><![CDATA[<p>Logistic regression is a powerful classification algorithm, but predicting 0 or 1 tells only half the story. How confident are these predictions? Where does the model make mistakes? How do you compare two models objectively? These questions are answered by classification metrics — specialized evaluation measures that go far beyond simple accuracy.</p><h3><strong>Understanding Supervised Learning Divisions</strong></h3><p>Supervised machine learning is classified into two major divisions: Regression and Classification. Regression predicts continuous values (e.g., house prices, temperature). Classification predicts categorical values (e.g., spam/not spam, fraud/legitimate). Binary Logistic Regression is a classification algorithm specifically designed for problems with exactly 2 possible outcomes: YES/NO, TRUE/FALSE, or 1/0.</p><h3><strong>Why is it Called “Regression”?</strong></h3><p>Even though logistic regression solves a classification problem, it uses linear regression internally. Here’s the key insight:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*v-i2rDez-Hbd3grDFgRQOg.jpeg" /><figcaption>Formulas</figcaption></figure><p>The sigmoid function transforms the linear regression output from an unlimited range into a probability between 0 and 1. This probability represents the likelihood of the positive class.</p><h3><strong>Making Predictions from Probabilities</strong></h3><p>Logistic regression outputs a probability (0 to 1), not a direct class label. To make a binary prediction, we apply a <strong>decision threshold</strong>, typically <strong>0.5</strong>:</p><p>· <strong><em>If output ≥ 0.5 → Predict: Yes (1, Positive)</em></strong></p><p>·<strong><em> If output &lt; 0.5 → Predict: No (0, Negative)</em></strong></p><p>This threshold is critical — changing it directly impacts all evaluation metrics.</p><h3><strong>Confusion Matrix: The Foundation of Everything</strong></h3><p>The <strong>confusion matrix</strong> is the foundation for understanding all classification metrics. It’s a simple 2×2 table that compares actual values with predicted values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*40F4-kGoZaNkJXMAFggwzQ.png" /></figure><p><strong>Understanding Each Cell</strong></p><p><strong>True Positives (TP):</strong> Correctly predicted positive cases</p><p>· Model predicted: Positive ✓ Actual: Positive ✓</p><p>· Example: Correctly identified spam emails</p><p><strong>True Negatives (TN):</strong> Correctly predicted negative cases</p><p>· Model predicted: Negative ✓ Actual: Negative ✓</p><p>· Example: Correctly identified legitimate emails</p><p><strong>False Positives (FP):</strong> Incorrectly predicted as positive</p><p>· Model predicted: Positive ✗ Actual: Negative</p><p>· Example: Flagging legitimate emails as spam (Type I Error)</p><p><strong>False Negatives (FN):</strong> Incorrectly predicted as negative</p><p>· Model predicted: Negative ✗ Actual: Positive</p><p>· Example: Missing actual spam emails (Type II Error)</p><p><strong>Why “Confusion” Matrix?</strong></p><p>The term highlights where your model is “confused” — the FP and FN cells show misclassifications. All other metrics derive from these four fundamental values.</p><h3>Recall: “Of the Actual Positives, How Many Did We Find?”</h3><p><strong>Recall focuses on ACTUAL values</strong>. It answers: “<em>Out of all the true positive cases in our data, how many did our model successfully identify?</em>”</p><p>Recall is particularly useful on <strong>training data</strong> (where we know actual values) or <strong>validation sets</strong>.</p><p><strong>Two Types of Recall</strong></p><p><strong>Sensitivity (True Positive Rate / TPR):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*QNTRuDGA4Ud74wN_oUCR8g.jpeg" /></figure><p>· Example: 850 / (850 + 150) = <strong>0.85</strong> or <strong>85%</strong></p><p>· Meaning: Model correctly identifies 85% of actual positive cases</p><p>· Used when: Missing positives is costly (medical diagnosis, fraud detection)</p><p><strong>Specificity (True Negative Rate / TNR):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/182/1*pRyAjE0LVw9K0KLlPBWaog.jpeg" /></figure><p>· Example: 900 / (900 + 100) = <strong>0.90</strong> or <strong>90%</strong></p><p>· Meaning: Model correctly identifies 90% of actual negative cases</p><p>· Used when: False positives are costly (minimizing false alarms)</p><p><strong>Key Insight About Recall</strong></p><p><strong>Recall uses the denominator based on actual values</strong> (TP+FN for sensitivity, TN+FP for specificity). This is why it’s an <strong>actual-value metric</strong>. High recall on training data is good, but the real test is validation/test data performance.</p><h3><strong>Precision: “Of Our Positive Predictions, How Many Were Correct?”</strong></h3><p><strong>Precision focuses on PREDICTED values</strong>. It answers: “<em>Out of all the positive predictions our model made, how many were actually correct?</em>”</p><p>Precision measures the <strong>reliability of positive predictions</strong>.</p><p><strong>Two Types of Precision</strong></p><p><strong>Positive Precision (Precision Whole Positive Rate):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*DUoRzAdBWOYKCTpgvx1BqA.jpeg" /></figure><p>· Example: 850 / (850 + 100) = <strong>0.895</strong> or <strong>89.5%</strong></p><p>· Meaning: When model predicts positive, it’s correct 89.5% of the time</p><p>· Used when: False positives are undesirable (reducing spam in inbox)</p><p><strong>Negative Precision (Precision Whole Negative Rate):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*Z90DiMSp1Lz1c4rdos4eHA.jpeg" /></figure><p>· Example: 900 / (900 + 150) = <strong>0.857</strong> or <strong>85.7%</strong></p><p>· Meaning: When model predicts negative, it’s correct 85.7% of the time</p><p>· Used when: False negatives are undesirable (not missing fraud)</p><p><strong>Key Insight About Precision</strong></p><p><strong>Precision uses the denominator based on predicted values</strong> (TP+FP for positive, TN+FN for negative). This is why it’s a <strong>predicted-value metric</strong>. High precision means you can trust the model’s predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*qX8qm8RAfkPDPu_hwSDLrQ.jpeg" /></figure><h3><strong>Accuracy: The Simple Overall Score</strong></h3><p><strong>Accuracy</strong> measures the percentage of correct predictions across all cases:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*jQQCKb20704mjrZppdEWWQ.jpeg" /></figure><p><strong>When Accuracy Fails: The Imbalanced Data Problem</strong></p><p>Accuracy is <strong>misleading on imbalanced datasets</strong>. Consider:</p><p>· Dataset: 1,000 samples, 950 negatives, 50 positives (95% negative)</p><p>· Naive model: Always predict “negative”</p><p>· Result: <strong>95% accuracy</strong> but <strong>0% recall</strong> for positives!</p><p>This is why other metrics exist — accuracy ignores the minority class entirely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*yfaWL9s2XivShPFuS5drgw.jpeg" /><figcaption>Metrics comparison</figcaption></figure><h3><strong>Key Takeaways</strong></h3><p>1. <strong>Confusion matrix is foundational</strong> — understand TP, TN, FP, FN</p><p>2. <strong>Recall measures actual values</strong> — useful for training data and medical/fraud contexts</p><p>3. <strong>Precision measures predicted values</strong> — useful for assessing prediction reliability</p><p><strong>4. Accuracy is dangerous on imbalanced data</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9af39396956e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polynomial Regression: A Deep Dive into Capturing Non-Linear Relationships]]></title>
            <link>https://medium.com/@kavmuni/polynomial-regression-a-deep-dive-into-capturing-non-linear-relationships-00fb5365ff1d?source=rss-ca48e9211f63------2</link>
            <guid isPermaLink="false">https://medium.com/p/00fb5365ff1d</guid>
            <dc:creator><![CDATA[Muniappan Mohanraj]]></dc:creator>
            <pubDate>Sat, 22 Nov 2025 16:10:49 GMT</pubDate>
            <atom:updated>2025-11-22T16:10:49.416Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Polynomial Regression?</strong></p><p><strong>Polynomial Features</strong> are used when data points don’t follow a straight line — that is, when they don’t exhibit a direct linear relationship with the target variable. Traditional linear regression assumes a straight-line relationship, but real-world data is often more complex.</p><p><strong>Polynomial regression extends linear regression</strong> to capture non-linear relationships by introducing polynomial terms (like x², x³, etc.) into the model. Rather than fitting a simple straight line, polynomial regression fits a curved relationship between independent and dependent variables while trying to minimize loss and error.</p><p><strong>Why Polynomial Regression Works</strong></p><p>Polynomial regression is particularly valuable for non-linear data because it can model relationships that linear regression cannot capture. It creates a curved fit that better represents the actual pattern in your data. Think of it as giving your model more flexibility to bend and curve around your data points, rather than forcing them onto a rigid straight line.</p><p><strong>The Critical Overfitting Problem: Why Degree Matters</strong></p><p>Here’s an important point that many practitioners overlook: <strong>as you increase the degree of polynomial features, your model becomes increasingly complex — and complexity leads to overfitting.</strong></p><p>When you add more polynomial terms, you’re also adding more parameters for the model to learn. Here’s what happens:</p><p>Polynomial Degree</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*BIx6Z2_FBUz31BkF8vjrFg.jpeg" /></figure><p><strong>With each increase in degree, the number of parameters grows exponentially</strong>, giving your model more opportunity to memorize noise in the training data rather than learning the true underlying pattern. This is where overfitting becomes a serious concern.</p><p><strong>Understanding Overfitting vs. Underfitting</strong></p><p><strong>Overfitting: The Silent Performance Killer</strong></p><p><strong>Overfitting occurs when a model shows low error on training data but performs poorly on test/unknown data.</strong> Your model has essentially memorized the training data, including its noise and quirks, and cannot generalize well to new data. This is the core problem that high-degree polynomial features can cause.</p><p><strong>Underfitting: The Opposite Problem</strong></p><p><strong>Underfitting is the opposite scenario.</strong> The model performs poorly on both training and test data because it’s too simple to capture the underlying patterns. Think of this as using a degree-1 polynomial (straight line) when your data clearly curves.</p><p><strong>The Solution: Regularization Techniques</strong></p><p>To overcome overfitting, we turn to <strong>regularization</strong> — a family of techniques that add a penalty to the model’s parameters or coefficients. These techniques work by discouraging the model from becoming unnecessarily complex, keeping it as simple as possible while still capturing important patterns.</p><p><strong>How Regularization Works</strong></p><p>Regularization adds a penalty term to your loss function during training. This penalty grows with the magnitude of your coefficients, forcing the model to keep parameter values smaller. The result? Your model stays simpler and more generalizable.</p><p><strong>Types of Regularization Techniques</strong></p><p><strong>1. Lasso — L1 Regularization</strong></p><p><strong>Lasso stands for Least Absolute Shrinkage and Selection Operator.</strong> This technique adds a penalty based on the absolute value of coefficients. The key advantage: Lasso can shrink some coefficients all the way down to zero, effectively removing those features from the model.</p><p><strong>Best for:</strong> Feature selection, high-dimensional data, and situations where you want a sparse solution (fewer features).</p><p><strong>2. Ridge — L2 Regularization</strong></p><p><strong>Ridge regularization adds a penalty based on the squared value of coefficients.</strong> Unlike Lasso, Ridge shrinks coefficients proportionally but doesn’t reduce them to exactly zero. It distributes the penalty across all features.</p><p><strong>Best for:</strong> Handling multicollinearity, stable interpretable models, and when you want to keep all features.</p><p><strong>3. Elastic Net</strong></p><p><strong>Elastic Net combines the strengths of both L1 and L2 techniques.</strong> It provides a balance between feature selection (like Lasso) and coefficient shrinkage (like Ridge). This hybrid approach often delivers the best results in practice.</p><p><strong>Best for:</strong> Complex datasets where you need both feature selection and parameter regularization.</p><p><strong>The Lambda Parameter: Your Regularization Control</strong></p><p>When using regularization, the <strong>lambda (λ) parameter</strong> plays a critical role. This hyperparameter controls the strength of the penalty:</p><p>· <strong>Higher Lambda</strong> = Stronger regularization = Simpler model (higher bias, lower variance) = Risk of underfitting</p><p>· <strong>Lower Lambda</strong> = Weaker regularization = More complex model (lower bias, higher variance) = Risk of overfitting</p><p>The art of machine learning is finding the sweet spot — a lambda value that prevents overfitting without causing underfitting.</p><p><strong>Key Takeaway: Business Alignment Matters Most</strong></p><p><strong>Always check your business needs and find optimal values that best fit your use case.</strong> There’s no universal “best” lambda value. The optimal regularization strength depends on:</p><p>· Your specific dataset characteristics</p><p>· The complexity of the underlying relationship you’re modeling</p><p>· Your tolerance for model complexity vs. accuracy trade-offs</p><p>· Whether you prioritize interpretability or pure predictive power</p><p>The most successful data scientists understand that <strong>the best model isn’t the one with the lowest training error — it’s the one that delivers reliable, generalizable predictions in production.</strong></p><p><strong>Summary</strong></p><p>Polynomial regression is a powerful tool for modeling non-linear relationships. However, <strong>higher-degree polynomials introduce complexity and overfitting risk.</strong> Regularization techniques (Lasso, Ridge, and Elastic Net) combat this by penalizing model complexity. By thoughtfully selecting your polynomial degree and regularization approach, you can build models that capture real patterns while generalizing well to new data.</p><p><strong>Start with degree 2 or 3, apply regularization, and tune your lambda parameter based on validation performance.</strong> This pragmatic approach works across most use cases.</p><p><em>Have you struggled with overfitting in your polynomial models? Share your experience in the comments below — I’d love to hear what techniques worked best for your projects.</em></p><p><strong>Clap if this was helpful, and follow for more machine learning insights!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00fb5365ff1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Machine Learning]]></title>
            <link>https://medium.com/@kavmuni/introduction-to-machine-learning-f176a730cd3b?source=rss-ca48e9211f63------2</link>
            <guid isPermaLink="false">https://medium.com/p/f176a730cd3b</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Muniappan Mohanraj]]></dc:creator>
            <pubDate>Sat, 01 Nov 2025 13:11:37 GMT</pubDate>
            <atom:updated>2025-11-01T13:11:37.060Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning is a subset of Artificial Intelligence and has been actively researched since the 1950s. Machine Learning and Artificial Intelligence are often confused, but they’re not identical concepts. Here’s a concise distinction:</p><p>· <strong>Artificial Intelligence (AI):</strong> Field of computer science enabling machines to perform tasks requiring human-like intelligence.</p><p>· <strong>Machine Learning (ML):</strong> A subfield of AI that enables systems to learn and improve from data provided.</p><p>In ML, machines understand patterns in data to predict unknown variables. Let’s break down the fundamental types of machine learning.</p><p><strong>Major Types of Machine Learning</strong></p><p><strong>1. Supervised Learning</strong></p><p>· Involves an unknown target (dependent variable) depending on several independent variables.</p><p>· The machine learns how the target changes relative to the inputs, using historical data to build prediction models.</p><p>· <strong>Example:</strong> Real estate price prediction.</p><p><strong>2. Unsupervised Learning</strong></p><p>· No target variable is defined.</p><p>· Data is categorized or clustered based on similarities and parameters.</p><p>· <strong>Example:</strong> Movie suggestion algorithms for Netflix or Amazon Prime.</p><p><strong>3. Reinforcement Learning</strong></p><p>· Machines learn by trial and error, refining patterns to avoid repeating mistakes.</p><p>· <strong>Example:</strong> Self-driving cars.</p><p><strong>Deep Dive: Supervised Learning</strong></p><p>Supervised learning breaks into two main tasks: regression and classification.</p><p><strong>a. Regression</strong></p><p>· The target variable is continuous (e.g., life expectancy).</p><p>· Regression measures the relationship between independent and target variables.</p><p>· <strong>Prediction methods include:</strong></p><p>o Formula method</p><p>o Linear algebra</p><p>o Gradient descent</p><p><strong>b. Classification</strong></p><p>· Target variable is discrete (e.g., male/female).</p><p><strong>Error Metrics in Regression</strong></p><p>Prediction is always affected by some error, which we aim to minimize. Key error metrics include:</p><p>· <strong>SSE (Sum of Squared Errors):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*Eun3XPg5dTJjPeWCnn-b-w.png" /></figure><p>Squared errors summed across all observations; range: [0, ∞).</p><p>· <strong>MSE (Mean Squared Error):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/124/1*RgkpKNe9M641rLmSS_1SCg.png" /></figure><p>Average squared error; range: [0, ∞).</p><p>· <strong>RMSE (Root Mean Squared Error):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*pfBSl95LDvQf-dM6yIzoVQ.png" /></figure><p>Square root of MSE; range: [0, ∞).</p><p>· <strong>MAPE (Mean Absolute Percentage Error):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*iUPQhBJyK4ForS71XmkRVA.png" /></figure><p>Relative error as a percentage; range: 0 to 100</p><p>· <strong>R squared (Coefficient of Determination):</strong><br> Indicates how well independent variables explain the target variable variation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*pVMsrEEaplvkQcKlyDifvg.jpeg" /></figure><p><strong>Conclusion</strong></p><p>Machine Learning is a foundational technology within AI, underpinning much of modern innovation in prediction, automation, and smart recommendations. Understanding its core concepts and error metrics is essential for anyone serious about building or evaluating ML models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f176a730cd3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>