Skip to main content

milwrap - multiple instane meta-learner that can use any supervised-learning algorithms.

Project description

milwrap

Build Status GitHub issues

Python package for multiple instance learning (MIL). This wraps single instance learning algorithms so that they can be fitted to data for MIL.

庁 Features

  • support count-based multiple instance assumptions (see wikipedia)
  • support multi-class setting
  • support scikit-learn algorithms (such as RandomForestClassifier, SVC, LogisticRegression)

逃 Installation

pip install milwrap

噫 Usage

# Prepare single-instance supervised-learning algorithm
# Note: only supports models with predict_proba() method.
from sklearn.linear_model import LogisticRegression
clf = LogisticRegression()

# Wrap it with MilCountBasedMultiClassLearner
from milwrap import MilCountBasedMultiClassLearner 
mil_learner = MilCountBasedMultiClassLearner(clf)

# Prepare follwing dataset
#
# - bags ... list of np.ndarray
#            (num_instance_in_the_bag * num_features)
# - lower_threshold ... np.ndarray (num_bags * num_classes)
# - upper_threshold ... np.ndarray (num_bags * num_classes)
#
# bags[i_bag] contains not less than lower_thrshold[i_bag, i_class]
# i_class instances.

# run multiple instance learning
clf_mil, y_mil = learner.fit(
    bags,
    lower_threshold,
    upper_threshold,
    n_classes,
    max_iter=10)

# after multiple instance learning,
# you can predict instance class
clf_mil.predict([instance_feature])

See tests/test_countbased.py for an example of a fully working test data generation process.

塘 License

milwrap is available under the MIT License.

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

milwrap-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

milwrap-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file milwrap-0.1.0.tar.gz.

File metadata

  • Download URL: milwrap-0.1.0.tar.gz
  • Upload date:
  • Size: 3.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.7.7

File hashes

Hashes for milwrap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 339983f065e8f5af50e8e5cfedea61a9f72017cd10e934e379ce939335079e26
MD5 7efecd93495bde76453f1c65c9e16dfd
BLAKE2b-256 3cf0938375ee435c0b26fa274da834f5ac3ee83f759272a60f6ff24149f36a59

See more details on using hashes here.

File details

Details for the file milwrap-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: milwrap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.7.7

File hashes

Hashes for milwrap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06da126ee9866e4a9695eda0478514bcf2fbeea124a91f9f6f20f7ff3a0c00c0
MD5 514672488061fa99bab21dc69755e438
BLAKE2b-256 f0d14e62d297a7de9fde6fb0cadac5f400ecea5395ec5700eb9a5fb5d02ccf40

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page