1

I produced a lift curve of answers predicted through 2 models: logistic regression and decision tree. I get 2 separate plots on two separate graphs. I need a single graph depicting both the plots. How to do that?

import scikitplot as skplt
log_y_probas = logmodel.predict_proba(X_test)
dec_y_probas = DecisionTreeModel.predict_proba(X_test);

skplt.metrics.plot_lift_curve(y_test,log_y_probas);
skplt.metrics.plot_lift_curve(y_test,dec_y_probas);
plt.show();

I receive two different plots on two different graphs. I need both the plots on the single graph. What should I do? Or should I use a different Python library somehow?

Venkatachalam
  • 16,288
  • 9
  • 49
  • 77

1 Answers1

1

In Python, there is no need to end statements with semicolons.

Anyway, each call to plot_lift_curve returns an Axes object if the ax parameter is not specified. You can use that to plot both curves on the same Axes:

ax = skplt.metrics.plot_lift_curve(y_test, log_y_probas)
skplt.metrics.plot_lift_curve(y_test, dec_y_probas, ax=ax)
plt.show()
gmds
  • 19,325
  • 4
  • 32
  • 58
  • Thank you! Could you please tell if it is possible to add legends to the curve to depict which line corresponds to decision tree and which to logistic regression? If yes, how? – Simrat Pal Singh Satia Apr 14 '19 at 09:41
  • I actually haven't used `skplt` before, so I'm not sure what functionality it exposes for that kind of thing, but you can try to create your own legend (see the docs)! – gmds Apr 14 '19 at 10:17