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

  • 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'])
主站蜘蛛池模板: 金塔县| 阿克苏市| 托里县| 峡江县| 鄂尔多斯市| 洱源县| 于田县| 来宾市| 灌云县| 温州市| 景洪市| 英吉沙县| 凤山市| 阿尔山市| 乌拉特中旗| 沽源县| 丁青县| 永仁县| 临洮县| 炉霍县| 浑源县| 安多县| 五家渠市| 南汇区| 茶陵县| 平定县| 蚌埠市| 克什克腾旗| 华安县| 青神县| 天津市| 泰顺县| 榆树市| 云安县| 白玉县| 奇台县| 屯昌县| 广元市| 三穗县| 都匀市| 都江堰市|