官术网_书友最值得收藏!

  • Deep Learning By Example
  • Ahmed Menshawy
  • 103字
  • 2021-06-24 18:52:45

Scaling

This kind of transformation can be applied to numerical features only.

For example, in the Titanic data, the Age feature can reach 100, but the household income may be in millions. Some models are sensitive to the magnitude of values, so scaling such features will help those models perform better. Also, scaling can be used to squash a variable's values to be within a specific range.

The following code will scale the Age feature by removing its mean from each value and scale to the unit variance:

# scale by subtracting the mean from each value
scaler_processing = preprocessing.StandardScaler()
df_titanic_data['Age_scaled'] = scaler_processing.fit_transform(df_titanic_data['Age'])
主站蜘蛛池模板: 凌海市| 南通市| 扎囊县| 六盘水市| 德阳市| 连山| 广水市| 花莲县| 连城县| 屯昌县| 湘西| 罗城| 武乡县| 德州市| 乡城县| 临泽县| 拉萨市| 石柱| 青川县| 延长县| 永仁县| 海原县| 常山县| 阳原县| 拉萨市| 什邡市| 栖霞市| 凤阳县| 房产| 衡山县| 承德市| 乐至县| 江陵县| 杭锦后旗| 思茅市| 凭祥市| 古田县| 乐陵市| 皮山县| 江山市| 无极县|