Skip to main content

A package to test linearity assumptions to determine whether a linear regression model is good or not

Project description

linreg_ally

Documentation Status Python 3.11 codecov

Overview of linreg_ally package:

This project delivers a Python package designed to help users determine if Ordinary Least Squares (“OLS”) regression is an appropriate model for their data. The package automates key steps, including performing OLS regression, data formatting checks, assumption validation, and multicollinearity detection, ensuring the data meets the prerequisites for a reliable model. By simplifying these essential tasks and providing clear diagnostics, the package empowers users to confidently assess the feasibility of linear regression and build accurate predictive models.

Functions in linreg_ally package:

  1. eda_summary: This function uses the training set to check whether the data is formatted correctly to even run a linear regression model and returns a chart that shows the distribution of various features.

  2. check_multicollinearity: This function detects multicollinearity in the training dataset by computing the variance inflation factor (‘VIF’) and pairwise Pearson Correlation for each numeric feature.

  3. run_linear_regression: This function performs linear regression with preprocessing using sklearn and outputs evaluation scoring metrics.

  4. qq_and_residuals_plot: This function tests the normality of residuals and homoscedasticity assumptions for a linear regression model by creating the Q-Q and Residuals vs Fitted Values plots, respectively.

How package fits in Python Ecosystem

linreg_ally provides an alternative to existing packages like StatAssume, which automates model fitting, assumptions checking, and dashboard generation in a single function, and lrasm, which provides specific functions that test certain key assumptions in OLS regression. linreg_ally differentiates itself by providing intuitive, user-friendly functions that guide users through every stage of training an OLS regression model – starting from explanatory data analysis and data preprocessing, progressing to model fitting and evaluating key assumptions in OLS regression.

Installation

$ pip install linreg_ally

Usage

To use this package:

  • Install the package via poetry, run the following command from the root directory of this repo. If poetry hasn't been set up yet, please following this link for installtion.
poetry install
  • Import the required functions from the package
import linreg_ally
from linreg_ally.eda import eda_summary
from linreg_ally.multicollinearity import check_multicollinearity
from linreg_ally.models import run_linear_regression
from linreg_ally.plotting import qq_and_residuals_plot
  • For individual function usage, visit our read the docs page to see individual function usage.

To run the tests, run the following commands from the root directory of this repo:

pytest tests/

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

linreg_ally was created by Paramveer Singh, Merari Santana-Carbajal, Cheng Zhang, and Alex Wong. It is licensed under the terms of the MIT license.

Credits

linreg_ally was created with cookiecutter and the py-pkgs-cookiecutter template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linreg_ally-0.0.2.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linreg_ally-0.0.2-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file linreg_ally-0.0.2.tar.gz.

File metadata

  • Download URL: linreg_ally-0.0.2.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for linreg_ally-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ee83995404e58e940b57ec4f559f4d892e502b7d946d6999d45c7845a6ac26c3
MD5 10a93fc66734e6adbb02d986f1eea81e
BLAKE2b-256 de884de5ce98292695e6201f1b8d4efc0947f22f479c1523e0b1af064130ddad

See more details on using hashes here.

File details

Details for the file linreg_ally-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: linreg_ally-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for linreg_ally-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b12b196e234d65a2ac3b22314070a863588fd5c46cd62c278742f1e4abc1dda
MD5 b7aba4625e37fef5997e240f47a38ecd
BLAKE2b-256 b42fa0113841a648be3e1d80a3adb1b965029903b7c0cfc70bab1fde86412f5a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page