Skip to content

Commit

Permalink
adds super method to score visualizers
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Bilbro committed Oct 8, 2016
1 parent 1efae1f commit 76d2d1f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 4 additions & 4 deletions yellowbrick/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ScoreVisualizer(Visualizer):
"""

def __init__(self, model):
pass
super(ScoreVisualizer, self).__init__(**kwargs)

def fit(self, X, y=None):
return self
Expand Down Expand Up @@ -121,9 +121,9 @@ def poof(self, **kwargs):

class ModelVisualizer(Visualizer):
"""
A model visualization class accepts as input a Scikit-Learn estimator(s)
and is itself an estimator (to be included in a Pipeline) in order to
visualize the efficacy of a particular fitted model.
A model visualization accepts as input an unfitted Scikit-Learn estimator(s)
and enables the user to visualize the performance of models across a range
of hyperparameter values (e.g. using VisualGridsearch and ValidationCurve).
"""

def fit(self, X, y=None, **kwargs):
Expand Down
6 changes: 6 additions & 0 deletions yellowbrick/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def __init__(self, model):
Check to see if model is an instance of a classifer.
Should return an error if it isn't.
"""
super(ClassificationScoreVisualizer, self).__init__(**kwargs)

if not isclassifier(model):
raise YellowbrickTypeError(
"This estimator is not a classifier; try a regression or clustering score visualizer instead!"
Expand All @@ -60,6 +62,8 @@ def __init__(self, model, **kwargs):
"""
Pass in a fitted model to generate a ROC curve.
"""
super(ClassificationReport, self).__init__(**kwargs)

self.estimator = model
self.name = get_model_name(self.estimator)
self.cmap = kwargs.pop('cmap', ddlheatmap)
Expand Down Expand Up @@ -124,6 +128,8 @@ def __init__(self, model, **kwargs):
"""
Pass in a model to generate a ROC curve.
"""
super(ROCAUC, self).__init__(**kwargs)

self.estimator = model
self.name = get_model_name(self.estimator)
super(ROCAUC, self).__init__(model, **kwargs)
Expand Down
15 changes: 14 additions & 1 deletion yellowbrick/regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from .exceptions import YellowbrickTypeError
from .utils import get_model_name, isestimator, isregressor
from .base import Visualizer, ScoreVisualizer, MultiModelMixin
# from sklearn.cross_validation import train_test_split as tts

##########################################################################
## Regression Visualization Base Object
Expand All @@ -37,6 +36,8 @@ def __init__(self, model):
Check to see if model is an instance of a regressor.
Should return an error if it isn't.
"""
super(RegressionScoreVisualizer, self).__init__(**kwargs)

if not isregressor(model):
raise YellowbrickTypeError(
"This estimator is not a regressor; try a classifier or clustering score visualizer instead!"
Expand All @@ -52,6 +53,8 @@ class PredictionError(RegressionScoreVisualizer):
predicted values generated by our model(s).
"""
def __init__(self, model, **kwargs):
super(PredictionError, self).__init__(**kwargs)

self.estimator = model
self.name = get_model_name(self.estimator)
self.colors = {
Expand Down Expand Up @@ -96,7 +99,17 @@ def poof(self):
##########################################################################

class ResidualsPlot(RegressionScoreVisualizer):
"""
A residual plot shows the residuals on the vertical axis
and the independent variable on the horizontal axis.
If the points are randomly dispersed around the horizontal axis,
a linear regression model is appropriate for the data;
otherwise, a non-linear model is more appropriate.
"""
def __init__(self, model, **kwargs):
super(ResidualsPlot, self).__init__(**kwargs)

self.estimator = model
self.name = get_model_name(self.estimator)
self.colors = {
Expand Down

0 comments on commit 76d2d1f

Please sign in to comment.