API Adds defaults to Display Objects#16933
Conversation
rth
left a comment
There was a problem hiding this comment.
This is nice, thanks @thomasjpfan !
NicolasHug
left a comment
There was a problem hiding this comment.
This is nice!
Nits but LGTM when addressed
| Display labels for plot. If None, display labels are set to 0 to | ||
| `n_classes`. |
There was a problem hiding this comment.
| 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`. |
| if self.display_labels is None: | ||
| display_labels = np.arange(n_classes) | ||
| else: | ||
| display_labels = self.display_labels |
There was a problem hiding this comment.
Do we like that kind of idiom? Just wondering
display_labels = self.display_labels or np.arange(n_classes)There was a problem hiding this comment.
We can not do this because self.display_labels can be a numpy array.
| @@ -0,0 +1,91 @@ | |||
| """ | |||
| =================================== | |||
| Visualizations with Display Objects | |||
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| # classification problem where the target is if an individual donated blood. | |
| # classification problem where the target is whether an individual donated blood. |
not sure
| # dataset. These predictions are used to compute confustion matrix and | ||
| # plot with the :class:`ConfusionMatrixDisplay` |
There was a problem hiding this comment.
| # 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 |
There was a problem hiding this comment.
| # 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: |
There was a problem hiding this comment.
| # a decision function, we will use it to plot he roc curve: | |
| # a decision function, we will use it to plot the roc curve: |
| # 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. |
There was a problem hiding this comment.
| # 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. |
There was a problem hiding this comment.
I would suggest "... store the computed values that were passed as arguments"
|
tests failing |
|
I think the only thing left is a link from the UG to the example. |
|
I think all your suggestions are addressed now @NicolasHug , could you maybe have another look? |
|
thanks @thomasjpfan |
Reference Issues/PRs
Partially addresses #15880 with more docs.
What does this implement/fix? Explain your changes.
This PR adds