Skip to main content

Python Regression Analysis.

Project description

PRegress

PRegress is a Python package for regression analysis and data visualization. It provides tools for model fitting, prediction, and various types of plots to help visualize your data particularly for regression analysis.

Features

  • Model fitting and prediction with convenient formula notation
  • Streamlined code for plotting (boxplot, histogram, scatter plot, etc.)
  • Regression analysis diagnostic tools
  • Integration with popular libraries like pandas and statsmodels

Installation

You can install the package using pip:

pip install pregress

Usage

Here are some examples of how to use the key functions in the package.

Importing the Package

To use the functions provided by the package, import it as follows:

import pregress as pr

Getting Data

There are multiple datasets available from PRegress and are easily attained using the get_data function. The datasets currently available are:

  • AirBnb.csv
  • Betas.csv
  • Charges.csv
  • Employment.csv
  • HousePrices.csv
  • HR_retention.csv
  • MarketingToys.csv
  • Sales.csv
  • Top200.csv
  • Twitter.csv
  • Youtube.csv

See Applied Linear Regression for Business Analytics with Python for details regarding these datasets. Sample import example:

import pregress as pr

# Load data from PRegress
df = pr.get_data("Betas.csv")

# Format the data (for later)
df.drop(columns = df.columns[0], inplace=True)

Model Fitting and Prediction

PRegress formula supports formula functionality similar to R. Fit a model with a formula:

# Fit model with formula 
model = pr.fit("SPY ~ .", df)

Summary types are specified using the out argument. Different summaries are available including:

  • statsmodels (default)
  • R
  • STATA
  • simple
  • ANOVA
  • coefficients (coef)
# Generate a model summary
pr.summary(model)

Making Predictions

A Statsmodels object is created by default. From this object, the predict function can be used. Since df is the dataframe used to fit the model, the following lines produce the same result.

# Make predictions
pr.predict(model, df)

# Produce fitted values
pr.predict(model)

General Plotting

Plotting code is streamlined and built on top of Seaborn and MatPlotLib. Samples provided below.

# Generate a boxplot
pr.boxplot("SPY ~ .", df)

# Generate a histogram
pr.hist(df.SPY)

# Multiple histograms
pr.hists("SPY ~ .",data = df)

# Scatter plot
pr.plotXY("MSFT ~ SPY", data = df)

# Multiple Scatter plots
pr.plots("SPY ~ .", data = df)

# Correlation Plot
pr.plot_cor(df)

Required Fixes

Based on current testing, the following fixes are required:

  1. Ensure global scope accessibility for variables.
  2. Adjust summary spacing.
  3. Provide compatibility with scikit-learn.
  4. Implement AI-generated summaries.
  5. Allow for additional plotting customization (using kwargs).
  6. Review and improve diagnostic plots.
  7. Provide support for logistic regression and other GLMs.
  8. Provide support for automatic dummy variable retrieval.
  9. Plots should work without formulas.

Contributing

We welcome contributions to PRegress! If you find a bug or have a feature request, please open an issue on GitHub. You can also contribute by:

  1. Forking the repository
  2. Creating a new branch (git checkout -b feature-branch)
  3. Committing your changes (git commit -am 'Add some feature')
  4. Pushing to the branch (git push origin feature-branch)
  5. Creating a pull request

License

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

Acknowledgements

We would like to thank all contributors and users of PRegress for their support and feedback. Special thanks to Mintra Putlek!

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

pregress-1.0.4.tar.gz (195.1 kB view details)

Uploaded Source

Built Distribution

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

pregress-1.0.4-py3-none-any.whl (212.6 kB view details)

Uploaded Python 3

File details

Details for the file pregress-1.0.4.tar.gz.

File metadata

  • Download URL: pregress-1.0.4.tar.gz
  • Upload date:
  • Size: 195.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.9

File hashes

Hashes for pregress-1.0.4.tar.gz
Algorithm Hash digest
SHA256 46d8b2585badaa54890cc5eca1c8599ce239cd5eb331292ce1591c9395e67009
MD5 99415b76d4385d586980e1689cae3ceb
BLAKE2b-256 ee3726fd089932de5071399692d452eedcdb4b5e3d5488a8057beda7a67f9eff

See more details on using hashes here.

File details

Details for the file pregress-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: pregress-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 212.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.9

File hashes

Hashes for pregress-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f5da81a3ae15755dc3de1e6135af571516bad613b6a697c33e41479181d8029a
MD5 2fb45cef90741e7ef958ec6478430e57
BLAKE2b-256 1332719cee1c73b3a481793759df613d5eba3950dbf429852b9649e8318f6143

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