February 2018
Intermediate to advanced
450 pages
11h 27m
English
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 quantilesdf_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)
Read now
Unlock full access