Skip to main content

Our package scikit-activeml is a Python library for active learning on top of SciPy and scikit-learn.

Project description

Doc Codecov PythonVersion PyPi Paper


https://raw.githubusercontent.com/scikit-activeml/scikit-activeml/master/docs/logos/scikit-activeml-logo.png

scikit-activeml is a Python module for active learning on top of SciPy and scikit-learn. It is distributed under the 3-Clause BSD licence.

The project was initiated in 2020 by the Intelligent Embedded Systems Group at University Kassel.

Installation

The easiest way of installing scikit-activeml is using pip

pip install -U scikit-activeml

Example

The following code implements an active learning cycle with 20 iterations using a logistic regression classifier and uncertainty sampling. To use other classifiers, you can simply wrap classifiers from scikit-learn or use classifiers provided by scikit-activeml. Note that the main difficulty using active learning with scikit-learn is the ability to handle unlabeled data, which we denote as a specific value (MISSING_LABEL) in the label vector y. More query strategies can be found in the documentation.

import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_classification
from skactiveml.pool import UncertaintySampling
from skactiveml.utils import unlabeled_indices, MISSING_LABEL
from skactiveml.classifier import SklearnClassifier

# Generate data set.
X, y_true = make_classification(random_state=0)
y = np.full(shape=y_true.shape, fill_value=MISSING_LABEL)

# Create classifier and query strategy.
clf = SklearnClassifier(LogisticRegression(), classes=np.unique(y_true))
qs = UncertaintySampling(method='entropy')

# Execute active learning cycle.
n_cycles = 20
for c in range(n_cycles):
     clf.fit(X, y)
     unlbld_idx = unlabeled_indices(y)
     X_cand = X[unlbld_idx]
     query_idx = unlbld_idx[qs.query(X_cand=X_cand, clf=clf)]
     y[query_idx] = y_true[query_idx]
print(f'Accuracy: {clf.fit(X, y).score(X, y_true)}')

Development

More information are available in the Developer’s Guide.

Documentation

The documentation is available here: https://scikit-activeml.readthedocs.io

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

scikit-activeml-0.1.1.tar.gz (97.6 kB view details)

Uploaded Source

Built Distribution

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

scikit_activeml-0.1.1-py3-none-any.whl (141.1 kB view details)

Uploaded Python 3

File details

Details for the file scikit-activeml-0.1.1.tar.gz.

File metadata

  • Download URL: scikit-activeml-0.1.1.tar.gz
  • Upload date:
  • Size: 97.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

File hashes

Hashes for scikit-activeml-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c31a882bcb4768418fe218d65c7530d1ed6c153ad16c76cae344a43b461f7efb
MD5 95639d12fc334114053d7d398ff133d9
BLAKE2b-256 d757d66414d327a361b3fe815b21a30fadb3904fa7db0a4090b11ccf6f8ad1bb

See more details on using hashes here.

File details

Details for the file scikit_activeml-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: scikit_activeml-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 141.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

File hashes

Hashes for scikit_activeml-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8123f5e8714a58701b4d68884bf3bc4b828b45eb248fa8cf37f34ac7ceacb40
MD5 c6bc3811e8cf2342c1779331eda50c31
BLAKE2b-256 c8dab4f0d19995fab01bc9889a110eadccba4c399114f60c9584da64926323ff

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