plot warning message

Question:

I encounter the following warning message when I run the following code:

disp = plot_confusion_matrix(
    xgb_clf, X_test, y_test, 
    cmap='Blues', values_format='d', 
    display_labels=['Default', 'Fully-Paid']
)

disp = plot_roc_curve(xgb_clf, X_test, y_test)

The warning message are as follows

C:Users***anaconda3libsite-packagessklearnutilsdeprecation.py:87: FutureWarning: Function plot_confusion_matrix is deprecated; Function `plot_confusion_matrix` is deprecated in 1.0 and will be removed in 1.2. Use one of the class methods: ConfusionMatrixDisplay.from_predictions or ConfusionMatrixDisplay.from_estimator.
  warnings.warn(msg, category=FutureWarning)
C:Users***anaconda3libsite-packagessklearnutilsdeprecation.py:87: FutureWarning: Function plot_roc_curve is deprecated; Function :func:`plot_roc_curve` is deprecated in 1.0 and will be removed in 1.2. Use one of the class methods: :meth:`sklearn.metric.RocCurveDisplay.from_predictions` or :meth:`sklearn.metric.RocCurveDisplay.from_estimator`.
  warnings.warn(msg, category=FutureWarning)

What to do step by step to address the warning message?

Asked By: Michael

||

Answers:

It means that the people who create the library you’re using (sklearn, in this case) have decided to phase out the function you’re using and to replace them with class methods. The old function still works in the current version, but it will be removed in a future version. People are already getting this message to encourage them to switch to the new methods, so as to smoothen the transition. The new class methods already work, so for a transitional period both the old and the new way work, but in the longer run the aim is to eliminate the old ones.

For you, this means that it’s worthwhile to familiarise yourself with the new class methods for the future, if you want to keep using sklearn in its future versions. But if you just want a small script to run for now, you can leave it at that, since for now it does the job.

Answered By: Schnitte
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.