MLCompare

Quickly compare machine learning models across libraries and datasets

MIT License

Downloads
274
Stars
0
Committers
1

MLCompare is a Python package for running model comparison pipelines, with the aim of being both simple and flexible. It supports multiple popular ML libraries, retrieval from multiple online dataset repositories, common data processing steps, and results visualization. Additionally, it allows for using your own models and datasets within the pipelines.

It is recommended to create a new virtual environment. Example with Conda:

conda create -n compare_env python==3.11.9
conda activate compare_env

Install this library with pip:

pip install mlcompare

Note that for MacOS, both XGBoost and LightGBM require libomp. It can be installed with Homebrew:

brew install libomp

Running a pipeline with multiple datasets and models is done by creating a list of dictionaries for each and providing them to a pipeline function.

The below example downloads a dataset from OpenML and Kaggle, one-hot encodes some of the columns in the Kaggle dataset, and trains and evaluates a Random Forest and XGBoost model on them.

import mlcompare

datasets = [
    {
        "type": "openml",
        "id": 8,
        "target": "drinks",
    },
    {
        "type": "kaggle",
        "user": "gorororororo23",
        "dataset": "plant-growth-data-classification",
        "file": "plant_growth_data.csv",
        "target": "Growth_Milestone",
        "oneHotEncode": ["Soil_Type", "Water_Frequency", "Fertilizer_Type"],
    }
]

models = [
    {
        "library": "sklearn",
        "name": "RandomForestRegressor",
    },
    {
        "library": "xgboost",
        "name": "XGBRegressor",
        "params": {"num_leaves": 40, "n_estimators": 200}
    }
]

mlcompare.full_pipeline(datasets, models, "regression")

In the case of the XGBoost model some non-default parameter values were used.

Package Rankings
Top 34.99% on Pypi.org
Related Projects