diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 2e83a0a..5d34df3 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -5,9 +5,9 @@ name: Tests on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: @@ -37,7 +37,7 @@ jobs: flake8 . --count --statistics - name: Test with pytest and measure coverage run: | - pytest ordcomp --cov=ordcomp --cov-report=xml + pytest cblearn --cov=cblearn --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: @@ -47,4 +47,4 @@ jobs: env_vars: OS,PYTHON - name: Build the documentation run: | - python setup.py build_sphinx \ No newline at end of file + python setup.py build_sphinx diff --git a/LICENSE b/LICENSE index 0b04938..167931a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2021 The ordcomp developers. +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 diff --git a/README.md b/README.md index b5245cb..50e70ab 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# ordcomp -Machine Learning Toolkit for Comparison-based Learning in Python +# cblearn +## Comparison-based Machine Learning in Python -[![Unit tests](https://github.com/dekuenstle/ordcomp/workflows/Python%20package/badge.svg)](https://github.com/dekuenstle/ordcomp/actions) -[![Test Coverage](https://codecov.io/gh/dekuenstle/ordcomp/branch/master/graph/badge.svg?token=P9JRT6OK6O)](https://codecov.io/gh/dekuenstle/ordcomp) -[![Documentation](https://readthedocs.org/projects/ordcomp/badge/?version=latest)](https://ordcomp.readthedocs.io/en/latest/?badge=latest) +[![Unit tests](https://github.com/dekuenstle/cblearn/workflows/Python%20package/badge.svg)](https://github.com/dekuenstle/cblearn/actions) +[![Test Coverage](https://codecov.io/gh/dekuenstle/cblearn/branch/master/graph/badge.svg?token=P9JRT6OK6O)](https://codecov.io/gh/dekuenstle/cblearn) +[![Documentation](https://readthedocs.org/projects/cblearn/badge/?version=latest)](https://cblearn.readthedocs.io/en/latest/?badge=latest) Comparison-based Learning are the Machine Learning algorithms to use, when training data are ordinal comparisons instead of Euclidean points. @@ -16,9 +16,9 @@ It plays hand-in-hand with scikit-learn: from sklearn.datasets import load_iris from sklearn.model_selection import cross_val_score -from ordcomp.datasets import make_random_triplets -from ordcomp.embedding.wrapper import SOE -from ordcomp.metrics import TripletScorer +from cblearn.datasets import make_random_triplets +from cblearn.embedding.wrapper import SOE +from cblearn.metrics import TripletScorer X = load_iris().data @@ -32,25 +32,25 @@ embedding = estimator.fit_transform(triplets, responses) print(f"The embedding has shape {embedding.shape}.") ``` -Please try the [Examples](https://ordcomp.readthedocs.io/en/latest/generated_examples/index.html). +Please try the [Examples](https://cblearn.readthedocs.io/en/latest/generated_examples/index.html). ## Getting Started -OrdComp required Python 3.7 or newer. The easiest way to install is using `pip`: +cblearn required Python 3.7 or newer. The easiest way to install is using `pip`: ``` -pip install https://github.com/dekuenstle/ordcomp.git +pip install https://github.com/dekuenstle/cblearn.git ``` -Find more details in the [installation instructions](https://ordcomp.readthedocs.io/en/latest/install.html). +Find more details in the [installation instructions](https://cblearn.readthedocs.io/en/latest/install.html). -In the [User Guide](https://ordcomp.readthedocs.io/en/latest/user_guide/index.html) you find a detailed introduction. +In the [User Guide](https://cblearn.readthedocs.io/en/latest/user_guide/index.html) you find a detailed introduction. ## Contribute We are happy about your contributions. -Please see our [Contributor Guide](https://ordcomp.readthedocs.io/en/latest/contributor_guide/index.html). +Please see our [Contributor Guide](https://cblearn.readthedocs.io/en/latest/contributor_guide/index.html). ## License -This library is free to use under the [MIT License](https://github.com/dekuenstle/ordcomp/blob/master/LICENSE) conditions. +This library is free to use under the [MIT License](https://github.com/dekuenstle/cblearn/blob/master/LICENSE) conditions. diff --git a/ordcomp/__init__.py b/cblearn/__init__.py similarity index 100% rename from ordcomp/__init__.py rename to cblearn/__init__.py diff --git a/ordcomp/_version.py b/cblearn/_version.py similarity index 100% rename from ordcomp/_version.py rename to cblearn/_version.py diff --git a/ordcomp/datasets/__init__.py b/cblearn/datasets/__init__.py similarity index 100% rename from ordcomp/datasets/__init__.py rename to cblearn/datasets/__init__.py diff --git a/ordcomp/datasets/_food_similarity.py b/cblearn/datasets/_food_similarity.py similarity index 100% rename from ordcomp/datasets/_food_similarity.py rename to cblearn/datasets/_food_similarity.py diff --git a/ordcomp/datasets/_musician_similarity.py b/cblearn/datasets/_musician_similarity.py similarity index 100% rename from ordcomp/datasets/_musician_similarity.py rename to cblearn/datasets/_musician_similarity.py diff --git a/ordcomp/datasets/_triplet_answers.py b/cblearn/datasets/_triplet_answers.py similarity index 98% rename from ordcomp/datasets/_triplet_answers.py rename to cblearn/datasets/_triplet_answers.py index 31dea81..0404b78 100644 --- a/ordcomp/datasets/_triplet_answers.py +++ b/cblearn/datasets/_triplet_answers.py @@ -6,7 +6,7 @@ from sklearn.metrics import pairwise import numpy as np -from ordcomp import utils +from cblearn import utils class NoiseTarget(enum.Enum): @@ -48,7 +48,7 @@ def noisy_triplet_answers(triplets: utils.Questions, embedding: np.ndarray, resu If return_indices is True, a tuple of indices and answers can be returned - >>> from ordcomp.datasets import noisy_triplet_answers + >>> from cblearn.datasets import noisy_triplet_answers >>> triplets = [[0, 1, 2], [1, 2, 3]] >>> embedding = [[0.1], [0.5], [0.9], [1.]] >>> noisy_triplet_answers(triplets, embedding, result_format='list-order') diff --git a/ordcomp/datasets/_triplet_indices.py b/cblearn/datasets/_triplet_indices.py similarity index 100% rename from ordcomp/datasets/_triplet_indices.py rename to cblearn/datasets/_triplet_indices.py diff --git a/ordcomp/datasets/_triplet_simulation.py b/cblearn/datasets/_triplet_simulation.py similarity index 91% rename from ordcomp/datasets/_triplet_simulation.py rename to cblearn/datasets/_triplet_simulation.py index 14ff081..9cee73d 100644 --- a/ordcomp/datasets/_triplet_simulation.py +++ b/cblearn/datasets/_triplet_simulation.py @@ -20,9 +20,9 @@ def make_all_triplets(embedding: np.ndarray, result_format: str, monotonic: bool embedding: Object coordinates or distance matrix monotonic: Only triplets (j, i, k), such that j < i < k. random_state: Seed for noisy answers - kwargs: Additional arguments passed to :func:`ordcomp.datasets.noisy_triplet_answers` + kwargs: Additional arguments passed to :func:`cblearn.datasets.noisy_triplet_answers` Returns: - The triplets and answers, based on format. See :func:`ordcomp.utils.check_triplets`. + The triplets and answers, based on format. See :func:`cblearn.utils.check_triplets`. """ triplets = make_all_triplet_indices(len(embedding), monotonic) return noisy_triplet_answers(triplets, embedding, result_format=result_format, **kwargs) @@ -49,9 +49,9 @@ def make_random_triplets(embedding: np.ndarray, result_format: str, size: Union[ make_all: Choose from all triplets instead of iterative sampling, if the difference between all triplets to the requested number is smaller than this value. random_state: Seed for triplet sampling and noisy answers - kwargs: Additional arguments passed to :func:`ordcomp.datasets.noisy_triplet_answers` + kwargs: Additional arguments passed to :func:`cblearn.datasets.noisy_triplet_answers` Returns: - The triplets and answers, based on format. See :func:`ordcomp.utils.check_triplets`. + The triplets and answers, based on format. See :func:`cblearn.utils.check_triplets`. """ triplets = make_random_triplet_indices(len(embedding), size, random_state, repeat, monotonic, make_all) return noisy_triplet_answers(triplets, embedding, result_format=result_format, random_state=random_state, **kwargs) diff --git a/ordcomp/datasets/data/musician_names.txt b/cblearn/datasets/data/musician_names.txt similarity index 100% rename from ordcomp/datasets/data/musician_names.txt rename to cblearn/datasets/data/musician_names.txt diff --git a/ordcomp/datasets/descr/food_similarity.rst b/cblearn/datasets/descr/food_similarity.rst similarity index 95% rename from ordcomp/datasets/descr/food_similarity.rst rename to cblearn/datasets/descr/food_similarity.rst index d744cc1..4215306 100644 --- a/ordcomp/datasets/descr/food_similarity.rst +++ b/cblearn/datasets/descr/food_similarity.rst @@ -19,7 +19,7 @@ Per user selection, multiple triplet constraints were created. Dimensionality unknown =================== ===================== -This dataset can be downloaded using the :func:`ordcomp.datasets.fetch_food_similarity`. +This dataset can be downloaded using the :func:`cblearn.datasets.fetch_food_similarity`. .. License statement from the original homepage diff --git a/ordcomp/datasets/descr/musician_similarity.rst b/cblearn/datasets/descr/musician_similarity.rst similarity index 95% rename from ordcomp/datasets/descr/musician_similarity.rst rename to cblearn/datasets/descr/musician_similarity.rst index 12e9121..ac2738f 100644 --- a/ordcomp/datasets/descr/musician_similarity.rst +++ b/cblearn/datasets/descr/musician_similarity.rst @@ -24,7 +24,7 @@ Such, for each user judgement multiple triplets were created with the remaining The original dataset, published 2002-10-15, contains 224793 triplets. We omit in this dataset the triplets with missing values for the last triplet index. -This dataset can be downloaded using the :func:`ordcomp.datasets.fetch_musician_similarity`. +This dataset can be downloaded using the :func:`cblearn.datasets.fetch_musician_similarity`. When using these triplets, please give credit to the original authors. diff --git a/ordcomp/datasets/tests/__init__.py b/cblearn/datasets/tests/__init__.py similarity index 100% rename from ordcomp/datasets/tests/__init__.py rename to cblearn/datasets/tests/__init__.py diff --git a/ordcomp/datasets/tests/test_food_similarity.py b/cblearn/datasets/tests/test_food_similarity.py similarity index 82% rename from ordcomp/datasets/tests/test_food_similarity.py rename to cblearn/datasets/tests/test_food_similarity.py index 5ae370a..ad35d27 100644 --- a/ordcomp/datasets/tests/test_food_similarity.py +++ b/cblearn/datasets/tests/test_food_similarity.py @@ -1,10 +1,10 @@ import numpy as np -from ordcomp.datasets import fetch_food_similarity +from cblearn.datasets import fetch_food_similarity def test_fetch_food(tmp_path): - data_home = tmp_path / 'ordcomp_datasets' + data_home = tmp_path / 'cblearn_datasets' bunch = fetch_food_similarity(data_home=data_home, shuffle=False) assert bunch.data.shape == (190376, 3) diff --git a/ordcomp/datasets/tests/test_musician_similarity.py b/cblearn/datasets/tests/test_musician_similarity.py similarity index 89% rename from ordcomp/datasets/tests/test_musician_similarity.py rename to cblearn/datasets/tests/test_musician_similarity.py index 36d0178..98f566a 100644 --- a/ordcomp/datasets/tests/test_musician_similarity.py +++ b/cblearn/datasets/tests/test_musician_similarity.py @@ -1,10 +1,10 @@ import numpy as np -from ordcomp.datasets import fetch_musician_similarity +from cblearn.datasets import fetch_musician_similarity def test_fetch_musician_similarity(tmp_path): - data_home = tmp_path / 'ordcomp_datasets' + data_home = tmp_path / 'cblearn_datasets' bunch = fetch_musician_similarity(data_home=data_home, shuffle=False) assert bunch.data.shape == (213629, 3) diff --git a/ordcomp/datasets/tests/test_triplet_indices.py b/cblearn/datasets/tests/test_triplet_indices.py similarity index 98% rename from ordcomp/datasets/tests/test_triplet_indices.py rename to cblearn/datasets/tests/test_triplet_indices.py index e2be4a7..9d36b9e 100644 --- a/ordcomp/datasets/tests/test_triplet_indices.py +++ b/cblearn/datasets/tests/test_triplet_indices.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from ordcomp import datasets +from cblearn import datasets def test_make_triplets_raises(): diff --git a/cblearn/embedding/__init__.py b/cblearn/embedding/__init__.py new file mode 100644 index 0000000..9510082 --- /dev/null +++ b/cblearn/embedding/__init__.py @@ -0,0 +1 @@ +from cblearn.embedding._soe import SOE diff --git a/ordcomp/embedding/_base.py b/cblearn/embedding/_base.py similarity index 95% rename from ordcomp/embedding/_base.py rename to cblearn/embedding/_base.py index ae48655..0052614 100644 --- a/ordcomp/embedding/_base.py +++ b/cblearn/embedding/_base.py @@ -4,8 +4,8 @@ from sklearn.base import TransformerMixin from sklearn.utils.validation import check_is_fitted -from ordcomp import datasets -from ordcomp import utils +from cblearn import datasets +from cblearn import utils class TripletEmbeddingMixin(TransformerMixin): diff --git a/ordcomp/embedding/_soe.py b/cblearn/embedding/_soe.py similarity index 96% rename from ordcomp/embedding/_soe.py rename to cblearn/embedding/_soe.py index 1fb4f01..f23d635 100644 --- a/ordcomp/embedding/_soe.py +++ b/cblearn/embedding/_soe.py @@ -6,10 +6,9 @@ from scipy.optimize import minimize from scipy.spatial import distance_matrix -import ordcomp -from ordcomp import utils -from ordcomp.embedding._base import TripletEmbeddingMixin -from ordcomp.utils import assert_torch_is_available, torch_minimize_lbfgs +from cblearn import utils +from cblearn.embedding._base import TripletEmbeddingMixin +from cblearn.utils import assert_torch_is_available, torch_minimize_lbfgs class SOE(BaseEstimator, TripletEmbeddingMixin): @@ -31,7 +30,7 @@ class SOE(BaseEstimator, TripletEmbeddingMixin): Examples: - >>> from ordcomp import datasets + >>> from cblearn import datasets >>> true_embedding = np.random.rand(15, 2) >>> triplets = datasets.make_random_triplets(true_embedding, result_format='list-order', size=1000) >>> triplets.shape, np.unique(triplets).shape @@ -91,7 +90,7 @@ def __init__(self, n_components=2, margin=1, max_iter=1000, verbose=False, self.device = device def fit(self, X: utils.Questions, y: np.ndarray = None, init: np.ndarray = None, - n_objects: Optional[int] = None) -> 'ordcomp.embedding.SOE': + n_objects: Optional[int] = None) -> 'SOE': """Computes the embedding. Args: diff --git a/ordcomp/embedding/tests/test_sklearn_estimator_checks.py b/cblearn/embedding/tests/test_sklearn_estimator_checks.py similarity index 91% rename from ordcomp/embedding/tests/test_sklearn_estimator_checks.py rename to cblearn/embedding/tests/test_sklearn_estimator_checks.py index de99c7e..7a7bf52 100644 --- a/ordcomp/embedding/tests/test_sklearn_estimator_checks.py +++ b/cblearn/embedding/tests/test_sklearn_estimator_checks.py @@ -7,7 +7,7 @@ This is why we wrap the ordinal embedding estimators below to transform featurized input to triplets. -Some checks are skipped, because ordcomp's estimators are not +Some checks are skipped, because cblearn's estimators are not 100% compatible to sklearn's estimators. While some of the checks could be adapted to our setting, some cannot work with triplet input. @@ -18,9 +18,9 @@ import numpy as np from sklearn.utils.estimator_checks import parametrize_with_checks -from ordcomp.embedding import SOE -from ordcomp.embedding import wrapper -from ordcomp.datasets import make_random_triplets +from cblearn.embedding import SOE +from cblearn.embedding import wrapper +from cblearn.datasets import make_random_triplets # Add new estimators here: @@ -81,7 +81,7 @@ def wrap_triplet_estimator(estimator): ) def test_all_estimators(estimator, check): if check.func.__name__ in SKIP_CHECKS: - pytest.skip("Ordcomp ordinal embedding estimator's are not fully compatible to sklearn estimators.") + pytest.skip("cblearn ordinal embedding estimator's are not fully compatible to sklearn estimators.") with wrap_triplet_estimator(estimator) as wrapped_estimator: check(wrapped_estimator) diff --git a/ordcomp/embedding/wrapper/__init__.py b/cblearn/embedding/wrapper/__init__.py similarity index 100% rename from ordcomp/embedding/wrapper/__init__.py rename to cblearn/embedding/wrapper/__init__.py diff --git a/ordcomp/embedding/wrapper/_mlds.py b/cblearn/embedding/wrapper/_mlds.py similarity index 94% rename from ordcomp/embedding/wrapper/_mlds.py rename to cblearn/embedding/wrapper/_mlds.py index 30ad991..0313922 100644 --- a/ordcomp/embedding/wrapper/_mlds.py +++ b/cblearn/embedding/wrapper/_mlds.py @@ -4,9 +4,9 @@ from sklearn.utils import check_random_state import numpy as np -from ordcomp import utils -from ordcomp.embedding._base import TripletEmbeddingMixin -from ordcomp.embedding.wrapper._r_base import RWrapperMixin +from cblearn import utils +from cblearn.embedding._base import TripletEmbeddingMixin +from cblearn.embedding.wrapper._r_base import RWrapperMixin class MLDS(BaseEstimator, TripletEmbeddingMixin, RWrapperMixin): @@ -24,7 +24,7 @@ class MLDS(BaseEstimator, TripletEmbeddingMixin, RWrapperMixin): embedding_: array-likeThe final embedding, shape (n_objects, 1) log_likelihood_: The final log-likelihood of the embedding. - >>> from ordcomp import datasets + >>> from cblearn import datasets >>> triplets = datasets.make_random_triplets(np.arange(15).reshape(-1, 1), size=400, result_format='list-order') >>> triplets.shape, np.unique(triplets).shape ((400, 3), (15,)) diff --git a/ordcomp/embedding/wrapper/_r_base.py b/cblearn/embedding/wrapper/_r_base.py similarity index 92% rename from ordcomp/embedding/wrapper/_r_base.py rename to cblearn/embedding/wrapper/_r_base.py index e1b7801..9898a7f 100644 --- a/ordcomp/embedding/wrapper/_r_base.py +++ b/cblearn/embedding/wrapper/_r_base.py @@ -17,8 +17,8 @@ def init_r(cls): numpy2ri.activate() except ImportError: raise ImportError("Expects installed python package 'rpy2', could not find it. " - "Did you install ordcomp with the r_wrapper extras? " - "pip install ordcomp[r_wrapper]") + "Did you install cblearn with the r_wrapper extras? " + "pip install cblearn[r_wrapper]") @classmethod def import_r_package(cls, package_name, install_if_missing=True, **kwargs): diff --git a/ordcomp/embedding/wrapper/_soe.py b/cblearn/embedding/wrapper/_soe.py similarity index 93% rename from ordcomp/embedding/wrapper/_soe.py rename to cblearn/embedding/wrapper/_soe.py index 6b0b868..073b26f 100644 --- a/ordcomp/embedding/wrapper/_soe.py +++ b/cblearn/embedding/wrapper/_soe.py @@ -4,10 +4,9 @@ from sklearn.utils import check_random_state import numpy as np -import ordcomp -from ordcomp import utils -from ordcomp.embedding._base import TripletEmbeddingMixin -from ordcomp.embedding.wrapper._r_base import RWrapperMixin +from cblearn import utils +from cblearn.embedding._base import TripletEmbeddingMixin +from cblearn.embedding.wrapper._r_base import RWrapperMixin class SOE(BaseEstimator, TripletEmbeddingMixin, RWrapperMixin): @@ -20,7 +19,7 @@ class SOE(BaseEstimator, TripletEmbeddingMixin, RWrapperMixin): stress_: Final value of the SOE stress corresponding to the embedding. Examples: - >>> from ordcomp import datasets + >>> from cblearn import datasets >>> triplets = datasets.make_random_triplets(np.random.rand(15, 2), result_format='list-order', size=1000) >>> triplets.shape, np.unique(triplets).shape ((1000, 3), (15,)) @@ -61,7 +60,7 @@ def __init__(self, n_components=2, n_init=10, margin=.1, max_iter=1000, verbose= self.random_state = random_state def fit(self, X: utils.Questions, y: np.ndarray = None, init: np.ndarray = None, - n_objects: Optional[int] = None) -> 'ordcomp.embedding.wrapper.SOE': + n_objects: Optional[int] = None) -> 'SOE': """Computes the embedding. Args: diff --git a/ordcomp/metrics/__init__.py b/cblearn/metrics/__init__.py similarity index 100% rename from ordcomp/metrics/__init__.py rename to cblearn/metrics/__init__.py diff --git a/ordcomp/metrics/_procrustes.py b/cblearn/metrics/_procrustes.py similarity index 100% rename from ordcomp/metrics/_procrustes.py rename to cblearn/metrics/_procrustes.py diff --git a/ordcomp/metrics/_triplets.py b/cblearn/metrics/_triplets.py similarity index 98% rename from ordcomp/metrics/_triplets.py rename to cblearn/metrics/_triplets.py index d1c90d7..a9b62fa 100644 --- a/ordcomp/metrics/_triplets.py +++ b/cblearn/metrics/_triplets.py @@ -4,7 +4,7 @@ from sklearn.utils import check_array from sklearn import metrics -from ordcomp import utils +from cblearn import utils from .. import datasets diff --git a/ordcomp/metrics/tests/__init__.py b/cblearn/metrics/tests/__init__.py similarity index 100% rename from ordcomp/metrics/tests/__init__.py rename to cblearn/metrics/tests/__init__.py diff --git a/ordcomp/metrics/tests/test_procrustes.py b/cblearn/metrics/tests/test_procrustes.py similarity index 96% rename from ordcomp/metrics/tests/test_procrustes.py rename to cblearn/metrics/tests/test_procrustes.py index fe9f45e..365ae57 100644 --- a/ordcomp/metrics/tests/test_procrustes.py +++ b/cblearn/metrics/tests/test_procrustes.py @@ -1,6 +1,6 @@ import numpy as np -from ordcomp import metrics +from cblearn import metrics def test_procrustes_distance(): diff --git a/ordcomp/metrics/tests/test_triplets.py b/cblearn/metrics/tests/test_triplets.py similarity index 96% rename from ordcomp/metrics/tests/test_triplets.py rename to cblearn/metrics/tests/test_triplets.py index a0602f8..b525a55 100644 --- a/ordcomp/metrics/tests/test_triplets.py +++ b/cblearn/metrics/tests/test_triplets.py @@ -1,8 +1,8 @@ import numpy as np import pytest -from ordcomp import metrics -from ordcomp import datasets +from cblearn import metrics +from cblearn import datasets class DummyOrdinalEmbedding(): diff --git a/ordcomp/utils/__init__.py b/cblearn/utils/__init__.py similarity index 100% rename from ordcomp/utils/__init__.py rename to cblearn/utils/__init__.py diff --git a/ordcomp/utils/_data_format.py b/cblearn/utils/_data_format.py similarity index 100% rename from ordcomp/utils/_data_format.py rename to cblearn/utils/_data_format.py diff --git a/ordcomp/utils/_torch.py b/cblearn/utils/_torch.py similarity index 95% rename from ordcomp/utils/_torch.py rename to cblearn/utils/_torch.py index 7f4e416..8bd9334 100644 --- a/ordcomp/utils/_torch.py +++ b/cblearn/utils/_torch.py @@ -16,10 +16,10 @@ def assert_torch_is_available() -> None: import torch # noqa: F401 We do not use torch here on purpose except ModuleNotFoundError as e: raise ModuleNotFoundError(f"{e}.\n\n" - "This function of ordcomp requires the installation of the pytorch package.\n" + "This function of cblearn requires the installation of the pytorch package.\n" "To install pytorch, visit https://pytorch.org/get-started/locally/\n" "or run either of the following commands:\n" - " pip install ordcomp[torch]\n" + " pip install cblearn[torch]\n" " pip install torch\n" " conda install -c=conda-forge pytorch\n") diff --git a/ordcomp/utils/_typing.py b/cblearn/utils/_typing.py similarity index 100% rename from ordcomp/utils/_typing.py rename to cblearn/utils/_typing.py diff --git a/ordcomp/utils/_validate_data.py b/cblearn/utils/_validate_data.py similarity index 100% rename from ordcomp/utils/_validate_data.py rename to cblearn/utils/_validate_data.py diff --git a/ordcomp/utils/_validate_size.py b/cblearn/utils/_validate_size.py similarity index 100% rename from ordcomp/utils/_validate_size.py rename to cblearn/utils/_validate_size.py diff --git a/ordcomp/utils/tests/__init__.py b/cblearn/utils/tests/__init__.py similarity index 100% rename from ordcomp/utils/tests/__init__.py rename to cblearn/utils/tests/__init__.py diff --git a/ordcomp/utils/tests/test_validate_data.py b/cblearn/utils/tests/test_validate_data.py similarity index 99% rename from ordcomp/utils/tests/test_validate_data.py rename to cblearn/utils/tests/test_validate_data.py index 725d97c..7ed6fe9 100644 --- a/ordcomp/utils/tests/test_validate_data.py +++ b/cblearn/utils/tests/test_validate_data.py @@ -2,7 +2,7 @@ import numpy as np import sparse -from ordcomp import utils +from cblearn import utils triplets_numeric_undecided = [[0, 1, 2], diff --git a/cblearn/utils/tests/test_validate_size.py b/cblearn/utils/tests/test_validate_size.py new file mode 100644 index 0000000..2e3fe54 --- /dev/null +++ b/cblearn/utils/tests/test_validate_size.py @@ -0,0 +1,14 @@ +import pytest + +import cblearn.utils + + +def test_check_size(): + assert 6 == cblearn.utils._validate_size.check_size(None, 6) + assert 3 == cblearn.utils._validate_size.check_size(3, 6) + assert 3 == cblearn.utils._validate_size.check_size(3., 6) + assert 3 == cblearn.utils._validate_size.check_size(.5, 6) + assert 15 == cblearn.utils._validate_size.check_size(15, 6) + + with pytest.raises(ValueError): + cblearn.utils._validate_size.check_size(-1, 6) diff --git a/docs/conf.py b/docs/conf.py index 368f69a..2173f02 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,7 +17,7 @@ # -- Project information ----------------------------------------------------- -project = 'OrdComp' +project = 'cblearn' author = 'David-Elias Künstle, Leena Suresh, Siyavash Haghiri, Michael Perrot, Debarghya Ghoshdastidari, Ulrike von Luxburg' copyright = f'2020, {author}' diff --git a/docs/contributor_guide/index.rst b/docs/contributor_guide/index.rst index 346c516..1f98b6a 100644 --- a/docs/contributor_guide/index.rst +++ b/docs/contributor_guide/index.rst @@ -6,16 +6,16 @@ There are multiple ways to contribute to this project. You can report bugs in this library or propose new ideas via `Github issues`_. This guide describes how to contribute code or documentation. -.. _Github issues: https://github.com/dekuenstle/ordcomp/issues +.. _Github issues: https://github.com/dekuenstle/cblearn/issues --------------- Getting Started --------------- -We assume, you downloaded and installed OrdComp as described in :ref:`developer_install`. +We assume, you downloaded and installed cblearn as described in :ref:`developer_install`. -The project directory contains the code directory ``ordcomp/`` and the documentation ``docs/``. +The project directory contains the code directory ``cblearn/`` and the documentation ``docs/``. In addition, there are readme, license, and a multiple configuration files as well as an examples folder. ------------- @@ -37,7 +37,7 @@ The docstring will be added to the :ref:`api_ref` by adding the function name in Check the syntax of the docstring by running ``make html`` in the ``docs/`` folder. Types should not be added to the docstring, but in the code as `type hints`_. -Typechecks can be performed using ``mypy ordcomp``. +Typechecks can be performed using ``mypy cblearn``. .. _PEP8 Style Guide: https://www.python.org/dev/peps/pep-0008/ .. _Google Docstring Style: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html @@ -84,14 +84,14 @@ sections below. Commit your changes to a separate *git* branch (do **not** commi After you finished changing push this branch to Github and open a pull request to the ``master`` branch there. Once the request is opened, automated tests are run. If these tests indicate a problem, you can fix this problem on your branch and push again. -Once the automated tests are successful, maintainers of OrdComp will review the changes and provide feedback. +Once the automated tests are successful, maintainers of cblearn will review the changes and provide feedback. Usually after some iterations, your changes will be merged to the ``master`` branch. .. Note: If you state a pull request, your changes will be published under `this open source license`_. -.. _this open source license: https://github.com/dekuenstle/ordcomp/blob/master/LICENSE +.. _this open source license: https://github.com/dekuenstle/cblearn/blob/master/LICENSE diff --git a/docs/index.rst b/docs/index.rst index 416af27..e756734 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,9 +1,9 @@ -.. OrdComp documentation master file, created by +.. cblearn documentation master file, created by sphinx-quickstart on Thu Sep 24 11:10:46 2020. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to OrdComp's documentation! +Welcome to cblearn's documentation! =================================== diff --git a/docs/install.rst b/docs/install.rst index 1cfdfaf..59bfec0 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -2,7 +2,7 @@ Installation ============ -OrdComp requires Python 3.7 or newer. +cblearn requires Python 3.7 or newer. We recommend using Anaconda_ to install Python and dependencies in separated environments. We support Linux (tested on Ubuntu 20.4), Windows and Mac OS. @@ -14,11 +14,11 @@ Examples in this installation guide Linux shell commands. User Installation ----------------- -OrdComp and its dependencies can be installed using `pip`: +cblearn and its dependencies can be installed using `pip`: .. code-block:: bash - $ pip install git+ssh://git@github.com/dekuenstle/ordcomp.git + $ pip install git+ssh://git@github.com/dekuenstle/cblearn.git .. _extras_install: @@ -26,7 +26,7 @@ Extras Requirements =================== The installation routine above tries to only install a minimal set of required packages. -Some of OrdComp's features depend on extra dependencies. +Some of cblearn's features depend on extra dependencies. These can be installed by adding them comma-separated in squared brackets to the pip command. For example, to use estimators on GPU, based on pytorch, and estimators @@ -34,7 +34,7 @@ wrapping paper author's original implementation in R-lang: .. code-block:: bash - $ pip install git+ssh://git@github.com/dekuenstle/ordcomp.git[torch,wrapper] + $ pip install git+ssh://git@github.com/dekuenstle/cblearn.git[torch,wrapper] ======= ============================================================= Extras Description @@ -59,6 +59,6 @@ This way, changes in the code are directly considered without the need of re-ins .. code-block:: bash - $ git clone git@github.com/dekuenstle/ordcomp.git - $ cd ordcomp + $ git clone git@github.com/dekuenstle/cblearn.git + $ cd cblearn $ pip install -e.[tests,docs] diff --git a/docs/references/index.rst b/docs/references/index.rst index a1d516d..e392c45 100644 --- a/docs/references/index.rst +++ b/docs/references/index.rst @@ -4,18 +4,18 @@ API Reference ============= -This is the class and function reference of OrdComp. +This is the class and function reference of cblearn. -:mod:`ordcomp.datasets` Datasets +:mod:`cblearn.datasets` Datasets ================================ -.. automodule:: ordcomp.datasets +.. automodule:: cblearn.datasets Loaders ------- -.. currentmodule:: ordcomp +.. currentmodule:: cblearn .. autosummary:: :toctree: generated/ @@ -27,7 +27,7 @@ Loaders Simulations ----------- -.. currentmodule:: ordcomp +.. currentmodule:: cblearn .. autosummary:: :toctree: generated/ @@ -39,7 +39,7 @@ Simulations Low-level Dataset Utility ------------------------- -.. currentmodule:: ordcomp +.. currentmodule:: cblearn .. autosummary:: :toctree: generated/ @@ -50,12 +50,12 @@ Low-level Dataset Utility datasets.noisy_triplet_answers -:mod:`ordcomp.embedding` Embedding +:mod:`cblearn.embedding` Embedding ================================== -.. automodule:: ordcomp.embedding +.. automodule:: cblearn.embedding -.. currentmodule:: ordcomp +.. currentmodule:: cblearn .. autosummary:: :toctree: generated/ @@ -65,7 +65,7 @@ Low-level Dataset Utility Wrapper ------- -.. currentmodule:: ordcomp.embedding +.. currentmodule:: cblearn.embedding .. autosummary:: @@ -75,12 +75,12 @@ Wrapper wrapper.SOE -:mod:`ordcomp.metrics` Metrics +:mod:`cblearn.metrics` Metrics ============================== -.. automodule:: ordcomp.metrics +.. automodule:: cblearn.metrics -.. currentmodule:: ordcomp +.. currentmodule:: cblearn .. autosummary:: :toctree: generated/ @@ -89,12 +89,12 @@ Wrapper metrics.procrustes_distance metrics.TripletScorer -:mod:`ordcomp.utils` Utility +:mod:`cblearn.utils` Utility ============================ -.. automodule:: ordcomp.utils +.. automodule:: cblearn.utils -.. currentmodule:: ordcomp +.. currentmodule:: cblearn .. autosummary:: :toctree: generated/ diff --git a/docs/user_guide/index.rst b/docs/user_guide/index.rst index 140360c..75b7360 100644 --- a/docs/user_guide/index.rst +++ b/docs/user_guide/index.rst @@ -27,5 +27,5 @@ This library supports two representation formats of triplets, in an array or in Dataset loading utilities ------------------------- -.. include:: ../../ordcomp/datasets/descr/musician_similarity.rst -.. include:: ../../ordcomp/datasets/descr/food_similarity.rst +.. include:: ../../cblearn/datasets/descr/musician_similarity.rst +.. include:: ../../cblearn/datasets/descr/food_similarity.rst diff --git a/examples/ordinal_embedding.py b/examples/ordinal_embedding.py index 2164adc..f37cdc0 100644 --- a/examples/ordinal_embedding.py +++ b/examples/ordinal_embedding.py @@ -10,7 +10,7 @@ We try to reconstruct the original points from the comparisons and quantify how good this works. """ from sklearn.datasets import make_blobs -from ordcomp.datasets import make_random_triplets +from cblearn.datasets import make_random_triplets # sample points from 3-dimensional Gaussian true_embedding, __ = make_blobs(n_samples=100, n_features=3, centers=1) @@ -21,9 +21,9 @@ print(f"Triplet comparisons: {triplets.shape}") # %% -# The ordinal embedding estimators in ordcomp follow the interface of scikit-learn's transformers. +# The ordinal embedding estimators in cblearn follow the interface of scikit-learn's transformers. # Let's estimate coordinates in a 2-dimensional and in a 3-dimensional Euclidean space. -from ordcomp.embedding.wrapper import SOE # noqa: E402 linter ignore import not at top of file +from cblearn.embedding.wrapper import SOE # noqa: E402 linter ignore import not at top of file transformer_2d = SOE(n_components=2) @@ -49,7 +49,7 @@ # which do not comply with the estimated embedding. # Note, that 5-fold cross validation requires refitting the model 5 times. from sklearn.model_selection import cross_val_score # noqa: E402 linter ignore import not at top of file -from ordcomp.metrics import procrustes_distance # noqa: E402 +from cblearn.metrics import procrustes_distance # noqa: E402 distance_3d = procrustes_distance(true_embedding, pred_embedding_3d) diff --git a/examples/triplet_formats.py b/examples/triplet_formats.py index f32d2f1..9391477 100644 --- a/examples/triplet_formats.py +++ b/examples/triplet_formats.py @@ -3,13 +3,13 @@ Triplet Formats =============== -OrdComp supports triplet input data in two +cblearn supports triplet input data in two formats: As a triplet array (or matrix with three columns) or as a sparse matrix. """ import time -from ordcomp import datasets -from ordcomp.utils import check_triplet_answers +from cblearn import datasets +from cblearn.utils import check_triplet_answers triplets_ordered = datasets.make_random_triplet_indices(n_objects=1000, size=1000000, repeat=False) print(f"'triplets_ordered' is a numpy array of shape {triplets_ordered.shape}.") diff --git a/ordcomp/embedding/__init__.py b/ordcomp/embedding/__init__.py deleted file mode 100644 index e29c715..0000000 --- a/ordcomp/embedding/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ordcomp.embedding._soe import SOE diff --git a/ordcomp/utils/tests/test_validate_size.py b/ordcomp/utils/tests/test_validate_size.py deleted file mode 100644 index 7b3614d..0000000 --- a/ordcomp/utils/tests/test_validate_size.py +++ /dev/null @@ -1,14 +0,0 @@ -import pytest - -import ordcomp.utils - - -def test_check_size(): - assert 6 == ordcomp.utils._validate_size.check_size(None, 6) - assert 3 == ordcomp.utils._validate_size.check_size(3, 6) - assert 3 == ordcomp.utils._validate_size.check_size(3., 6) - assert 3 == ordcomp.utils._validate_size.check_size(.5, 6) - assert 15 == ordcomp.utils._validate_size.check_size(15, 6) - - with pytest.raises(ValueError): - ordcomp.utils._validate_size.check_size(-1, 6) diff --git a/pyproject.toml b/pyproject.toml index f874823..f7cdba4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,5 +2,5 @@ requires = ["setuptools", "wheel"] [tool.pytest.ini_options] -addopts = "--doctest-modules -ra -v" +addopts = "--doctest-modules -ra -v --ignore=docs" doctest_optionflags = "NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 97098cc..bc5cd2e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,11 +1,11 @@ # Static configuration of the distribution package, as defined by setuptools [metadata] -name = ordcomp -description = Machine Learning Toolkit for Ordinal Comparison in Python. +name = cblearn +description = Comparison-based Machine Learning in Python. long_description = file: README.md, LICENSE author = 'David-Elias Künstle' author_email = 'david-elias dot kuenstle at uni-tuebingen dot de' -url = 'https://github.com/dekuenstle/ordcomp' +url = 'https://github.com/dekuenstle/cblearn' classifierts = Development Status :: 1 - Planning Environment :: GPU :: NVIDIA CUDA diff --git a/setup.py b/setup.py index e1d9d3c..fffc2ba 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools import find_packages, setup # get __version__ from _version.py -ver_file = os.path.join('ordcomp', '_version.py') +ver_file = os.path.join('cblearn', '_version.py') with open(ver_file) as f: exec(f.read())