Skip to content

Instantly share code, notes, and snippets.

@dsal1951
Last active August 11, 2017 03:30
Show Gist options
  • Save dsal1951/922529c73a77bc3c80000e2c91897321 to your computer and use it in GitHub Desktop.
Save dsal1951/922529c73a77bc3c80000e2c91897321 to your computer and use it in GitHub Desktop.
#Actual Outcome (y=1 converted to customer, y=0 did not convert to customer
convert_actual = y
#Predicted Probability that lead converts into a customer
convert_prob = clf.predict_proba(x)
cols = ['CONVERT_ACTUAL','CONVERT_PROB']
data = [convert_actual,convert_prob[:,1]]
df = pd.DataFrame(dict(zip(cols,data)))
#Sort Ascending based on Predicted Probability y=1
df.sort_values('CONVERT_PROB',ascending=False)
#Create 10 Bins where First Bin has Leads with the
#Highest Predicted Probability that y = 1
df['GROUP'] = pd.qcut(df['CONVERT_PROB'],10,labels=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment