<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sagar borse</title>
    <description>The latest articles on DEV Community by sagar borse (@sagar_borse_a8da7af37d6bc).</description>
    <link>https://dev.to/sagar_borse_a8da7af37d6bc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2157939%2Fab4af402-92f6-404d-be0f-9e7bc6e10c24.png</url>
      <title>DEV Community: sagar borse</title>
      <link>https://dev.to/sagar_borse_a8da7af37d6bc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sagar_borse_a8da7af37d6bc"/>
    <language>en</language>
    <item>
      <title>Feature Scaling in Machine Learning</title>
      <dc:creator>sagar borse</dc:creator>
      <pubDate>Fri, 04 Oct 2024 17:57:45 +0000</pubDate>
      <link>https://dev.to/sagar_borse_a8da7af37d6bc/feature-scaling-in-machine-learning-4j1f</link>
      <guid>https://dev.to/sagar_borse_a8da7af37d6bc/feature-scaling-in-machine-learning-4j1f</guid>
      <description>&lt;p&gt;Feature scaling is a technique used in data preprocessing to ensure that all the features (independent variables) in a dataset have a similar scale. This is important because many machine learning algorithms perform better prediction when the features are on a similar scale.&lt;/p&gt;

&lt;p&gt;Example: we have a dataset with two features: height (in centimeters) and weight (in kilograms). If we don’t scale these features, the algorithm might give more importance to the feature with larger values (height) just because of its scale, not because it’s more important.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Why use Feature Scaling?&lt;/strong&gt;&lt;/em&gt; &lt;br&gt;
Feature scaling is important in machine learning for several key reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Improves Algorithm Performance: Many machine learning algorithms, like those using gradient descent, work better and converge faster when the features are on a similar scale.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fair Contribution: Without scaling, features with larger ranges can dominate the learning process. Scaling ensures that all features contribute equally to the model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accurate Distance Calculations: Algorithms that rely on distance calculations, such as k-nearest neighbors (KNN) and support vector machines (SVM), need scaled features to compute accurate distances.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Consistent Units: When features are measured in different units (e.g., height in centimeters and weight in kilograms), scaling helps standardize them, making the model’s calculations more consistent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Handling Outliers: Some scaling methods, like robust scaling, help reduce the impact of outliers by focusing on the median and interquartile range.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Algorithms That Need Feature Scaling:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Gradient Descent-Based Algorithms:&lt;/strong&gt; These include linear regression, logistic regression, and neural networks. Scaling helps these algorithms converge faster.&lt;br&gt;
&lt;strong&gt;2.Distance-Based Algorithms:&lt;/strong&gt; Algorithms like k-nearest neighbors (KNN) and support vector machines (SVM) rely on distance calculations, which are affected by the scale of the features.&lt;br&gt;
Principal Component Analysis (PCA): PCA is sensitive to the variances of the features, so scaling ensures that each feature contributes equally.&lt;br&gt;
&lt;strong&gt;3.Clustering Algorithms:&lt;/strong&gt; Algorithms like k-means clustering use distance measures, so scaling is important to ensure fair clustering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Algorithms That Do Not Need Feature Scaling:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Tree-Based Algorithms: Decision trees, random forests, and gradient boosting algorithms (like XGBoost) are generally not affected by the scale of the features. These algorithms split the data based on feature values, so scaling is not necessary.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Naive Bayes: This algorithm is based on probability and is not influenced by the scale of the features.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Types of feature scaling:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Standardization (Also called as Z-score Normalization):&lt;/strong&gt; Standardization is a technique used to transform data so that it has a mean of 0 and a standard deviation of 1. This process is particularly useful when the data follows a Gaussian (normal) distribution.&lt;br&gt;
First, we should calculate the mean and standard deviation of the data we would like to normalize.&lt;/p&gt;

&lt;p&gt;Then we are supposed to subtract the mean value from each entry and then divide the result by the standard deviation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Formula:&lt;/strong&gt; Z = X - mu / sigma&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(X): is original feature value.&lt;/p&gt;

&lt;p&gt;(mu):is the mean(average) of the feature.&lt;/p&gt;

&lt;p&gt;(sigma): is the standard deviation of the feature.&lt;/p&gt;

&lt;p&gt;(Z): is the standardized value.&lt;/p&gt;

&lt;p&gt;Example with Age and Salary Features&lt;/p&gt;

&lt;p&gt;Age=[25,35,45,55,65]&lt;/p&gt;

&lt;p&gt;Salary = [50000,60000,70000,80000,90000]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calculate the Mean(mu):&lt;/strong&gt;&lt;br&gt;
For Age: mean = 25 + 35 + 45 + 55 + 65 / 5 = 45&lt;/p&gt;

&lt;p&gt;For Salary: mean = 50000 + 60000 + 70000 + 80000 + 90000 / 5 = 70000&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calculate the Standard Deviation(sigma):&lt;/strong&gt;&lt;br&gt;
For Age: sigma = (25-45)^2 + (35-45)^2 + (45-45)^2 + (55-45)^2 + (65-45)^2 / 5 = 14.14&lt;/p&gt;

&lt;p&gt;For Salary: sigma = (50000-70000)^2 + (60000-70000)^2 + (70000-70000)^2 + (80000-70000)^2 + (90000-70000)^2 / 5 = 14142.14&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Apply the Formula:&lt;/strong&gt;&lt;br&gt;
For Age:&lt;/p&gt;

&lt;p&gt;X1 = 25 - 45 / 14.14 = -1.41&lt;/p&gt;

