Help you train and optimize many popular classifiers in one place with a summary table
Project description
classifierpromax
classifierpromax is a scikit-learn wrapper library that helps to train and optimize multiple classifier models in parallel.
ClassifierTrainer():
Train multiple machine learning classifiers using cross-validation and return trained models and evaluation metrics.
FeatureSelector():
Selects features for multiple classification models using RFE or Pearson methods.
ClassifierOptimizer():
Optimizes a dictionary of scikit-learn Pipeline classifiers using RandomizedSearchCV and evaluates their performance.
ResultsHandler():
Processes and combines scoring results from model training and optimization.
In a machine learning pipeline, code can often be repeated when working with multiple models, violating the DRY (Don’t-Repeat-Yourself) principle. This Python library is to promote DRY principles in machine learning code and create cleaner code.
Installation
Before installation, please make sure Python 3.12 or newer is installed.
$ pip install classifierpromax
Usage
- Training baseline models
import pandas as pd
import numpy as np
from classifierpromax.ClassifierTrainer import ClassifierTrainer
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
# Dummy data
X = pd.DataFrame(np.random.rand(100, 5), columns=[f"feature_{i}" for i in range(5)])
y = pd.Series(np.random.randint(0, 2, size=100))
preprocessor = StandardScaler()
baseline_models, baseline_score = ClassifierTrainer(preprocessor, X, y, seed=123)
- Feature selection
from classifierpromax.FeatureSelector import FeatureSelector
fs_models = FeatureSelector(preprocessor, baseline_models, X, y, n_features_to_select=3)
- Hyperparameter optimization
from classifierpromax.ClassifierOptimizer import ClassifierOptimizer
opt_models, opt_score = ClassifierOptimizer(fs_models, X, y, scoring="f1")
- Results summary
from classifierpromax.ResultHandler import ResultHandler
summary = ResultHandler(baseline_score, opt_score)
print(summary)
For a more in-depth tutorial on using the library, please refer to the example.ipynb Jupyter Notebook in the docs folder.
Testing
Create a new environment with Python 3.12.
conda create -n classifierpromax python=3.12
conda activate classifierpromax
Clone the repo and cd in to the directory.
git clone git@github.com:UBC-MDS/ClassifierProMax.git
cd ClassifierProMax
Install poetry following these instructions and then run the following bash command to install the depencies needed to run the library.
$ poetry install
Execute pytest from the root project directory.
$ pytest
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.
Contributors
Long Nguyen, Jenson Chang, Gunisha Kaur, Han Wang
License
classifierpromax was created by Long Nguyen, Jenson Chang, Gunisha Kaur, Han Wang. It is licensed under the terms of the MIT license.
Credits
classifierpromax 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file classifierpromax-1.2.3.tar.gz.
File metadata
- Download URL: classifierpromax-1.2.3.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fb466af9ac5006b9d6009a2ca0a312f0a317dcfc1f0e6a70496657fd7b410fd
|
|
| MD5 |
b88c860384cb88df2a3b805f4465d30b
|
|
| BLAKE2b-256 |
3eb982d7f7e27350b18a35757d5bcabd9e615f23cd865357fbfccf622a497b98
|
File details
Details for the file classifierpromax-1.2.3-py3-none-any.whl.
File metadata
- Download URL: classifierpromax-1.2.3-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32056012c7cb7bc0e1d6db3f0048d9da971f1b86dce5d918caf1f059716942fc
|
|
| MD5 |
f8628b2307c9ff5d08e3f92c0354be17
|
|
| BLAKE2b-256 |
5c5946cf8f3f7b6496db52e96408ab0b6019f13f1a0694e10f5525990932a4c9
|