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

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'])
主站蜘蛛池模板: 新田县| 成安县| 左贡县| 新建县| 临邑县| 平远县| 江口县| 远安县| 霍邱县| 康马县| 五指山市| 舟曲县| 宁远县| 台中市| 迁安市| 正安县| 固安县| 大渡口区| 安阳市| 澳门| 公主岭市| 子洲县| 桐城市| 延吉市| 伊通| 登封市| 门头沟区| 灵山县| 永宁县| 通河县| 莆田市| 韶关市| 宜宾市| 西贡区| 车险| 尚义县| 隆安县| 镇安县| 根河市| 怀化市| 全南县|