GithubHelp home page GithubHelp logo

analyzefit's Introduction

PyPIBuild StatuscodecovCode Health

analyzefit

Analyze fit is a python package that performs standard analysis on the fit of a regression model. The analysis class validate method will create a residuals vs fitted plot, a quantile plot, a spread location plot, and a leverage plot for the model provided as well as print the accuracy scores for any metric the user likes. For example:

alt_text

If a detailed plot is desired then the plots can also be generated individually using the methods res_vs_fit, quantile, spread_loc, and leverage respectively. By default when the plots are created individually they are rendered in an interactive inverontment using the bokeh plotting package. For example:

alt text

This allows the user to determine which points the model is failing to predict.

Full API Documentation available at: github pages.

Installing the code

To install analyzefit you may either pip install:

pip install analyzefit

or clone this repository and install manually:

python setup.py install

Validating a Model

To use analyze fit simply pass the feature matrix, target values, and the model to the analysis class then call the validate method, (or any other plotting method). For example:

import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.model_selection import train_test_split
from analyzefit import Analysis

df = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data', header=None,sep="\s+")
df.columns = ["CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B","LSTAT","MEDV"]
X = df.iloc[:,:-1].values
y = df[["MEDV"]].values
X_train, X_test,y_train,y_test = train_test_split(X,y, test_size=0.3,random_state=0)
slr = LinearRegression()
slr.fit(X_train,y_train)

an = Analysis(X_train, y_train, slr)
an.validate()

an.validate(X=X_test, y=y_test, metric=[mean_squared_error, r2_score])

an.res_vs_fit()

an.quantile()

an.spread_loc()

an.leverage()

Python Packages Used

  • numpy

  • matplotlib

  • bokeh

  • sklearn

analyzefit's People

Contributors

chmodsss avatar wsmorgan avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

chmodsss

analyzefit's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.