Skip to main content

Help you train and optimize many popular classifiers in one place with a summary table

Project description

classifierpromax

drawing

Documentation StatusPython 3.12 ci-cd codecov

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

  1. 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)
  1. Feature selection
from classifierpromax.FeatureSelector import FeatureSelector

fs_models = FeatureSelector(preprocessor, baseline_models, X, y, n_features_to_select=3)
  1. Hyperparameter optimization
from classifierpromax.ClassifierOptimizer import ClassifierOptimizer

opt_models, opt_score = ClassifierOptimizer(fs_models, X, y, scoring="f1")
  1. Results summary
from classifierpromax.ResultHandler import ResultHandler

summary = ResultHandler(baseline_score, opt_score)
print(summary)

Testing

Create a new environment with Python 3.12.

conda create -n classifierpromax python=3.12
conda activate classifierpromax

Clone the repo.

git clone git@github.com:UBC-MDS/ClassifierProMax.git

Install poetry following these instructions and then run the following bash command.

$ 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

classifierpromax-1.2.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

classifierpromax-1.2.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file classifierpromax-1.2.2.tar.gz.

File metadata

  • Download URL: classifierpromax-1.2.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for classifierpromax-1.2.2.tar.gz
Algorithm Hash digest
SHA256 130e55ab65776f5e550d84f26bedba711b2246496a117e5a13a67edb9c816467
MD5 14e164988628f171a30e746ae689bb96
BLAKE2b-256 cb1f6da3a9af1a4c688ad77f37d09de3bb4dea5f821a095de599849ca2e2547f

See more details on using hashes here.

File details

Details for the file classifierpromax-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for classifierpromax-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4c703b0dd1d28ee8d2e7a8246f89095cf274499592300d6669481085a20272d4
MD5 369ec34302a2e08197116d60917a5400
BLAKE2b-256 11eefb03fd54d538d511eb34c6e636d6fb7492a8d0f1197f4653ebfea069ad9d

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