Package: cblearn
cblearnComparison-based Machine Learning in PythonComparison-based Learning algorithms are the Machine Learning algorithms to use when training data contains similarity comparisons ("A and B are more similar than C and D") instead of data points.Triplet comparisons from human observers help model the perceived similarity of objects.
These human triplets are collected in studies, asking questions like
"Which of the following bands is most similar to Queen?" or
"Which color appears most similar to the reference?".This library provides an easy-to-use interface for comparison-based learning algorithms.
It plays hand-in-hand with scikit-learn:fromsklearn.datasetsimportload_irisfromsklearn.model_selectionimportcross_val_scorefromcblearn.datasetsimportmake_random_tripletsfromcblearn.embeddingimportSOEfromcblearn.metricsimportQueryScorerX=load_iris().datatriplets=make_random_triplets(X,result_format="list-order",size=1000)estimator=SOE(n_components=2)# Measure the fit with scikit-learn's cross-validationscores=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 tripletsembedding=estimator.fit_transform(triplets)print(f"The embedding has shape{embedding.shape}.")Please try theExamples.Getting StartedInstall cblearn as describedhereand try theexamples.Find a theoretical introduction to comparison-based learning, the datatypes,
algorithms, and datasets in theUser Guide.FeaturesDatasetscblearnprovides utility methods to simplify the loading and conversion
of your comparison datasets. In addition, some functions download and load multiple real-world comparisons.DatasetQuery#Object#Response#TripletVogue CoverOdd-out Triplet601,1072,214Nature SceneOdd-out Triplet1203,3556,710CarMost-Central Triplet607,09714,194MaterialStandard Triplet100104,692104,692FoodStandard Triplet100190,376190,376MusicianStandard Triplet413224,792224,792Things Image TestsetOdd-out Triplet1,854146,012292,024ImageNet Images v0.1Rank 2 from 81,00025,273328,549ImageNet Images v0.2Rank 2 from 850,000384,2775MEmbedding AlgorithmsAlgorithmDefaultPytorch (GPU)Reference WrapperCrowd Kernel Learning (CKL)XXFORTEXGNMDSXXMaximum-Likelihood Difference Scaling (MLDS)XMLDS (R)Soft Ordinal Embedding (SOE)XXloe (R)Stochastic Triplet Embedding (STE/t-STE)XXContributeWe are happy about your bug reports, questions or suggestions as Github Issues and code or documentation contributions as Github Pull Requests.
Please see ourContributor Guide.Authors and Acknowledgementcblearnwas initiated by current and former members of theTheory of Machine Learning groupof Prof. Dr. Ulrike von Luxburg at the University of Tübingen.
The leading developer isDavid-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.LicenseThis library is free under theMIT Licenseconditions.
Please cite this library appropriately if it contributes to your scientific publication. We would also appreciate a short email (optionally) to see how our library is being used.ChangelogUpcoming0.2.0Improvement: Extended documentationFeature:embedding.estimate_dimensionality_cvfunction (Künstle et al., 2022)Fix: Avoid numpy deprecation warning for scalar variables infetch_similarity_matrixFix: Various errors in the examplesFix: Minor errors in the unit testsOthers: Updated dependencies0.1.2support python 3.11update core dependencies0.1.1Minor fixes in the documentation.Adapt loading of food and imagenet dataset to solve problems caused by changes in externally hosted files0.1.0Support python 3.9 and 3.10.Introduce semantic versioningPublish to PyPIMIT LicenseCopyright (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.