authors: Yu-An Chung, Shao-Chuan Lee, Yao-Yuan Yang, Tung-En Wu, Hsuan-Tien Lin
libact
is a python package designed to make active learning easier for real-world users. The package not only implements several popular active learning strategies, but also features the active learning by learning meta-strategy that allows the machine to automatically learn the best strategy on the fly. The package is designed for easy extension in terms of strategies, models and labelers. In particular, libact
models can be easily obtained by interfacing with the models in scikit-learn
.
Comments on the package is welcomed at (temporarily) [email protected]
. If you find this package useful, please cite the original works (see Reference of each strategy) as well as (temporarily)
@Misc{libact,
author = {Yu-An Chung and Shao-Chuan Lee and Yao-Yuan Yang and Tung-En Wu and Hsuan-Tien Lin},
title = {Pool-based Active Learning in Python},
howpublished = {\url{https://github.com/ntucllab/libact}},
year = {2015}
}
Python3 dependencies
pip3 install -r requirements.txt
Debian (>= 7) / Ubuntu (>= 14.04)
sudo apt-get install build-essential gfortran libatlas-base-dev liblapacke-dev python3-dev
MacOS
brew tap homebrew/science
brew install openblas
One of the query strategies (hintsvm
) depends on the HintSVM package that requires special installation. If you are not using the strategy, please simply follow the section on general installation. Otherwise please follow the section on HintSVM.
After resolving the dependencies, it should be fairly simple to install the package in your home directory:
python setup.py install --user
To install for all users on Unix/Linux:
python setup.py build
sudo python setup.py install
Or via pip: (for all users):
sudo pip install libact
Pip install in home directory:
pip install --user libact
For HintSVM, you would have to install the hintsvm package first.
Before running, you need to make sure the path to the library and
python code of hintsvm
are set in the environment variables:
export LD_LIBRARY_PATH=/path/to/hintsvm:$LD_LIBRARY_PATH
export PYTHONPATH=/path/to/hintsvm/python:$PYTHONPATH
The main usage of libact
is as follows:
qs = UncertaintySampling(trn_ds, method='lc') # query strategy instance
ask_id = qs.make_query() # let the specified query strategy suggest a data to query
X, y = zip(*trn_ds.data)
lb = lbr.label(X[ask_id]) # query the label of unlabeled data from labeler instance
trn_ds.update(ask_id, lb) # update the dataset with newly queried data
Some examples are available under the examples
directory. Before running, use
examples/get_dataset.py
to retrieve the dataset used by the examples.
Available examples:
examples/plot.py
: This example performs basic usage of libact. It splits a fully-labeled dataset and remove some label from dataset to simulate the pool-based active learning scenario. Each query of an unlabeled dataset is then equivalent to revealing one labeled example in the original data set.examples/label_digits.py
: This example shows how to use libact in the case that you want a human to label the selected sample for your algorithm.
The authors thank Chih-Wei Chang and other members of the Computational Learning Lab at National Taiwan University for valuable discussions and various contributions to making this package better.