# lets take a look at our coefficients from earlier. # we can see that the features that impact survival positively are 'Contract_One year', 'Contract_Two year', # 'PaymentMethod_Bank transfer (automatic)', 'PaymentMethod_Credit card (automatic)'. Beyond these the results are # insignificant. Lets compare customers with the features to understand the best place to spend money. upgrades = ['Contract_One year', 'Contract_Two year', 'PaymentMethod_Bank transfer (automatic)', 'PaymentMethod_Credit card (automatic)'] results_dict = {} for customer in tqdm(values.index): actual = data.loc[[customer]] change = data.loc[[customer]] results_dict[customer] = [cph.predict_median(actual)] for upgrade in upgrades: change[upgrade] = 1 if list(change[upgrade]) == [0] else 0 results_dict[customer].append(cph.predict_percentile(actual, p=likelihood_cutoff)) change[upgrade] = 1 if list(change[upgrade]) == [0] else 0 results_df = pd.DataFrame(results_dict).T results_df.columns = ['baseline'] + upgrades actions = values.join(results_df).drop([likelihood_cutoff], axis=1) # now we can calculate the difference between applying different features from the baseline actions['CreditCard Diff'] = ( actions['PaymentMethod_Credit card (automatic)'] - actions['baseline'] ) * actions['MonthlyCharges'] actions['BankTransfer Diff'] = ( actions['PaymentMethod_Bank transfer (automatic)'] - actions['baseline'] ) * actions['MonthlyCharges'] actions['1yrContract Diff'] = (