clustermil
Python package for multiple instance learning (MIL) for large n_instance dataset.
Features
- support count-based multiple instance assumptions (see wikipedia)
- support multi-class setting
- support scikit-learn Clustering algorithms (such as
MiniBatchKMeans) - fast even if n_instance is large
Installation
pip install clustermil
Usage
# 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.
# Prepare single-instance clustering algorithms
from sklearn.cluster import MiniBatchKMeans
n_clusters = 100
clustering = MiniBatchKMeans(n_clusters=n_clusters)
clusters = clustering.fit_predict(np.vstack(bags)) # flatten bags into instances
# Prepare one-hot encoder
from sklearn.preprocessing import OneHotEncoder
onehot_encoder = OneHotEncoder()
onehot_encoder.fit(clusters)
# generate ClusterMilClassifier with helper function
from clustermil import generate_mil_classifier
milclassifier = generate_mil_classifier(
clustering,
onehot_encoder,
bags,
lower_threshold,
upper_threshold,
n_clusters)
# after multiple instance learning,
# you can predict instance class
milclassifier.predict([instance_feature])
See tests/test_classification.py for an example of a fully working test data generation process.
License
clustermil is available under the MIT License.
Metadata
Release files for clustermil 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 | Provenance | Actions |
|---|---|---|---|---|
| clustermil-0.2.0.tar.gz | 4.3 kB | Without provenance | Details for clustermil-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clustermil-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for clustermil-0.2.0-py3-none-any.whl |
Total release size: 9.0 kB
Release files / clustermil-0.2.0.tar.gz
| Download URL | clustermil-0.2.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87eabdf8980ea71fbbc7634b089b845aaf1826d9e0c9878750fabaec1fb58579
|
|
BLAKE2b-256 checksum How to use checksums |
8cd931b0bc2b87ba4c72472f60500d9be3786d760c0350fee6bd5dba6aca5ef4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.9.13 Windows/10
|
Release files / clustermil-0.2.0-py3-none-any.whl
| Download URL | clustermil-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
248dfad281588acf410f8385bed54c763aad6722f77eb79af6f5607411af26d9
|
|
BLAKE2b-256 checksum How to use checksums |
db25cc164faab4151cfa4fea3705ced9b7a05c57dd87cb82f7308800a9805759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.9.13 Windows/10
|
Security for clustermil 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.