Skip to content

Commit

Permalink
Merge branch 'develop' into manual-alphas
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccabilbro committed Jun 10, 2020
2 parents 6e1d05e + 6a004ed commit 2ed5dbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions docs/api/classifier/rocauc.rst
Expand Up @@ -52,8 +52,7 @@ Workflow Model evaluation
Multi-class ROCAUC Curves
-------------------------

Yellowbrick's ``ROCAUC`` Visualizer does allow for plotting multiclass classification curves.
ROC curves are typically used in binary classification, and in fact the Scikit-Learn ``roc_curve`` metric is only able to perform metrics for binary classifiers. Yellowbrick addresses this by binarizing the output (per-class) or to use one-vs-rest (micro score) or one-vs-all (macro score) strategies of classification.
Yellowbrick's ``ROCAUC`` Visualizer does allow for plotting multiclass classification curves. ROC curves are typically used in binary classification, and in fact the Scikit-Learn ``roc_curve`` metric is only able to perform metrics for binary classifiers. Yellowbrick addresses this by binarizing the output (per-class) or to use one-vs-rest (micro score) or one-vs-all (macro score) strategies of classification.

.. plot::
:context: close-figs
Expand Down
16 changes: 9 additions & 7 deletions yellowbrick/classifier/rocauc.py
Expand Up @@ -208,7 +208,7 @@ def __init__(

# Set the visual parameters for ROCAUC
# NOTE: the binary flag breaks our API since it's really just a meta parameter
# for micro, macro, and per_class. We knew this going into it, but did it anyway.
# for micro, macro, and per_class. We knew this going in, but did it anyway.
if binary:
self.set_params(micro=False, macro=False, per_class=False)
else:
Expand Down Expand Up @@ -261,10 +261,11 @@ def score(self, X, y=None):
y_pred = self._get_y_scores(X)

if self.target_type_ == BINARY:
# If it's binary classification, to draw micro or macro curves per_class must be True
# For binary, per_class must be True to draw micro/macro curves
if (self.micro or self.macro) and not self.per_class:
raise ModelError(
"no curves will be drawn; set per_class=True or micro=False and macro=False."
"no curves will be drawn; ",
"set per_class=True or micro=False and macro=False.",
)
if self.target_type_ == MULTICLASS:
# If it's multiclass classification, at least one of micro, macro, or
Expand All @@ -284,7 +285,7 @@ def score(self, X, y=None):
self.tpr = dict()
self.roc_auc = dict()

# If the decision is binary draw only ROC curve for the postitive class
# If the decision is binary draw only ROC curve for the positive class
if self.target_type_ is BINARY and not self.per_class:
# In this case predict_proba returns an array of shape (n, 2) which
# specifies the probabilities of both the negative and positive classes.
Expand Down Expand Up @@ -430,7 +431,7 @@ def finalize(self, **kwargs):
self.ax.set_ylim([0.0, 1.0])

# Set x and y axis labels
self.ax.set_ylabel("True Postive Rate")
self.ax.set_ylabel("True Positive Rate")
self.ax.set_xlabel("False Positive Rate")

def _get_y_scores(self, X):
Expand Down Expand Up @@ -563,7 +564,7 @@ def roc_auc(
y_train : array-like, 2D
The vector of target data or the dependent variable predicted by X. Used to fit
the visualizer and also to score the visualizer if test splits are not specified.
the visualizer and also to score the visualizer if test splits not specified.
X_test: array-like, 2D, default: None
The table of instance data or independent variables that describe the outcome of
Expand Down Expand Up @@ -694,7 +695,8 @@ def roc_auc(
# Fit and transform the visualizer (calls draw)
visualizer.fit(X_train, y_train, **kwargs)

# Scores the visualizer with X_test and y_test if provided, X_train, y_train if not provided
# Scores the visualizer with X_test and y_test if provided,
# X_train, y_train if not provided
if X_test is not None and y_test is not None:
visualizer.score(X_test, y_test)
else:
Expand Down

0 comments on commit 2ed5dbc

Please sign in to comment.