Comparison-based Machine Learning in Python.
Project description
Comparison-based Machine Learning in Python
Comparison-based learning methods are machine learning algorithms using similarity comparisons ("A and B are more similar than C and D") instead of featurized data.
from sklearn.datasets import load_iris
from sklearn.model_selection import cross_val_score
from cblearn.datasets import make_random_triplets
from cblearn.embedding import SOE
from cblearn.metrics import QueryScorer
X = load_iris().data
triplets = make_random_triplets(X, result_format="list-order", size=1000)
estimator = SOE(n_components=2)
# Measure the fit with scikit-learn's cross-validation
scores = cross_val_score(estimator, triplets, cv=5)
print(f"The 5-fold CV triplet error is {sum(scores) / len(scores)}.")
# Estimate the scale on all triplets
embedding = estimator.fit_transform(triplets)
print(f"The embedding has shape {embedding.shape}.")
Getting Started
Contribute
We are happy about your bug reports, questions or suggestions as Github Issues and code or documentation contributions as Github Pull Requests. Please see our Contributor Guide.
Related packages
There are more Python packages for comparison-based learning:
- metric-learn is a collection of algorithms for metric learning. The weakly supervised algorithms learn from triplets and quadruplets.
- salmon is a package for efficiently collecting triplets in crowd-sourced experiments. The package implements ordinal embedding algorithms and sampling strategies to query the most informative comparisons actively.
Authors and Acknowledgement
cblearn was initiated by current and former members of the Theory of Machine Learning group of Prof. Dr. Ulrike von Luxburg at the University of Tübingen. The leading developer is David-Elias Künstle.
We want to thank all the contributors here on GitHub. This work has been supported by the Machine Learning Cluster of Excellence, funded by EXC number 2064/1 – Project number 390727645. The authors would like to thank the International Max Planck Research School for Intelligent Systems (IMPRS-IS) for supporting David-Elias Künstle.
License
This library is free to use, share, and adapt under the MIT License conditions.
If you publish work that uses this library, please cite our JOSS paper.
Changelog
Upcoming
0.3
- Feature: JOSS paper
- Feature: Quickstart guide in documentation
- Feature: Data point sampling from manifolds.
- Improvement: Extended documentation
- Improvement: cblearn logo and new style in documentation
- Improvement: Filter invalid responses in datasets
- Improvement: Full compatibility to sklearn estimator tests
0.2
- Improvement: Extended documentation
- Feature:
embedding.estimate_dimensionality_cv
function (Künstle et al., 2022) - Fix: Avoid numpy deprecation warning for scalar variables in
fetch_similarity_matrix
- Fix: Various errors in the examples
- Fix: Minor errors in the unit tests
- Others: Updated dependencies
0.1
0.1.2
- support python 3.11
- update core dependencies
0.1.1
- Minor fixes in the documentation.
- Adapt loading of food and imagenet dataset to solve problems caused by changes in externally hosted files
0.1.0
- Support python 3.9 and 3.10.
- Introduce semantic versioning
- Publish to PyPI
MIT License
Copyright (c) 2020-2021 The cblearn developers.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
Built Distribution
File details
Details for the file cblearn-0.3.0.tar.gz
.
File metadata
- Download URL: cblearn-0.3.0.tar.gz
- Upload date:
- Size: 408.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5f86526fee5d1530996343e70719213d52ed41f9b84feadd5601368baa70d78 |
|
MD5 | 1e706240a2cd86d043a6b641a3b25b47 |
|
BLAKE2b-256 | cec4e6d60d2a2914a6e5ea3adb03cf9111458a284779c5b3da6925efb5bd0266 |
File details
Details for the file cblearn-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: cblearn-0.3.0-py3-none-any.whl
- Upload date:
- Size: 104.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 541f075f31af309ca27d08420b025bd077bbe3f96152e6069286a022b251ea06 |
|
MD5 | 0a3f78ad86b849660e1102e038ab1217 |
|
BLAKE2b-256 | 7be457bda32b581aeb38683ba52556bea1431db256ebb80004fbb0d71d7a3ead |