- 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)
推薦閱讀
- 大數(shù)據(jù)導(dǎo)論:思維、技術(shù)與應(yīng)用
- Practical Data Wrangling
- Learning Apache Spark 2
- 精通Excel VBA
- iClone 4.31 3D Animation Beginner's Guide
- 數(shù)據(jù)庫(kù)原理與應(yīng)用技術(shù)
- 機(jī)器人創(chuàng)新實(shí)訓(xùn)教程
- AWS Certified SysOps Administrator:Associate Guide
- Supervised Machine Learning with Python
- Pig Design Patterns
- Visual C++編程全能詞典
- 工業(yè)機(jī)器人操作與編程
- 統(tǒng)計(jì)學(xué)習(xí)理論與方法:R語(yǔ)言版
- AI的25種可能
- Mastering Geospatial Analysis with Python