Skip to main content

Generative AutoML for Tabular Data

Project description

SapientML

Generative AutoML for Tabular Data

SapientML is an AutoML technology that can learn from a corpus of existing datasets and their human-written pipelines, and efficiently generate a high-quality pipeline for a predictive task on a new dataset.

PyPI - Version PyPI - Python Version Release Conventional Commits OpenSSF Best Practices

Available on 🤗 HuggingFace Spaces

Open in Spaces

Installation

Requires Python 3.10–3.13.

From PyPI repository

pip install sapientml

From source code:

git clone https://github.com/sapientml/sapientml.git
cd sapientml
pip install poetry
poetry install

Getting Started

Please see our Documentation for further details.

Run AutoML

import pandas as pd
from sapientml import SapientML
from sklearn.metrics import f1_score
from sklearn.model_selection import train_test_split

train_data = pd.read_csv("https://github.com/sapientml/sapientml/files/12481088/titanic.csv")
train_data, test_data = train_test_split(train_data)
y_true = test_data["survived"].reset_index(drop=True)
test_data.drop(["survived"], axis=1, inplace=True)

cls = SapientML(["survived"])

cls.fit(train_data)
y_pred = cls.predict(test_data)

y_pred = y_pred["survived"].rename("survived_pred")
print(f"F1 score: {f1_score(y_true, y_pred)}")

Obtain and Run Generated Code

You can access model field to get a model consisting of generated code after executing fit method. model provides fit, predict, and save method to train a model by generated code, predict from a test data by generated code, and save generated code to a designated folder.

model = sml.fit(train_data, codegen_only=True).model

model.fit(X_train, y_train) # build a model by using another data and the same generated code

y_pred = model.predict(X_test) # prediction by using generated code

model.save("/path/to/output") # save generated code to `path/to/output`

Examples

Dataset Task Target Code
Titanic Dataset classification survived Open In Colab
Hotel Cancellation classification Status Open In Colab
Housing Prices regression SalePrice Open In Colab
Medical Insurance Charges regression charges Open In Colab

Publications

The technologies of the software originates from the following research paper published at the International Conference on Software Engineering (ICSE), which is one of the premier conferences on Software Engineering.

Ripon K. Saha, Akira Ura, Sonal Mahajan, Chenguang Zhu, Linyi Li, Yang Hu, Hiroaki Yoshida, Sarfraz Khurshid, Mukul R. Prasad (2022, May). SapientML: Synthesizing Machine Learning Pipelines by Learning from Human-Written Solutions. In Proceedings of the 44th International Conference on Software Engineering (pp. 1932-1944).

@inproceedings{10.1145/3510003.3510226,
author = {Saha, Ripon K. and Ura, Akira and Mahajan, Sonal and Zhu, Chenguang and Li, Linyi and Hu, Yang and Yoshida, Hiroaki and Khurshid, Sarfraz and Prasad, Mukul R.},
title = {SapientML: Synthesizing Machine Learning Pipelines by Learning from Human-Written Solutions},
year = {2022},
isbn = {9781450392211},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3510003.3510226},
doi = {10.1145/3510003.3510226},
abstract = {Automatic machine learning, or AutoML, holds the promise of truly democratizing the use of machine learning (ML), by substantially automating the work of data scientists. However, the huge combinatorial search space of candidate pipelines means that current AutoML techniques, generate sub-optimal pipelines, or none at all, especially on large, complex datasets. In this work we propose an AutoML technique SapientML, that can learn from a corpus of existing datasets and their human-written pipelines, and efficiently generate a high-quality pipeline for a predictive task on a new dataset. To combat the search space explosion of AutoML, SapientML employs a novel divide-and-conquer strategy realized as a three-stage program synthesis approach, that reasons on successively smaller search spaces. The first stage uses meta-learning to predict a set of plausible ML components to constitute a pipeline. In the second stage, this is then refined into a small pool of viable concrete pipelines using a pipeline dataflow model derived from the corpus. Dynamically evaluating these few pipelines, in the third stage, provides the best solution. We instantiate SapientML as part of a fully automated tool-chain that creates a cleaned, labeled learning corpus by mining Kaggle, learns from it, and uses the learned models to then synthesize pipelines for new predictive tasks. We have created a training corpus of 1,094 pipelines spanning 170 datasets, and evaluated SapientML on a set of 41 benchmark datasets, including 10 new, large, real-world datasets from Kaggle, and against 3 state-of-the-art AutoML tools and 4 baselines. Our evaluation shows that SapientML produces the best or comparable accuracy on 27 of the benchmarks while the second best tool fails to even produce a pipeline on 9 of the instances. This difference is amplified on the 10 most challenging benchmarks, where SapientML wins on 9 instances with the other tools failing to produce pipelines on 4 or more benchmarks.},
booktitle = {Proceedings of the 44th International Conference on Software Engineering},
pages = {1932–1944},
numpages = {13},
keywords = {AutoML, program synthesis, program analysis, machine learning},
location = {Pittsburgh, Pennsylvania},
series = {ICSE '22}
}

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

sapientml-0.4.17.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

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

sapientml-0.4.17-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file sapientml-0.4.17.tar.gz.

File metadata

  • Download URL: sapientml-0.4.17.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.20 Linux/6.14.0-1017-azure

File hashes

Hashes for sapientml-0.4.17.tar.gz
Algorithm Hash digest
SHA256 5b4b30d19d93ab768577de4a2d1aedd4647ecde9eef99889e32ab0555a3f6101
MD5 44b953f2b4d72000b8025bb9d5ec5678
BLAKE2b-256 1891c5cb8961f4149c0db5e6bfc252d305f0a97eb8772fafbefd89febe36e1b2

See more details on using hashes here.

File details

Details for the file sapientml-0.4.17-py3-none-any.whl.

File metadata

  • Download URL: sapientml-0.4.17-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.20 Linux/6.14.0-1017-azure

File hashes

Hashes for sapientml-0.4.17-py3-none-any.whl
Algorithm Hash digest
SHA256 5e99d8b218487304696601ac88511748ce2f746661076b6d949d19e95b21375e
MD5 30c136cb8603f29d3952425cca6941b7
BLAKE2b-256 5e53be7cdf01d557392d83c18bb1c05b4db9d04c82dc4a0ad3653e3425d790e1

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