{"id":14970690,"url":"https://github.com/inoueakimitsu/milwrap","last_synced_at":"2025-05-07T23:43:58.240Z","repository":{"id":44981597,"uuid":"411639873","full_name":"inoueakimitsu/milwrap","owner":"inoueakimitsu","description":"Wrapping single instance learning algorithms for fitting them to data for multiple instance learning","archived":false,"fork":false,"pushed_at":"2025-01-24T06:21:14.000Z","size":649,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T23:43:46.856Z","etag":null,"topics":["large-data","machine-learning","multi-class-classification","multiple-instance-learning","python","sklearn"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inoueakimitsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-29T11:06:11.000Z","updated_at":"2025-01-24T06:21:18.000Z","dependencies_parsed_at":"2023-02-19T12:46:13.108Z","dependency_job_id":null,"html_url":"https://github.com/inoueakimitsu/milwrap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inoueakimitsu%2Fmilwrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inoueakimitsu%2Fmilwrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inoueakimitsu%2Fmilwrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inoueakimitsu%2Fmilwrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inoueakimitsu","download_url":"https://codeload.github.com/inoueakimitsu/milwrap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973617,"owners_count":21834105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["large-data","machine-learning","multi-class-classification","multiple-instance-learning","python","sklearn"],"created_at":"2024-09-24T13:43:59.754Z","updated_at":"2025-05-07T23:43:58.220Z","avatar_url":"https://github.com/inoueakimitsu.png","language":"Jupyter Notebook","readme":"# milwrap\n\n[![Python Tests](https://github.com/inoueakimitsu/milwrap/actions/workflows/python-tests.yml/badge.svg)](https://github.com/inoueakimitsu/milwrap/actions/workflows/python-tests.yml)\n\u003ca href=\"https://github.com/inoueakimitsu/milwrap/issues\"\u003e\u003cimg alt=\"GitHub issues\" src=\"https://img.shields.io/github/issues/inoueakimitsu/milwrap\"\u003e\u003c/a\u003e\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/inoueakimitsu/milwrap/blob/master/introduction.ipynb)\n\nPython package for multiple instance learning (MIL).\nThis wraps single instance learning algorithms so that they can be fitted to data for MIL.\n\n## Features\n\n- support count-based multiple instance assumptions (see [wikipedia](https://en.wikipedia.org/wiki/Multiple_instance_learning#:~:text=Presence-%2C%20threshold-%2C%20and%20count-based%20assumptions%5Bedit%5D))\n- support multi-class setting\n- support scikit-learn algorithms (such as `RandomForestClassifier`, `SVC`, `LogisticRegression`)\n\n## Installation\n\n```bash\npip install milwrap\n```\n\n## Usage\n\nFor more information, see [Use scikit-learn models in multiple instance learning based on the count-based assumption](https://github.com/inoueakimitsu/milwrap/blob/main/intro-en.md).\n\n```python\n# Prepare single-instance supervised-learning algorithm\n# Note: only supports models with predict_proba() method.\nfrom sklearn.linear_model import LogisticRegression\nclf = LogisticRegression()\n\n# Wrap it with MilCountBasedMultiClassLearner\nfrom milwrap import MilCountBasedMultiClassLearner\nmil_learner = MilCountBasedMultiClassLearner(clf)\n\n# Prepare follwing dataset\n#\n# - bags ... list of np.ndarray\n#            (num_instance_in_the_bag * num_features)\n# - lower_threshold ... np.ndarray (num_bags * num_classes)\n# - upper_threshold ... np.ndarray (num_bags * num_classes)\n#\n# bags[i_bag] contains not less than lower_thrshold[i_bag, i_class]\n# i_class instances.\n\n# run multiple instance learning\nclf_mil, y_mil = learner.fit(\n    bags,\n    lower_threshold,\n    upper_threshold,\n    n_classes,\n    max_iter=10)\n\n# after multiple instance learning,\n# you can predict instance class\nclf_mil.predict([instance_feature])\n```\n\nSee `tests/test_countbased.py` for an example of a fully working test data generation process.\n\n## License\n\nmilwrap is available under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finoueakimitsu%2Fmilwrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finoueakimitsu%2Fmilwrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finoueakimitsu%2Fmilwrap/lists"}