I am trying to build a lift chart using scikitplot library.

I am getting the following can anyone guide with the error.

please find the code with the error


import scikitplot as skplt
actual = df['Actual']
predicted = df['Pred']


IndexError                                Traceback (most recent call last)
<ipython-input-38-f14ae9c16143> in <module>
      6 pdt = np.array(predicted)
      7 # plotLiftChart(actual,predicted)
----> 8 skplt.metrics.plot_lift_curve(act,pdt)
      9 # plt.show()

~\Anaconda3\lib\site-packages\scikitplot\metrics.py in plot_lift_curve(y_true, y_probas, title, ax, figsize, title_fontsize, text_fontsize)
   1193     # Compute Cumulative Gain Curves
-> 1194     percentages, gains1 = cumulative_gain_curve(y_true, y_probas[:, 0],
   1195                                                 classes[0])
   1196     percentages, gains2 = cumulative_gain_curve(y_true, y_probas[:, 1],

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

please guide where I have done the mistake


1 Answer 1


The mistake is not to have read the documentation ;)

scikitplot.metrics.plot_lift_curve(y_true, y_probas,...)


  • y_true (array-like, shape (n_samples)) – Ground truth (correct) target values.
  • y_probas (array-like, shape (n_samples, n_classes)) – Prediction probabilities for each class returned by a classifier.

The second parameter y_probas should be a double-dimension array of the predicted probabilities for every class, not a single dimension array of the predicted class.

You can also check the example provided in the documentation which contains:

y_probas = lr.predict_proba(X_test)
  • $\begingroup$ Thank you Erwan Can you help me how to interpret the results $\endgroup$
    – PavanKumar
    Sep 17, 2020 at 2:26
  • $\begingroup$ @PavanKumar Sorry I'm not familiar with these curves, but you can ask a new question. $\endgroup$
    – Erwan
    Sep 17, 2020 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.