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

  • 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'])
主站蜘蛛池模板: 菏泽市| 偃师市| 河津市| 馆陶县| 开封市| 兴仁县| 舒兰市| 色达县| 桂平市| 台湾省| 鹤岗市| 龙门县| 古浪县| 宿州市| 井冈山市| 余庆县| 晴隆县| 潮安县| 桑植县| 平潭县| 崇礼县| 仁寿县| 江油市| 辽阳市| 孟津县| 石楼县| 米泉市| 宜州市| 诏安县| 康乐县| 南召县| 普洱| 潢川县| 昌吉市| 咸宁市| 成安县| 株洲市| 龙里县| 太仓市| 吴桥县| 三门县|