擅长:python、mysql、java
<p>使用scikit:
<a href="http://scikit-learn.org/stable/modules/preprocessing.html#scaling-features-to-a-range" rel="nofollow">http://scikit-learn.org/stable/modules/preprocessing.html#scaling-features-to-a-range</a></p>
<p>它具有内置函数,可以将特征缩放到指定范围。您将在这里找到其他要规范化和标准化的函数。</p>
<p>请参见以下示例:</p>
<pre><code>>>> 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. ]])
</code></pre>