Skip to content

Commit

Permalink
Merge branch 'feature-api' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort committed Jun 3, 2016
2 parents b2218fa + cb75e0e commit d3e2454
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.org/DistrictDataLabs/yellowbrick.svg?branch=master)](https://travis-ci.org/DistrictDataLabs/yellowbrick)
[![Coverage Status](https://coveralls.io/repos/github/DistrictDataLabs/yellowbrick/badge.svg?branch=master)](https://coveralls.io/github/DistrictDataLabs/yellowbrick?branch=master)
[![Code Health](https://landscape.io/github/DistrictDataLabs/yellowbrick/master/landscape.svg?style=flat)](https://landscape.io/github/DistrictDataLabs/yellowbrick/master)
[![Documentation Status](https://readthedocs.org/projects/yellowbrick/badge/?version=latest)](http://yellowbrick.readthedocs.io/en/latest/?badge=latest)
[![Stories in Ready](https://badge.waffle.io/DistrictDataLabs/yellowbrick.png?label=ready&title=Ready)](https://waffle.io/DistrictDataLabs/yellowbrick)

Expand Down
81 changes: 81 additions & 0 deletions yellowbrick/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# yellowbrick.base
# Abstract base classes and interface for Yellowbrick.
#
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com>
# Created: Fri Jun 03 10:20:59 2016 -0700
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: base.py [] benjamin@bengfort.com $

"""
Abstract base classes and interface for Yellowbrick.
"""

from .exceptions import YellowbrickTypeError
from sklearn.base import BaseEstimator, TransformerMixin

##########################################################################
## Base class hierarhcy
##########################################################################

class BaseVisualization(object):
"""
The root of the visual object hierarchy that defines how yellowbrick
creates, stores, and renders visual artifcats using matplotlib.
"""

def render(self):
"""
Render is the primary entry point for producing the visualization.
"""
raise NotImplementedError(
"All visualizations must specify their own render methodology"
)


class FeatureVisualization(BaseVisualization, BaseEstimator, TransformerMixin):
"""
A feature visualization class accepts as input a DataFrame or Numpy array
in order to investigate features individually or together.
FeatureVisualization is itself a transformer so that it can be used in
a Scikit-Learn Pipeline to perform automatic visual analysis during build.
"""

def fit(self, X, y=None, **kwargs):
pass

def transform(self, X):
pass

def render(self, data=None):
"""
A feature visualization renders data.
"""
raise NotImplementedError(
"Please specify how to render the feature visualization"
)


class ModelVisualization(BaseVisualization, BaseEstimator):
"""
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.
"""

def fit(self, X, y=None, **kwargs):
pass

def predict(self, X):
pass

def render(self, model=None):
"""
A model visualization renders a model
"""
raise NotImplementedError(
"Please specify how to render the model visualization"
)
9 changes: 9 additions & 0 deletions yellowbrick/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
from sklearn.metrics import classification_report

from .color import ddlheatmap
from .base import ModelVisualization


##########################################################################
## Classification Visualization Base Object
##########################################################################

class ClassifierVisualization(ModelVisualization):
pass


##########################################################################
Expand Down
45 changes: 45 additions & 0 deletions yellowbrick/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# yellowbrick.exceptions
# Exceptions hierarchy for the yellowbrick library
#
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com>
# Created: Fri Jun 03 10:39:41 2016 -0700
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: exceptions.py [] benjamin@bengfort.com $

"""
Exceptions hierarchy for the yellowbrick library
"""

##########################################################################
## Exceptions Hierarchy
##########################################################################

class YellowbrickError(Exception):
"""
The root exception for all yellowbrick related errors.
"""
pass


class VisualError(YellowbrickError):
"""
A problem when interacting with matplotlib or the display framework.
"""
pass


class ModelError(YellowbrickError):
"""
A problem when interacting with sklearn or the ML framework.
"""
pass


class YellowbrickTypeError(YellowbrickError, TypeError):
"""
There was an unexpected type or none for a property or input.
"""
pass
28 changes: 28 additions & 0 deletions yellowbrick/regressor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# yellowbrick.regressor
# Visualizations related to evaluating Scikit-Learn regressor models
#
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com>
# Created: Fri Jun 03 10:30:36 2016 -0700
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: regressor.py [] benjamin@bengfort.com $

"""
Visualizations related to evaluating Scikit-Learn regressor models
"""

##########################################################################
## Imports
##########################################################################

from .base import ModelVisualization


##########################################################################
## Regression Visualization Base Object
##########################################################################

class RegressorVisualization(ModelVisualization):
pass

0 comments on commit d3e2454

Please sign in to comment.