AutoFlow: Automatic machine learning workflow modeling platform.
Project description
AutoFlow : Automatic machine learning workflow modeling platform
Introduction
In the problem of data mining and machine learning of tabular data, data scientists usually group the features, construct a directed acyclic graph (DAG), and form a machine learning workflow.
In each directed edge of this directed acyclic graph, the tail node represents the feature group before preprocessing, and the head node represents the feature group after preprocessing. Edge representation data processing or feature engineering algorithms, in each edge algorithm selection and hyper-parameter optimization are doing.
Unfortunately, if data scientists want to manually select algorithms and hyper-parameters for such a workflow, it will be a very tedious task. In order to solve this problem, we developed the Hyperflow, which can automatically select algorithm and optimize the parameters of machine learning workflow. In other words, it can implement AutoML for tabular data.
Documentation
The documentation can be found here.
Installation
Requirements
This project is built and test on Linux system, so Linux platform is required. If you are using Windows system, WSL is worthy of considerarion.
Besides the listed requirements (see requirements.txt), the random forest used in SMAC3 requires SWIG (>= 3.0, <4.0) as a build dependency. If you are using Ubuntu or another Debain Linux, you can enter following command :
apt-get install swig
On Arch Linux (or any distribution with swig4 as default implementation):
pacman -Syu swig3 ln -s /usr/bin/swig-3 /usr/bin/swig
AutoFlow requires Python 3.6 or higher.
Installation via pip
pip install auto-flow
Manual Installation
git clone https://github.com/auto-flow/autoflow.git && cd autoflow python setup.py install
Quick Start
Titanic is perhaps the most familiar machine learning task for data scientists. For tutorial purposes, you can find titanic dataset in examples/data/train_classification.csv and examples/data/test_classification.csv . You can use AutoFlow to finish this ML task instead of manually exploring all the features of the dataset. DO IT !
$ cd examples/classification
import os
import joblib
import pandas as pd
from sklearn.model_selection import KFold
from autoflow import AutoFlowClassifier
# load data from csv file
train_df = pd.read_csv("../data/train_classification.csv")
test_df = pd.read_csv("../data/test_classification.csv")
# initial_runs -- initial runs are totally random search, to provide experience for SMAC algorithm.
# run_limit -- is the maximum number of runs.
# n_jobs -- defines how many search processes are started.
# included_classifiers -- restrict the search space . lightgbm is the only classifier that needs to be selected
# per_run_time_limit -- restrict the run time. if a trial during 60 seconds, it is expired, should be killed.
trained_pipeline = AutoFlowClassifier(initial_runs=5, run_limit=10, n_jobs=1, included_classifiers=["lightgbm"],
per_run_time_limit=60)
# describing meaning of columns. `id`, `target` and `ignore` all has specific meaning
# `id` is a column name means unique descriptor of each rows,
# `target` column in the dataset is what your model will learn to predict
# `ignore` is some columns which contains irrelevant information
column_descriptions = {
"id": "PassengerId",
"target": "Survived",
"ignore": "Name"
}
if not os.path.exists("autoflow_classification.bz2"):
# pass `train_df`, `test_df` and `column_descriptions` to classifier,
# if param `fit_ensemble_params` set as "auto", Stack Ensemble will be used
# ``splitter`` is train-valid-dataset splitter, in here it is set as 3-Fold Cross Validation
trained_pipeline.fit(
X_train=train_df, X_test=test_df, column_descriptions=column_descriptions,
fit_ensemble_params=False,
splitter=KFold(n_splits=3, shuffle=True, random_state=42),
)
# finally , the best model will be serialize and store in local file system for subsequent use
joblib.dump(trained_pipeline, "autoflow_classification.bz2")
# if you want to see what the workflow AutoFlow is searching, you can use `draw_workflow_space` to visualize
hdl_constructor = trained_pipeline.hdl_constructors[0]
hdl_constructor.draw_workflow_space()
# suppose you are processing predict procedure, firstly, you should load serialized model from file system
predict_pipeline = joblib.load("autoflow_classification.bz2")
# secondly, use loaded model to do predicting
result = predict_pipeline.predict(test_df)
print(result)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file auto-flow-0.1.1.tar.gz
.
File metadata
- Download URL: auto-flow-0.1.1.tar.gz
- Upload date:
- Size: 193.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0.post20200127 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dd795cdc984b282a412c92862ef2c91a96d2670b8d1db6e51207bb64cf6f18a |
|
MD5 | 92296da1bbd06e4de489c06833c24a79 |
|
BLAKE2b-256 | fdc10eaa7dc382458e6a29d7883394d28aae5fd2615d59747b6d4278438950ba |