Summary | Functions | Installation | Usage | Dependencies
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.
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.
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 modelshow_all: Generates a DataFrame presenting each scoring metric alongside the respective model, while outputting a clear overview of the results in a table formatdisplay_best_score: Identifies the best score with respect to a specific scoring metric along with the corresponding modelselect_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.
In order to use this package, please run the instructions provided below.
This package is published on PyPi. Run the following command to install autopredictor in the desired environment:
pip install autopredictorAll dependencies installation used in this package will be handled by Poetry through the following commands:
- Clone this GitHub repository using this command:
git clone https://github.com/UBC-MDS/autopredictor.git-
Install poetry in your base environment by following these instructions.
-
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 installTo use autopredictor, follow these simple steps:
-
Import the package:
import autopredictor
-
Load your preprocessed training data.
-
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
fitfunction returns a dictionary containing four metric scores for each model. -
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. -
Identify the best score with respect to a specific metric:
autopredictor.display_best_score(metric='r2')
-
Get a summary of all scoring metrics associated with a specific model:
autopredictor.select_model(model='Linear Regression')
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')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-branchThis 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"
Online documentation is available here.
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.
autopredictor was created by Anu Banga, Arturo Rey, Sharon Voon, Zeily Garcia. It is licensed under the terms of the GNU GENERAL PUBLIC LICENSE.
- Official source code repo: https://github.com/UBC-MDS/autopredictor.git
- Official read the doc: https://autopredictor.readthedocs.io/en/latest/?badge=latest
This package uses the following models from scikit-learn:
- Linear Regression: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html
- Linear Regression (L1) (Lasso): https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Lasso.html
- Linear Regression (L2) (Ridge):https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html
- Support Vector Machine: https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html
- Decision Tree: https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeRegressor.html
- Random Forest: https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html
- Gradient Boosting: https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html
- AdaBoost: https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.AdaBoostRegressor.html
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
autopredictor was created with cookiecutter and the py-pkgs-cookiecutter template.
