scikit normalize
from sklearn.preprocessing import normalize
X_normalized = normalize(X, norm='l2', *, axis=1, copy=True, return_norm=False)
scikit normalize
from sklearn.preprocessing import normalize
X_normalized = normalize(X, norm='l2', *, axis=1, copy=True, return_norm=False)
feature scaling in python
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
from sklearn.linear_model import Ridge
X_train, X_test, y_train, y_test = train_test_split(X_data, y_data,
random_state = 0)
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)
Scaling features to a range
# Scaling features to a range using MinMaxScaler
X_train = np.array([[ 1., -1., 2.],
[ 2., 0., 0.],
[ 0., 1., -1.]])
min_max_scaler = preprocessing.MinMaxScaler()
X_train_minmax = min_max_scaler.fit_transform(X_train)
X_train_minmax
# array([[0.5 , 0. , 1. ],
# [1. , 0.5 , 0.33333333],
# [0. , 1. , 0. ]])
X_test = np.array([[-3., -1., 4.]])
X_test_minmax = min_max_scaler.transform(X_test)
X_test_minmax
# array([[-1.5 , 0. , 1.66666667]])
min_max_scaler.scale_
# array([0.5 , 0.5 , 0.33...])
min_max_scaler.min_
# array([0. , 0.5 , 0.33...])
normalizer in sklearn
class sklearn.preprocessing.Normalizer(norm='l2', *, copy=True)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us