Active Learning Playground
This is a python module for experimenting with different active learning algorithms. There are a few key components to running active learning experiments:
Main experiment script is
run_experiment.pywith many flags for different run options.
Supported datasets can be downloaded to a specified directory by running
Supported active learning methods are in
Below I will go into each component in more detail.
DISCLAIMER: This is not an official Google product.
It is highly suggested that you install all dependencies into a separate
easy package management.
Getting benchmark datasets
By default the datasets are saved to
/tmp/data. You can specify another directory via the
Redownloading all the datasets will be very time consuming so please be patient.
You can specify a subset of the data to download by passing in a comma separated
string of datasets via the
There are a few key flags for
dataset: name of the dataset, must match the save name used in
create_data.py. Must also exist in the data_dir.
sampling_method: active learning method to use. Must be specified in
warmstart_size: initial batch of uniformly sampled examples to use as seed data. Float indicates percentage of total training data and integer indicates raw size.
batch_size: number of datapoints to request in each batch. Float indicates percentage of total training data and integer indicates raw size.
score_method: model to use to evaluate the performance of the sampling method. Must be in
data_dir: directory with saved datasets.
save_dir: directory to save results.
This is just a subset of all the flags. There are also options for preprocessing, introducing labeling noise, dataset subsampling, and using a different model to select than to score/evaluate.
Available active learning methods
All named active learning methods are in
You can also specify a mixture of active learning methods by following the
[sampling_method]-[mixture_weight] separated by dashes; i.e.
Some supported sampling methods include:
Uniform: samples are selected via uniform sampling.
Margin: uncertainty based sampling method.
Informative and diverse: margin and cluster based sampling method.
k-center greedy: representative strategy that greedily forms a batch of points to minimize maximum distance from a labeled point.
Graph density: representative strategy that selects points in dense regions of pool.
Exp3 bandit: meta-active learning method that tries to learns optimal sampling method using a popular multi-armed bandit algorithm.
Adding new active learning methods
The only method that must be implemented by any sampler is
which can have arbitrary named arguments. The only restriction is that the name
for the same input must be consistent across all the samplers (i.e. the indices
for already selected examples all have the same name across samplers). Adding a
new named argument that hasn't been used in other sampling methods will require
feeding that into the
select_batch call in
All available models are in the
get_model method of
Linear SVM: scikit method with grid search wrapper for regularization parameter.
Kernel SVM: scikit method with grid search wrapper for regularization parameter.
Logistc Regression: scikit method with grid search wrapper for regularization parameter.
Small CNN: 4 layer CNN optimized using rmsprop implemented in Keras with tensorflow backend.
Kernel Least Squares Classification: block gradient descient solver that can use multiple cores so is often faster than scikit Kernel SVM.
Adding new models
New models must follow the scikit learn api and implement the following methods
fit(X, y[, sample_weight]): fit the model to the input features and target.
predict(X): predict the value of the input features.
score(X, y): returns target metric given test features and test targets.
decision_function(X)(optional): return class probabilities, distance to decision boundaries, or other metric that can be used by margin sampler as a measure of uncertainty.
for an example.
After implementing your new model, be sure to add it to
get_model method of
Currently models must be added on a one-off basis and not all scikit-learn classifiers are supported due to the need for user input on whether and how to tune the hyperparameters of the model. However, it is very easy to add a scikit-learn model with hyperparameter search wrapped around as a supported model.
Collecting results and charting
script handles processing of data and charting for a specified dataset and