Feature Engineering: Scaling and Selection in python machine learning
In this project, we will learn concept of feature engineering.
Formula:
#feature scaling
def featureScaling(arr):
max_num = max(arr)
min_num = min(arr)
lst = []
for num in arr:
X_prime = (num - min_num) / (max_num - min_num)
lst.append(X_prime)
return lst
# tests of your feature scaler--line below is input data
data = [115, 140, 175]
print(featureScaling(data))
Output:
[0.0, 0.4166666666666667, 1.0]
Feature Scaling in Scikit-learn
Import the libraries
#importing the scikit-learn libraries
from sklearn.preprocessing import MinMaxScaler
import numpy as np
# 3 different training points for 1 feature
weights = np.array([[115], [140], [175]]).astype(float)
Now it fit into the model
# Rescale
rescaled_weights = scaler.fit_transform(weights)
rescaled_weights
Output:
array([[0. ], [0.41666667], [1. ]])
Get your project or assignment completed by Deep learning expert and experienced developers and researchers.
OR
If you have project files, You can send at codersarts@gmail.com directly