milwrap - multiple instane meta-learner that can use any supervised-learning algorithms.
Project description
milwrap
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.3.tar.gz
(4.3 kB
view details)
Built Distribution
File details
Details for the file milwrap-0.1.3.tar.gz
.
File metadata
- Download URL: milwrap-0.1.3.tar.gz
- Upload date:
- Size: 4.3 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d0fbbe4c728a0186668a0bf7de7dabcd108a720c02d440a6931d7ac7ff4e5b2 |
|
MD5 | 03041b037ef4aaac79ed20482c3ac566 |
|
BLAKE2b-256 | a43fe5c0c8e349c168c4371ad5e032a8d6da623971b1bd23a3fdb6e1ad85d641 |
File details
Details for the file milwrap-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: milwrap-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | aca3cdd9ee433e7a9ae1331389739cb755a3c4709cba0466fe6924dffb9a51b9 |
|
MD5 | c5da74578e0ef95e85a458f3201489bc |
|
BLAKE2b-256 | 5bafb136e4941331edde8be3bef0343d334b9140e5010910a303f21ada13f4a8 |