Package: auto-flow
AutoFlow:Automatic machine learning workflow modeling platformIntroductionIn 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 theHyperflow,
which can automatically select algorithm and optimize the parameters of
machine learning workflow.
In other words, it can implement AutoML for tabular data.DocumentationThe documentation can be foundhere.InstallationRequirementsThis project is built and test on Linux system, so Linux platform is required.
If you are using Windows system,WSLis worthy of considerarion.Besides the listed requirements (see requirements.txt), therandom forestused inSMAC3requiresSWIG(>= 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 swigOn Arch Linux (or any distribution with swig4 as default implementation):pacman -Syu swig3
ln -s /usr/bin/swig-3 /usr/bin/swigAutoFlow requiresPython3.6 or higher.Installation via pippip install auto-flowManual Installationgit clone https://github.com/auto-flow/autoflow.git && cd autoflow
python setup.py installQuick StartTitanicis perhaps the most familiar machine learning task for data scientists.
For tutorial purposes, you can find titanic dataset inexamples/data/train_classification.csvandexamples/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 !$cdexamples/classificationimportosimportjoblibimportpandasaspdfromsklearn.model_selectionimportKFoldfromautoflowimportAutoFlowClassifier# load data from csv filetrain_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 informationcolumn_descriptions={"id":"PassengerId","target":"Survived","ignore":"Name"}ifnotos.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 Validationtrained_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 usejoblib.dump(trained_pipeline,"autoflow_classification.bz2")# if you want to see what the workflow AutoFlow is searching, you can use `draw_workflow_space` to visualizehdl_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 systempredict_pipeline=joblib.load("autoflow_classification.bz2")# secondly, use loaded model to do predictingresult=predict_pipeline.predict(test_df)print(result)