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

  • Deep Learning By Example
  • Ahmed Menshawy
  • 86字
  • 2021-06-24 18:52:46

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)
主站蜘蛛池模板: 会东县| 克东县| 茶陵县| 古浪县| 长海县| 宁夏| 卫辉市| 从化市| 林西县| 成都市| 固始县| 上蔡县| 尼玛县| 敦煌市| 抚州市| 富锦市| 冀州市| 文水县| 德江县| 万源市| 天长市| 桐城市| 改则县| 南岸区| 抚顺市| 富源县| 滕州市| 五寨县| 东安县| 公主岭市| 深圳市| 普安县| 临夏县| 东至县| 那坡县| 涞源县| 土默特左旗| 天等县| 桃江县| 萨嘎县| 中西区|