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
For more information, see Use scikit-learn models in multiple instance learning based on the count-based assumption.
# 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.
Metadata
Release files for milwrap 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| milwrap-0.2.0.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| milwrap-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / milwrap-0.2.0.tar.gz
| Download URL | milwrap-0.2.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a5eade323f4f705ad6d61d1f9c688581a5d4bb54b82af1f9ce745a69b823757
|
|
BLAKE2b-256 checksum How to use checksums |
4cfb3dd6a131b3efd470e46775e9861dff2fada5db3430ebb091bafcac00dce0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.1 Linux/6.5.0-1025-azure
|
Release files / milwrap-0.2.0-py3-none-any.whl
| Download URL | milwrap-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e31bb8edeaff7ad1a3f8f781a17f378f9643ba96738e01ea61057c6c93ee3b24
|
|
BLAKE2b-256 checksum How to use checksums |
648685a943b1b599b72aaf4cefa28a861d9c559e61584e6c52b7f1a53fecbcd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.1 Linux/6.5.0-1025-azure
|