1. Learn
  2. /
  3. Courses
  4. /
  5. Machine Learning for Marketing in Python

Exercise

Explore logistic regression coefficients

You will now explore the coefficients of the logistic regression to understand what is driving churn to go up or down. For this exercise, you will extract the logistic regression coefficients from your fitted model, and calculate their exponent to make them more interpretable.

The fitted logistic regression instance is loaded as logreg and the scaled features are loaded as a pandas DataFrame called train_X. The numpy and pandas libraries are loaded as np and pd respectively.

Instructions

100 XP
  • Combine feature names and coefficients into a pandas DataFrame.
  • Calculate the exponent of the logistic regression coefficients.
  • Remove the coefficients that are equal to zero and print them sorted by the exponent coefficient.