-
-
Save amandaiglesiasmoreno/4a4b136993927b53df7c9768c432797d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# function that computes the mutual infomation score between a categorical serie and the column Churn | |
def compute_mutual_information(categorical_serie): | |
return mutual_info_score(categorical_serie, df_telco.Churn) | |
# select categorial variables excluding the response variable | |
categorical_variables = df_telco.select_dtypes(include=object).drop('Churn', axis=1) | |
# compute the mutual information score between each categorical variable and the target | |
feature_importance = categorical_variables.apply(compute_mutual_information).sort_values(ascending=False) | |
# visualize feature importance | |
print(feature_importance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment