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

  • 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)
主站蜘蛛池模板: 大丰市| 兴隆县| 萍乡市| 新津县| 浦县| 渝中区| 常德市| 吐鲁番市| 胶南市| 迁安市| 宁南县| 磴口县| 岱山县| 山东| 方山县| 湛江市| 株洲县| 岚皋县| 成武县| 四平市| 雷波县| 武夷山市| 象山县| 阿克| 卢湾区| 黎川县| 宁津县| 宁国市| 长白| 乐至县| 遂昌县| 抚顺市| 和林格尔县| 大连市| 泰安市| 张掖市| 文安县| 乡城县| 广灵县| 德阳市| 波密县|