Python Machine Learning Preprocessing The Data

Python Machine Learning Preprocessing The Data

Python Machine Learning Preprocessing The Data – As in real world we deal with alot of raw data. Python Machine Learning algorithms expect Data to be formatted in a certain way before they start the training Process. in order to prepare the data for ingestion by Machine Learning algorithms, we have to preprocess it and convert the Data in to right format.

You can see my before article about Python Machine Learning

 

1:  Python Machine Learning Introduction

2:  Python Machine Learning Open Source Libraries

 

So there are four different kinds of Preprocessing  The Data

  • Binarization
  • Mear Removal
  • Scalling
  • Normalization

So now lets see an example first we need to import these lines of code

 

After that we are going to define our data

 

So first we are going to see Binarization

1: Binarization:  So when we want to convert our numerical values to Boolean values we use Binarization process, and we have an inbuilt method in Sklearn that is called binarize(), this method takes our input value the a threshold.

 

This is the code

 

The result will be

Binarized Preprocessing The Data
Binarized Preprocessing The Data

 

2:  Mean Removal: Removing the mean is a common preprocessing technique used in machine learning. It’s usually useful to remove the mean from our feature vector, so that each feature is centered on zero. We do this in order to remove bias from the features in our feature vector.

 

So first lets determine the mean and standard deviation

 

So this is the result

Python Mean Removal
Python Mean Removal

 

The above lines of code displays the mean and standard deviation of the input data. Let’s
remove the mean:

This is the result

Python Machine Learning Scaled Data
Python Machine Learning Scaled Data

 

3: Scaling:  In our feature vector, the value of each feature can vary between many random values. So it becomes important to scale those features so that it is a level playing field for the machine learning algorithm to train on. We don’t want any feature to be artificially large or small just because of the nature of the measurements.

This is the result

Python Machine Learning
Python Machine Learning

 

4: Normalization:  We use the process of normalization to modify the values in the feature vector so that we
can measure them on a common scale. In machine learning, we use many different forms of
normalization. Some of the most common forms of normalization aim to modify the values
so that they sum up to 1. L1 normalization, which refers to Least Absolute Deviations,
works by making sure that the sum of absolute values is 1 in each row. L2 normalization,
which refers to least squares, works by making sure that the sum of squares is 1.
In general, L1 normalization technique is considered more robust than L2 normalization
technique. L1 normalization technique is robust because it is resistant to outliers in the data.
A lot of times, data tends to contain outliers and we cannot do anything about it. We want
to use techniques that can safely and effectively ignore them during the calculations. If we
are solving a problem where outliers are important, then maybe L2 normalization becomes
a better choice.

 

This is the result

Python Machine Learing Data Normalized
Python Machine Learing Data Normalized

 

(Visited 341 times, 1 visits today)
Share via
Copy link
Powered by Social Snap