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

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'])
主站蜘蛛池模板: 南郑县| 仲巴县| 合山市| 友谊县| 马尔康县| 尚志市| 汉寿县| 凯里市| 广宗县| 新疆| 霍邱县| 丹阳市| 鞍山市| 南澳县| 张家界市| 璧山县| 平度市| 诸暨市| 阿拉善盟| 浦城县| 翼城县| 砚山县| 宜昌市| 桐庐县| 香河县| 成都市| 辉县市| 化州市| 龙江县| 屏山县| 平阴县| 博乐市| 桂林市| 麻阳| 长沙市| 麦盖提县| 北安市| 常德市| 游戏| 灵宝市| 德阳市|