Skip to main content

Exhaustive-Search for best R^2 in Linear Regression Models

Project description

Kiku

cavemanstatistics 1.0

This package contains unnecessarily slow, brute-force search methods for finding highest R^2 (of linear regression models with specified or unspecified dependant variable) in a dataset. This project is mainly intended to get to know packaging with pypi.org and to develope my workflow. In the future I'd like to vectorize the loops and maybe add more search options and better search methods. Be careful about combinatorial explosion and set the bounds appropriately.

Dependancies

  • NumPy
  • Pandas
  • SciPy
  • scikit-learn
  • Tabulate

Installing

Install with:

pip install cavemanstatistics

Quick documentation

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

After installation, import:

from cavemanstatistics import ExhaustiveSearch, BruteForce

Search for highest R^2 (unspecified dependant variable):

model, results = ExhaustiveSearch(data = pd.dataframe, remove = list, lowerbound = int, upperbound = int, adjusted_R2 = bool).solve()
y, x = model
print(model)

('depedant variable', [list of explanatory variables])

ExhaustiveSearch().solve() returns a touple containing a string (dependant variable) and a list (explanatory variables) and a sorted dictionary with all results.

Parameters:

  • data: has to be a pandas dataframe
  • remove: place list of variable names that you would like to exclude as depedant variables (or place an empty list)
  • lowerbound: smallest integer number of explanatory variables in solution set
  • upperbound: largest integer number of exoplanatory variables in solution set
  • adjusted_R2: True for adjusted R^2, false for R^2

Search for highest R^2 (specified dependant variable):

model, results = BruteForce(data = pd.dataframe, Y = str, lowerbound = int, upperbound = int, adjusted_R2 = bool).solve()
y, x = model
print(model)

('depedant variable', [list of explanatory variables])

BruteForce().solve() returns a touple containing a string (dependant) and a list (explanatory variables) and a sorted dictionary with all results.

Parameters:

  • data: has to be a pandas dataframe
  • Y: the name of the variable that you would like to specify as dependant variable
  • lowerbound: smallest integer number of explanatory variables in solution set
  • upperbound: largest integer number of exoplanatory variables in solution set
  • adjusted_R2: True for adjusted R^2, false for R^2

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • This is a spawn of the frustration caused by the R-Package 'leaps'
  • Tip fedora to the ascii art creators

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

cavemanstatistics-0.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

cavemanstatistics-0.4-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file cavemanstatistics-0.4.tar.gz.

File metadata

  • Download URL: cavemanstatistics-0.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4

File hashes

Hashes for cavemanstatistics-0.4.tar.gz
Algorithm Hash digest
SHA256 a17aacb5651ad9d725540a6396922537d9a8a4ec5c05e36ddfcda652de70cff0
MD5 09d370414bb2faeec1656f6a7bcd588f
BLAKE2b-256 bf0e4930322d0ba6fd346b4f86ace57635952440665da36bee08e25aab8b80bb

See more details on using hashes here.

File details

Details for the file cavemanstatistics-0.4-py3-none-any.whl.

File metadata

  • Download URL: cavemanstatistics-0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4

File hashes

Hashes for cavemanstatistics-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2854378ce4992c7f81dfb119daeb8cd32c882ca5f3e5d7d95017dbefeaf1b24b
MD5 4e23d4ce23f66cd9dfaf430e652a634f
BLAKE2b-256 64ad7327cd0898945cca8ad0a555af8cf2982e865466da72da9431986bd82fc4

See more details on using hashes here.

Supported by

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