Skip to main content

A package that streamline the repetitive task of regression models selection and comparison in the machine learning workflow.

Project description

autopredictor

CI/CD codecov Documentation Status License: GNU Python 3.9.0 release version

Summary | Functions | Installation | Usage | Dependencies

About

Autopredictor simplifies machine learning model selection for regression tasks. This Python package provides an intuitive approach, minimizing coding for model exploration. Assuming preprocessed data, it swiftly evaluates models with default settings, allowing quick comparison of their effectiveness.

Summary

This Autopredictor Python package streamlines the process of selecting and assessing machine learning models, offering a simplified approach to assess various regression models without the need of intricate manual setup. Designed for datasets with continuous response variable, this tool expedites the exploration of multiple models, minimizing the coding effort required for model selection and fitting. Leveraging preprocessed and trained data, this package evaluates models using default settings, allowing users to swiftly comprehend model performance. By computing and showcasing diverse performance metrics for each model, it offers an efficient means to compare their effectiveness. The key metrics used for evaluating model performance include Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), R2 Square, Mean Squared Error (MSE), and Root Mean Squared Error (RMSE). The Autopredictor package encompasses eight regression models, enhancing flexibility and choices in model selection:

  • Linear Regression
  • Lasso Regression
  • Ridge Regression
  • Linear Support Vector Machine
  • Support Vector Machine
  • Decision Tree
  • Random Forest
  • Gradient Boosting
  • AdaBoost

For a detailed explanation of each model, refer to the Audopredictor Tutorial. Overall, Autopredictor delivers a convenient and efficient framework for preliminary model evaluation and the comparison of regression models in machine learning workflows.

Functions

This package includes four main functions:

  • fit: Fits a clean, preprocessed training data into eight different regression models. This function returns a dictionary containing five metric scores for each model
  • show_all: Generates a DataFrame presenting each scoring metric alongside the respective model, while outputting a clear overview of the results in a table format
  • display_best_score: Identifies the best score with respect to a specific scoring metric along with the corresponding model
  • select_model: Returns a summary of all the scoring metrics associated with a specific machine learning model

A comprehensize walkthrough of each function can be found in the Audopredictor Tutorial.

This package focuses on eight widely used regressor models, providing a curated selection that covers a broad range of algorithmic approaches. This package are designed to be user-friendly through automation with default configurations for each model. It is catered for both beginners by eliminating complicated model arguments and for experts by providing baseline results. However, this package may not be suitable for experienced practitioner who requires customized regressor models. Within the Python ecosystem, there is an existing, well developed and maintained library named lazypredict that offer similar functionality with a wider range of models, including classification models.

Installation

In order to use this package, please run the instructions provided below.

For Users: Using PyPI

This package is published on PyPi. Run the following command to install autopredictor in the desired environment:

pip install autopredictor

For Developers: Using Poetry

All dependencies installation used in this package will be handled by Poetry through the following commands:

  1. Clone this GitHub repository using this command:
git clone https://github.com/UBC-MDS/autopredictor.git
  1. Install poetry in your base environment by following these instructions.

  2. Run the following commands from the root directory of this project to create a virtual environment for this package and install autopredictor through poetry:

conda create --name autopredictor python=3.9 -y
conda activate autopredictor
poetry install

Usage

To use autopredictor, follow these simple steps:

  1. Import the package:

    import autopredictor
    
  2. Load your preprocessed training data.

  3. Once you have your data split into training and testing, you can start by fitting the data to obtain scores for eight different regression models:

    results_test, results_train = autopredictor.fit(X_train,
                      X_test,
                      y_train,
                      y_test,
                      return_train=True)
    

    The fit function returns a dictionary containing four metric scores for each model.

  4. Display an overview of the results in a table format:

    scores_test = autopredictor.show_all(results_test)
    scores_train = autopredictor.show_all(results_train)
    

    By calling autopredictor.show_all(results), the function will print a tabulated version of the resulting DataFrame for easier visualization.

  5. Identify the best score with respect to a specific metric:

    autopredictor.display_best_score(metric='r2')
    
  6. Get a summary of all scoring metrics associated with a specific model:

    autopredictor.select_model(model='Linear Regression')
    

Example

import autopredictor

# return_train will always default to False assuming the user does not want to see the train scores
scores, _ = autopredictor.fit(X_train, 
                           X_test, 
                           y_train, 
                           y_test)

# Display an overview of the results
test_df = autopredictor.show_all(scores)

# Identify the best score with respect to the R-squared metric
autopredictor.display_best_score(metric='r2')

# Get a summary of scoring metrics for the Linear Regression model
autopredictor.select_model(model='Linear Regression')

Developer notes:

Running The Tests

Run the following command in the terminal from the project's root directory to execute the tests written for each function in this package:

pytest tests/

To assess the branch coverage for this package:

pytest --cov=autopredictor --cov-branch

Dependencies

This package relies on the following dependencies as outlined in pyproject.toml:

  • python = "^3.9"
  • pandas = "^2.1.4"
  • tabulate = "^0.9.0"
  • scikit-learn = "^1.3.2"
  • pytest = "^7.4.4"
  • pytest-cov = "^4.1.0"
  • jupyter = "^1.0.0"
  • myst-nb = "^1.0.0"
  • sphinx-autoapi = "^3.0.0"
  • sphinx-rtd-theme = "^2.0.0"

Documentations

Online documentation is available here.

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. Please find the list of contributors here.

License

autopredictor was created by Anu Banga, Arturo Rey, Sharon Voon, Zeily Garcia. It is licensed under the terms of the GNU GENERAL PUBLIC LICENSE.

Important Links

This package uses the following models from scikit-learn:

References

Pandala, S. R. (2022). LazyPredict. Retrived from https://pypi.org/project/lazypredict/

Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., … Duchesnay, É. (1970). Scikit-Learn: Machine learning in Python. Retrieved from https://jmlr.csail.mit.edu/papers/v12/pedregosa11a.html

Credits

autopredictor 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

autopredictor-0.2.1.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

autopredictor-0.2.1-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file autopredictor-0.2.1.tar.gz.

File metadata

  • Download URL: autopredictor-0.2.1.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for autopredictor-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fef52902c31362eae21046e160ca32ae9a63017e5a4cf6955336d09a082109e9
MD5 9856adc5b070e54ad16a8b05e9967e00
BLAKE2b-256 3876e7a85102e5412b2876cc31b26c7e8f62757b7ad663035c2c64f9728af14e

See more details on using hashes here.

File details

Details for the file autopredictor-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for autopredictor-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0608e6bb93774ed5b6df1ded2bea799b24c327c0a0aae2aa0e30a6307acbfce5
MD5 b67c70b75f17e9b977bb5c7e7111f415
BLAKE2b-256 6a94f57c035b42265f31ee9ccf547e970837e05f37d217a1d648ae2b2b4c56d8

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