Skip to content

API Adds defaults to Display Objects#16933

Merged
NicolasHug merged 8 commits intoscikit-learn:masterfrom
thomasjpfan:display_object_example
Apr 23, 2020
Merged

API Adds defaults to Display Objects#16933
NicolasHug merged 8 commits intoscikit-learn:masterfrom
thomasjpfan:display_object_example

Conversation

@thomasjpfan
Copy link
Copy Markdown
Member

Reference Issues/PRs

Partially addresses #15880 with more docs.

What does this implement/fix? Explain your changes.

This PR adds

  1. Defaults to the display object to make it easier to construct.
  2. Example that shows how to create the display objects and plot them.

Copy link
Copy Markdown
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice, thanks @thomasjpfan !

@thomasjpfan thomasjpfan added this to the 0.23 milestone Apr 21, 2020
Copy link
Copy Markdown
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one.

Copy link
Copy Markdown
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice!

Nits but LGTM when addressed

Comment on lines +25 to +26
Display labels for plot. If None, display labels are set to 0 to
`n_classes`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Display labels for plot. If None, display labels are set to 0 to
`n_classes`.
Display labels for plot. If None, display labels are set from 0 to
`n_classes - 1`.

Comment on lines +112 to +115
if self.display_labels is None:
display_labels = np.arange(n_classes)
else:
display_labels = self.display_labels
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we like that kind of idiom? Just wondering

display_labels = self.display_labels or np.arange(n_classes)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can not do this because self.display_labels can be a numpy array.

@@ -0,0 +1,91 @@
"""
===================================
Visualizations with Display Objects
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the visualization UG to link to this example? (just a link in the example box is enough)

:class:`ConfusionMatrixDisplay`, :class:`RocCurveDisplay`, and
:class:`PrecisionRecallDisplay` directly from their respective metrics. This
is an alternative to using their corresponding plot functions when
a model's predictions are already computed or expensive to compute.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest insisting further that this is advanced usage:

Note that this is advanced usage, and in general we recommend using their respective plot functions.

# -------------------------
# For this example, we load a blood transfusion service center data set
# from `OpenML <https://www.openml.org/d/1464>`. This is a binary
# classification problem where the target is if an individual donated blood.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# classification problem where the target is if an individual donated blood.
# classification problem where the target is whether an individual donated blood.

not sure

Comment on lines +40 to +41
# dataset. These predictions are used to compute confustion matrix and
# plot with the :class:`ConfusionMatrixDisplay`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# dataset. These predictions are used to compute confustion matrix and
# plot with the :class:`ConfusionMatrixDisplay`
# dataset. These predictions are used to compute the confusion matrix which
# is plotted with the :class:`ConfusionMatrixDisplay`

##############################################################################
# Create :class:`RocCurveDisplay`
##############################################################################
# The roc curve requires either the probability or the non-thresholded
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# The roc curve requires either the probability or the non-thresholded
# The roc curve requires either the probabilities or the non-thresholded

##############################################################################
# The roc curve requires either the probability or the non-thresholded
# decision values from the estimator. Since the logistic regression provides
# a decision function, we will use it to plot he roc curve:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# a decision function, we will use it to plot he roc curve:
# a decision function, we will use it to plot the roc curve:

Comment on lines +79 to +82
# The display objects stores the computed values of metrics. This allows
# for the visualizations to be easliy combinied using matplotlib's API. In
# the following example, we place the displays next to each other in a
# row.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# The display objects stores the computed values of metrics. This allows
# for the visualizations to be easliy combinied using matplotlib's API. In
# the following example, we place the displays next to each other in a
# row.
# The display objects store the computed values of metrics. This allows
# for the visualizations to be easily combined using matplotlib's API. In
# the following example, we place the displays next to each other in a
# row.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest "... store the computed values that were passed as arguments"

@adrinjalali
Copy link
Copy Markdown
Member

tests failing

@adrinjalali
Copy link
Copy Markdown
Member

I think the only thing left is a link from the UG to the example.

@adrinjalali
Copy link
Copy Markdown
Member

I think all your suggestions are addressed now @NicolasHug , could you maybe have another look?

@NicolasHug NicolasHug merged commit 923b13c into scikit-learn:master Apr 23, 2020
@NicolasHug
Copy link
Copy Markdown
Member

thanks @thomasjpfan

gio8tisu pushed a commit to gio8tisu/scikit-learn that referenced this pull request May 15, 2020
viclafargue pushed a commit to viclafargue/scikit-learn that referenced this pull request Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants