Skip to main content
[![PyPI](https://img.shields.io/pypi/v/analyzefit.svg)](https://pypi.python.org/pypi/analyzefit/)[![Build Status](https://travis-ci.org/wsmorgan/analyzefit.svg?branch=master)](https://travis-ci.org/wsmorgan/analyzefit)[![codecov](https://codecov.io/gh/wsmorgan/analyzefit/branch/master/graph/badge.svg)](https://codecov.io/gh/wsmorgan/analyzefit)[![Code Health](https://landscape.io/github/wsmorgan/analyzefit/master/landscape.svg?style=flat)](https://landscape.io/github/wsmorgan/analyzefit/master)

# 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](../master/support/images/validation.png)

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](../master/support/images/interactive.pdf)

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

Full API Documentation available at: [github pages](https://wsmorgan.github.io/analysefit/).

## 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


Metadata

Release files for analyzefit 0.3.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for analyzefit 0.3.8
File Size Uploaded
analyzefit-0.3.8.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for analyzefit 0.3.8
File Interpreter ABI Platform
analyzefit-0.3.8-py2-none-any.whl Python 2 none any Details

Total release size: 21.4 kB

Release files / analyzefit-0.3.8.tar.gz

Download URL analyzefit-0.3.8.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6d2c7e8b3e92cfe959f91cd1938646f35e8a7df2e254e53de77308f12b642cc0
BLAKE2b-256 checksum
How to use checksums
3ea4d2f592f64785dd87d47d68458df9626945fb3a87dcee08c9952496a8821d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / analyzefit-0.3.8-py2-none-any.whl

Download URL analyzefit-0.3.8-py2-none-any.whl
Size 12.3 kB
Tags Python 2
SHA-256 checksum
How to use checksums
de027905dda05d4ae1ddb22144ca6633b6ce0a96393725005509b24f351c352f
BLAKE2b-256 checksum
How to use checksums
a34c678b51a42c0ed199e3a67492481e46f7ba55040f4f1be3a2d1e6364ca840
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.8 This release

2 release files

0.3.6

2 release files

0.3.4

3 release files

0.3.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page