From 0d9f4c2808202409b7710d9cdbc8bf533593cf91 Mon Sep 17 00:00:00 2001 From: acdm123 <39374111+acdm123@users.noreply.github.com> Date: Sun, 26 Sep 2021 14:43:13 +0800 Subject: [PATCH] Update customer_churn.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新版pandas中已不使用ix函数,用loc和iloc替代了 --- statistics/customer_churn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/statistics/customer_churn.py b/statistics/customer_churn.py index b5acc27..2d16bbd 100755 --- a/statistics/customer_churn.py +++ b/statistics/customer_churn.py @@ -113,7 +113,7 @@ def inverse_logit(model_formula): print("Probability of churn when account length changes by 1: %.2f" % (inverse_logit(cust_serv_mean) - inverse_logit(cust_serv_mean_minus_one))) # Predict churn for "new" observations -new_observations = churn.ix[churn.index.isin(xrange(10)), independent_variables.columns] +new_observations = churn.loc[churn.index.isin(range(10)), independent_variables.columns] new_observations_with_constant = sm.add_constant(new_observations, prepend=True) y_predicted = logit_model.predict(new_observations_with_constant) y_predicted_rounded = [round(score, 2) for score in y_predicted] @@ -135,4 +135,4 @@ def inverse_logit(model_formula): # Predict output value for a new observation based on its mean standardized input values input_variables = [0., 0., 0., 1.] predicted_value = logit_model.predict(input_variables) -print("Predicted value: %.5f") % predicted_value \ No newline at end of file +print("Predicted value: %.5f") % predicted_value