# -*- coding: utf-8 -*-

"""This module contains functions for making plots relevant to regressors."""
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from __future__ import unicode_literals



@@ -123,22 +123,23 @@
 ort 
-print_function
+absolute_import
 %0Afro
@@ -186,39 +186,38 @@
 re__ import 
-absolute_import
+print_function
 %0Afrom __futu
@@ -246,9 +246,2264 @@
 terals%0A%0A
+import matplotlib.pyplot as plt%0Aimport seaborn.apionly as sns%0Afrom sklearn import linear_model as lm%0A%0Afrom regressors import stats%0A%0Asupported_linear_models = (lm.LinearRegression, lm.Lasso, lm.Ridge,%0A                           lm.ElasticNet)%0A%0A%0Adef plot_residuals(clf, X, y, r_type='standardized', figsize=(10, 10)):%0A    %22%22%22Plot residuals of a linear model.%0A%0A    Parameters%0A    ----------%0A    clf : sklearn.linear_model%0A        A scikit-learn linear model classifier with a %60predict()%60 method.%0A    X : numpy.ndarray%0A        Training data used to fit the classifier.%0A    y : numpy.ndarray%0A        Target training values, of shape = %5Bn_samples%5D.%0A    r_type : str%0A        Type of residuals to return: %5B'raw', 'standardized', 'studentized'%5D.%0A        Defaults to 'standardized'.%0A%0A        * 'raw' will return the raw residuals.%0A        * 'standardized' will return the standardized residuals, also known as%0A          internally studentized residuals.%0A        * 'studentized' will return the externally studentized residuals.%0A    figsize : tuple%0A        A tuple indicating the size of the plot to be created, with format%0A        (x-axis, y-axis). Defaults to (10, 10).%0A%0A    Returns%0A    -------%0A    matplotlib.figure.Figure%0A        The Figure instance.%0A    %22%22%22%0A    # Ensure we only plot residuals using classifiers we have tested%0A    assert isinstance(clf, supported_linear_models), (%0A        %22Classifiers of type %7B%7D not currently supported.%22.format(type(clf))%0A    )%0A    # With sns, only use their API so you don't change user stuff%0A    sns.set_context(%22talk%22)  # Increase font size on plot%0A    sns.set_style(%22whitegrid%22)%0A    # Get residuals or standardized residuals%0A    resids = stats.residuals(clf, X, y, r_type)%0A    predictions = clf.predict(X)%0A    # Generate residual plot%0A    y_label = %7B'raw': 'Residuals', 'standardized': 'Standardized Residuals',%0A               'studentized': 'Studentized Residuals'%7D%0A    fig = plt.figure('residuals', figsize=figsize)%0A    plt.scatter(predictions, resids, s=14, c='gray', alpha=0.7)%0A    plt.hlines(y=0, xmin=predictions.min() - 100, xmax=predictions.max() + 100,%0A               linestyle='dotted')%0A    plt.title(%22Residuals Plot%22)%0A    plt.xlabel(%22Predictions%22)%0A    plt.ylabel(y_label%5Br_type%5D)%0A    plt.show()%0A    return fig%0A
 %0A

Add function to make residuals plot