&lt;p&gt;X1 = 35 - 45 / 14.14 = -0.71&lt;/p&gt;

&lt;p&gt;X1= 45 - 45 / 14.14 = 0&lt;/p&gt;

&lt;p&gt;X1 = 55 - 45 / 14.14 = 0.71&lt;/p&gt;

&lt;p&gt;X1 = 65 - 45 / 14.14 = 1.41&lt;/p&gt;

&lt;p&gt;For Salary:&lt;/p&gt;

&lt;p&gt;X2 = 50000 - 70000 / 14142.14 = -1.41&lt;/p&gt;

&lt;p&gt;X2 = 60000 - 70000 / 14142.14 = -0.71&lt;/p&gt;

&lt;p&gt;X2 = 70000 - 70000 / 14142.14 = 0&lt;/p&gt;

&lt;p&gt;X2 = 90000 - 70000 / 14142.14 = 1.41&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Standardized Data:&lt;/strong&gt;The standardized values for Age and Salary are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Age(Standardized)&lt;/strong&gt; = [-1.41, -0.71, 0, 0.71, 1.41]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Salary(Standardized)&lt;/strong&gt; = [-1.41, -0.71, 0, 0.71, 1.41]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.Normalization(Min-Max Scaling)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Normalization scaling is a technique used to adjust the range of feature values in our data so they all fit within a specific scale, usually 0 to 1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why Use Normalization?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Equal Contribution: Ensures each feature contributes equally in the analysis, preventing larger scale features from dominating the results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improves Performance: Helps algorithms like KNN, SVM, and Neural Networks perform better and more efficiently by removing bias due to varying feature scales.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Smooth Convergence: Makes training algorithms converge faster and more reliably.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How It Works:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Identify Min and Max Values: Find the minimum and maximum values for each feature.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Apply the Formula: Rescale each feature using the formula:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Normalized Value = Original Value - Min / Max - Min&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine we have heights (cm) and weights (kg) of people:&lt;/p&gt;

&lt;p&gt;Height: Min = 150, Max = 200&lt;/p&gt;

&lt;p&gt;Weight: Min = 50, Max = 100&lt;/p&gt;

&lt;p&gt;If a person is 180 cm tall and weighs 75 kg:&lt;/p&gt;

&lt;p&gt;Normalized Height: 180 - 150 / 200 - 150 = 0.6&lt;/p&gt;

&lt;p&gt;Normalized Weight: 75 - 50 / 100 - 50 = 0.5&lt;/p&gt;

&lt;p&gt;This rescaling makes it easier for algorithms to process the data without any one feature overshadowing the others.&lt;/p&gt;

&lt;p&gt;Source code example link : &lt;a href="https://www.kaggle.com/code/sagarborse/notebookb6572850b7" rel="noopener noreferrer"&gt;https://www.kaggle.com/code/sagarborse/notebookb6572850b7&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Feature Engineering In Machine Learning</title>
      <dc:creator>sagar borse</dc:creator>
      <pubDate>Wed, 02 Oct 2024 15:55:12 +0000</pubDate>
      <link>https://dev.to/sagar_borse_a8da7af37d6bc/feature-engineering-21oo</link>
      <guid>https://dev.to/sagar_borse_a8da7af37d6bc/feature-engineering-21oo</guid>
      <description>&lt;p&gt;▶ What is Feature Engineering?&lt;br&gt;
Feature engineering is the process of transforming raw data into useful features that can be used to improve the performance of machine learning models. Here feature is column name in dataset like Name, Age, Height.&lt;br&gt;
Imagine we have a dataset with lots of information, like a spreadsheet with columns for age, height, weight, etc. Feature engineering involves:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Selecting the most important columns (features).&lt;/li&gt;
&lt;li&gt;Creating new columns from the existing ones (like calculating BMI from height and weight).&lt;/li&gt;
&lt;li&gt;Transforming data to make it more useful (like converting text to numbers).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;▶ Why It’s Important:&lt;br&gt;
1.Improves Model Accuracy: Better features help the model make more accurate predictions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Simplifies Data: Makes complex data easier to understand and use.&lt;/li&gt;
&lt;li&gt;Highlights Key Information: Brings out the most important aspects of the data.
Example:
If you have data about houses, we might create a new feature called “price per square foot” by dividing the price by the size of the house. This new feature can help the model understand the value of the house better.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;▶ Types of feature engineering&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Feature Transformation: Feature Transformation is the process of transforming the features into a more suitable representation for the machine learning model. This is done to ensure that the model can effectively learn from the data.&lt;/li&gt;
&lt;li&gt;Feature Creation : Feature Creation is the process of generating new features based on domain knowledge or by observing patterns in the data. It is a form of feature engineering that can significantly improve the performance of a machine-learning model.&lt;/li&gt;
&lt;li&gt;Feature Selection: Feature Selection is the process of selecting a subset of relevant features from the dataset to be used in a machine-learning model. It is an important step in the feature engineering process as it can have a significant impact on the model’s performance.&lt;/li&gt;
&lt;li&gt;Feature Extraction: Feature Extraction is the process of creating new features from existing ones to provide more relevant information to the machine learning model. This is done by transforming, combining, or aggregating existing features.&lt;/li&gt;
&lt;li&gt;Feature Scaling: Feature Scaling is the process of transforming the features so that they have a similar scale. This is important in machine learning because the scale of the features can affect the performance of the model.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  MachineLearning #AI #ML #FeatureEngineering #100DaysOfMachineLearning #MLGuru
&lt;/h1&gt;

</description>
    </item>
  </channel>
</rss>
