Diagnostic Plots for Lineare Regression Models. Similar to plot.lm in R.
Project description
Python Library providing Diagnostic Plots for Lineare Regression Models. (Like plot.lm in R.)
I built this, because I missed the diagnostics plots of R for a university project. There are some substitutions in Python for individual charts, but they are spread over different libraries and sometimes don’t show the exact same. My implementation tries to copycat the R-plots, but I didn’t reimplement the R-code: The charts are just based on available documentation.
Installation
Available in PyPi: https://pypi.org/project/lmdiag/
Using pip: pip install lmdiag
Using pipenv: pipenv install lmdiag
Usage
The plots need a fitted Linear Regression Model created by statsmodels as input.
Example
(See also the more extensive Example Notebook)
import numpy as np import matplotlib.pyplot as plt import statsmodels.api as sm import lmdiag %matplotlib inline # In Jupyter # Generate sample model np.random.seed(20) predictor = np.random.normal(size=30, loc=20, scale=3) response = 5 + 5 * predictor + np.random.normal(size=30) X = sm.add_constant(predictor) lm = sm.OLS(response, X).fit() # Plot chart matrix (and enlarge figure) plt.figure(figsize=(10,7)) lmdiag.plot(lm);
Methods
Draw matrix of all plots:
lmdiag.plot(lm)
Draw individual plots:
lmdiag.resid_fit(lm)
lmdiag.q_q(lm)
lmdiag.scale_loc(lm)
lmdiag.resid_lev(lm)
Print useful descriptions for interpretations:
lmdiag.info() (for all plots)
lmdiag.info('<method name>') (for individual plot)
Development
Disclaimer
This is my very first public python library. Don’t expect everything to work smoothly. I’m happy to receive useful feedback or pull requests.
Certification
Packaging and Upload to PyPi
pipenv run rstcheck README.rst (check syntax)
rm -rf ./dist (delete old builds)
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/*
Then new release on github…
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lmdiag-0.2.0.tar.gz
.
File metadata
- Download URL: lmdiag-0.2.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 807e446d42cfa8accfad3bde47772f8718333b4bdf68e97894cc05998a17cdef |
|
MD5 | d18e6417dceeb793e093299551625491 |
|
BLAKE2b-256 | 65de38a2e53fe905d353f53102e633c8a7adec13418a21d5e23e57676bc5983f |
File details
Details for the file lmdiag-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: lmdiag-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 014e28e4e76b47dc1df99ef7696b48d9411f50d6702c8dc3f9b13036665d346a |
|
MD5 | 5891d6427a38d04595cc9152d39383dc |
|
BLAKE2b-256 | 80cbd9c27e8235b4be5788b552672e7adeae571b35876bdd4b5ef6c32fa8aa7f |