ordinal_embedding.ipynb example doesn't work.
Predicted 2D embedding: (100, 2)
Predicted 3D embedding: (100, 3)
The estimated embedding can be evaluated from different perspectives.
The procrustes distance is a square distance between the true and the estimated embeddings, where scale, rotation and translation transformations are ignored. This is only possible, if the true embedding is known and the embeddings have the same dimensionality.
The training triplet error is the fraction of training comparisons, which do not comply with the estimated embedding.
The cross-validation triplet error indicates the fraction of unknown triplets which do not comply with the estimated embedding. Note, that 5-fold cross validation requires refitting the model 5 times.
Procrustes distance: 0.00322 in 3d
Training triplet error: 0.126 in 2d vs 0.000 in 3d.
---------------------------------------------------------------------------
Empty Traceback (most recent call last)
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/joblib/parallel.py:1423, in Parallel.dispatch_one_batch(self, iterator)
1422 try:
-> 1423 tasks = self._ready_batches.get(block=False)
1424 except queue.Empty:
1425 # slice the iterator n_jobs * batchsize items at a time. If the
1426 # slice returns less than that, then the current batchsize puts
(...)
1429 # accordingly to distribute evenly the last items between all
1430 # workers.
File ~/anaconda3/envs/cblearn/lib/python3.9/queue.py:168, in Queue.get(self, block, timeout)
167 if not self._qsize():
--> 168 raise Empty
169 elif timeout is None:
Empty:
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
Cell In[6], line 12
9 error_3d = 1 - transformer_3d.score(triplets)
10 print(f"Training triplet error: {error_2d:.3f} in 2d vs {error_3d:.3f} in 3d.")
---> 12 cv_error_2d = 1 - cross_val_score(transformer_3d, triplets, cv=5, n_jobs=-1).mean()
13 cv_error_3d = 1 - cross_val_score(transformer_3d, triplets, cv=5, n_jobs=-1).mean()
14 print(f"CV triplet error: {cv_error_2d:.3f} in 2d vs {cv_error_3d:.3f} in 3d.")
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/model_selection/_validation.py:562, in cross_val_score(estimator, X, y, groups, scoring, cv, n_jobs, verbose, fit_params, pre_dispatch, error_score)
559 # To ensure multimetric format is not supported
560 scorer = check_scoring(estimator, scoring=scoring)
--> 562 cv_results = cross_validate(
563 estimator=estimator,
564 X=X,
565 y=y,
566 groups=groups,
567 scoring={"score": scorer},
568 cv=cv,
569 n_jobs=n_jobs,
570 verbose=verbose,
571 fit_params=fit_params,
572 pre_dispatch=pre_dispatch,
573 error_score=error_score,
574 )
575 return cv_results["test_score"]
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/utils/_param_validation.py:214, in validate_params.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
208 try:
209 with config_context(
210 skip_parameter_validation=(
211 prefer_skip_nested_validation or global_skip_validation
212 )
213 ):
--> 214 return func(*args, **kwargs)
215 except InvalidParameterError as e:
216 # When the function is just a wrapper around an estimator, we allow
217 # the function to delegate validation to the estimator, but we replace
218 # the name of the estimator by the name of the function in the error
219 # message to avoid confusion.
220 msg = re.sub(
221 r"parameter of \w+ must be",
222 f"parameter of {func.__qualname__} must be",
223 str(e),
224 )
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/model_selection/_validation.py:309, in cross_validate(estimator, X, y, groups, scoring, cv, n_jobs, verbose, fit_params, pre_dispatch, return_train_score, return_estimator, return_indices, error_score)
306 # We clone the estimator to make sure that all the folds are
307 # independent, and that it is pickle-able.
308 parallel = Parallel(n_jobs=n_jobs, verbose=verbose, pre_dispatch=pre_dispatch)
--> 309 results = parallel(
310 delayed(_fit_and_score)(
311 clone(estimator),
312 X,
313 y,
314 scorers,
315 train,
316 test,
317 verbose,
318 None,
319 fit_params,
320 return_train_score=return_train_score,
321 return_times=True,
322 return_estimator=return_estimator,
323 error_score=error_score,
324 )
325 for train, test in indices
326 )
328 _warn_or_raise_about_fit_failures(results, error_score)
330 # For callable scoring, the return type is only know after calling. If the
331 # return type is a dictionary, the error scores can now be inserted with
332 # the correct key.
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/utils/parallel.py:65, in Parallel.__call__(self, iterable)
60 config = get_config()
61 iterable_with_config = (
62 (_with_config(delayed_func, config), args, kwargs)
63 for delayed_func, args, kwargs in iterable
64 )
---> 65 return super().__call__(iterable_with_config)
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/joblib/parallel.py:1950, in Parallel.__call__(self, iterable)
1944 self._call_ref = weakref.ref(output)
1946 # The first item from the output is blank, but it makes the interpreter
1947 # progress until it enters the Try/Except block of the generator and
1948 # reach the first `yield` statement. This starts the aynchronous
1949 # dispatch of the tasks to the workers.
-> 1950 next(output)
1952 return output if self.return_generator else list(output)
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/joblib/parallel.py:1588, in Parallel._get_outputs(self, iterator, pre_dispatch)
1586 detach_generator_exit = False
1587 try:
-> 1588 self._start(iterator, pre_dispatch)
1589 # first yield returns None, for internal use only. This ensures
1590 # that we enter the try/except block and start dispatching the
1591 # tasks.
1592 yield
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/joblib/parallel.py:1571, in Parallel._start(self, iterator, pre_dispatch)
1562 def _start(self, iterator, pre_dispatch):
1563 # Only set self._iterating to True if at least a batch
1564 # was dispatched. In particular this covers the edge
(...)
1568 # was very quick and its callback already dispatched all the
1569 # remaining jobs.
1570 self._iterating = False
-> 1571 if self.dispatch_one_batch(iterator):
1572 self._iterating = self._original_iterator is not None
1574 while self.dispatch_one_batch(iterator):
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/joblib/parallel.py:1434, in Parallel.dispatch_one_batch(self, iterator)
1431 n_jobs = self._cached_effective_n_jobs
1432 big_batch_size = batch_size * n_jobs
-> 1434 islice = list(itertools.islice(iterator, big_batch_size))
1435 if len(islice) == 0:
1436 return False
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/utils/parallel.py:61, in <genexpr>(.0)
56 # Capture the thread-local scikit-learn configuration at the time
57 # Parallel.__call__ is issued since the tasks can be dispatched
58 # in a different thread depending on the backend and on the value of
59 # pre_dispatch and n_jobs.
60 config = get_config()
---> 61 iterable_with_config = (
62 (_with_config(delayed_func, config), args, kwargs)
63 for delayed_func, args, kwargs in iterable
64 )
65 return super().__call__(iterable_with_config)
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/model_selection/_validation.py:311, in <genexpr>(.0)
306 # We clone the estimator to make sure that all the folds are
307 # independent, and that it is pickle-able.
308 parallel = Parallel(n_jobs=n_jobs, verbose=verbose, pre_dispatch=pre_dispatch)
309 results = parallel(
310 delayed(_fit_and_score)(
--> 311 clone(estimator),
312 X,
313 y,
314 scorers,
315 train,
316 test,
317 verbose,
318 None,
319 fit_params,
320 return_train_score=return_train_score,
321 return_times=True,
322 return_estimator=return_estimator,
323 error_score=error_score,
324 )
325 for train, test in indices
326 )
328 _warn_or_raise_about_fit_failures(results, error_score)
330 # For callable scoring, the return type is only know after calling. If the
331 # return type is a dictionary, the error scores can now be inserted with
332 # the correct key.
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/base.py:75, in clone(estimator, safe)
41 """Construct a new unfitted estimator with the same parameters.
42
43 Clone does a deep copy of the model in an estimator
(...)
72 found in :ref:`randomness`.
73 """
74 if hasattr(estimator, "__sklearn_clone__") and not inspect.isclass(estimator):
---> 75 return estimator.__sklearn_clone__()
76 return _clone_parametrized(estimator, safe=safe)
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/base.py:268, in BaseEstimator.__sklearn_clone__(self)
267 def __sklearn_clone__(self):
--> 268 return _clone_parametrized(self)
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/base.py:106, in _clone_parametrized(estimator, safe)
98 raise TypeError(
99 "Cannot clone object '%s' (type %s): "
100 "it does not seem to be a scikit-learn "
101 "estimator as it does not implement a "
102 "'get_params' method." % (repr(estimator), type(estimator))
103 )
105 klass = estimator.__class__
--> 106 new_object_params = estimator.get_params(deep=False)
107 for name, param in new_object_params.items():
108 new_object_params[name] = clone(param, safe=False)
File ~/anaconda3/envs/cblearn/lib/python3.9/site-packages/sklearn/base.py:195, in BaseEstimator.get_params(self, deep)
193 out = dict()
194 for key in self._get_param_names():
--> 195 value = getattr(self, key)
196 if deep and hasattr(value, "get_params") and not isinstance(value, type):
197 deep_items = value.get_params().items()
AttributeError: 'SOE' object has no attribute 'n_init'
Used conda env mentioned in the documentation, so it uses python3.9.