1>>> from sklearn import preprocessing
2>>>
3>>> data = [100, 10, 2, 32, 31, 949]
4>>>
5>>> preprocessing.normalize([data])
6array([[0.10467389, 0.01046739, 0.00209348, 0.03349564, 0.03244891,0.99335519]])
7
1from sklearn.preprocessing import MinMaxScaler
2scaler = MinMaxScaler()
3from sklearn.linear_model import Ridge
4X_train, X_test, y_train, y_test = train_test_split(X_data, y_data,
5 random_state = 0)
6
7X_train_scaled = scaler.fit_transform(X_train)
8X_test_scaled = scaler.transform(X_test)
9
1from sklearn import preprocessing
2normalizer = preprocessing.Normalizer().fit(X_train)
3X_train = normalizer.transform(X_train)
4X_test = normalizer.transform(X_test)
1# Scaling features to a range using MaxAbsScaler
2
3X_train = np.array([[ 1., -1., 2.],
4 [ 2., 0., 0.],
5 [ 0., 1., -1.]])
6
7max_abs_scaler = preprocessing.MaxAbsScaler()
8X_train_maxabs = max_abs_scaler.fit_transform(X_train)
9X_train_maxabs
10# array([[ 0.5, -1., 1. ],
11# [ 1. , 0. , 0. ],
12# [ 0. , 1. , -0.5]])
13X_test = np.array([[ -3., -1., 4.]])
14X_test_maxabs = max_abs_scaler.transform(X_test)
15X_test_maxabs
16# array([[-1.5, -1. , 2. ]])
17max_abs_scaler.scale_
18# array([2., 1., 2.])
1pd.merge(left, right, how='inner', on=None, left_on=None, right_on=None,
2left_index=False, right_index=False, sort=True)
3