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

Binning

This kind of quantitative transformation is used to create quantiles. In this case, the quantitative feature values will be the transformed ordered variable. This approach is not a good choice for linear regression, but it might work well for learning algorithms that respond effectively when using ordered/categorical variables.

The following code applies this kind of transformation to the Fare feature:

# Binarizing the features by binning them into quantiles
df_titanic_data['Fare_bin'] = pd.qcut(df_titanic_data['Fare'], 4)

if keep_binary:
df_titanic_data = pd.concat(
[df_titanic_data, pd.get_dummies(df_titanic_data['Fare_bin']).rename(columns=lambda x: 'Fare_' + str(x))],
axis=1)
主站蜘蛛池模板: 浙江省| 聂拉木县| 大悟县| 乐都县| 晋江市| 高雄县| 望都县| 洱源县| 商洛市| 博湖县| 丰原市| 九寨沟县| 渑池县| 普宁市| 老河口市| 甘肃省| 晋中市| 兴仁县| 贞丰县| 郎溪县| 汤原县| 彩票| 湘阴县| 颍上县| 新郑市| 河间市| 临海市| 万年县| 嫩江县| 云龙县| 敦煌市| 赤水市| 渑池县| 丰台区| 云和县| 海原县| 丹东市| 绍兴县| 玛沁县| 吴堡县| 永胜县|