Data Transformation and Visualisation with Standard Scaler | Machine Learning
Standard Scaling - Part 64 - Data Transformation and Visualisation with Standard Scaler
Topic to be covered - How the data is transformed after applying Standard Scaler
Formula for the transformation - (Xi - mean(x)) / stdev(x)
Code Starts Here
==============
import pandas as pd
import numpy as np
from sklearn import preprocessing
import matplotlib.pyplot as plt
import seaborn as sns
np.random.seed(1)
df = pd.DataFrame({
'x1' : np.random.normal(0,2,10000),
'x2' : np.random.normal(-3,5,10000)})
scaler = preprocessing.StandardScaler()
scaled_df = scaler.fit_transform(df)
scaled_df = pd.DataFrame(scaled_df, columns = ['col1','col2'])
fig , (ob1, ob2) = plt.subplots(ncols = 2, figsize=(5,5))
ob1.set_title('Before Scaling')
sns.kdeplot(df['x1'],ax=ob1)
sns.kdeplot(df['x2'],ax=ob1)
ob2.set_title('After Standard Scaler')
sns.kdeplot(scaled_df['col1'],ax=ob2)
sns.kdeplot(scaled_df['col2'],ax=ob2)
plt.show()
plt.scatter(df['x1'],df['x2'], color = 'green')
plt.scatter(scaled_df['col1'],scaled_df['col2'], color = 'red')
sns.jointplot(df['x1'],df['x2'],color='yellow')
plt.show()
sns.jointplot(scaled_df['col1'],scaled_df['col2'],color='blue')
plt.show()
All Playlist of this youtube channel
=============================
1. Data Preprocessing in Machine Learning
[ Ссылка ]
2. Confusion Matrix in Machine Learning, ML, AI
[ Ссылка ]
3. Anaconda, Python Installation, Spyder, Jupyter Notebook, PyCharm, Graphviz
[ Ссылка ]
4. Cross Validation, Sampling, train test split in Machine Learning
[ Ссылка ]
5. Drop and Delete Operations in Python Pandas
[ Ссылка ]
6. Matrices and Vectors with python
[ Ссылка ]
7. Detect Outliers in Machine Learning
[ Ссылка ]
8. TimeSeries preprocessing in Machine Learning
[ Ссылка ]
9. Handling Missing Values in Machine Learning
[ Ссылка ]
10. Dummy Encoding Encoding in Machine Learning
[ Ссылка ]
11. Data Visualisation with Python, Seaborn, Matplotlib
[ Ссылка ]
12. Feature Scaling in Machine Learning
[ Ссылка ]
13. Python 3 basics for Beginner
[ Ссылка ]
14. Statistics with Python
[ Ссылка ]
15. Sklearn Scikit Learn Machine Learning
[ Ссылка ]
16. Python Pandas Dataframe Operations
[ Ссылка ]
17. Linear Regression, Supervised Machine Learning
[ Ссылка ]
18 Interiew Questions on Machine Learning and Data Science
[ Ссылка ]
19. Jupyter Notebook Operations
[ Ссылка ]_
![](https://s2.save4k.ru/pic/vd7duB8hHeM/mqdefault.jpg)