Skip to content

[question or doc update] global_reconstruction_distortion does not support features with different dimensions #269

@sofiia-chorna

Description

@sofiia-chorna
import numpy as np
from skmatter.metrics import global_reconstruction_distortion

A_features = np.random.rand(10, 5)
B_features = np.random.rand(10, 4)

result = global_reconstruction_distortion(A_features, B_features)

raises:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[148], [line 7](vscode-notebook-cell:?execution_count=148&line=7)
      4 A_features = np.random.rand(10, 5)
      5 B_features = np.random.rand(10, 4)
----> [7](vscode-notebook-cell:?execution_count=148&line=7) result = global_reconstruction_distortion(A_features, B_features)

File /opt/miniconda3/envs/course/lib/python3.11/site-packages/skmatter/metrics/_reconstruction_measures.py:315, in global_reconstruction_distortion(X, Y, test_idx, train_idx, scaler, estimator)
    255 def global_reconstruction_distortion(
    256     X,
    257     Y,
   (...)    261     estimator=None,
    262 ):
    263     r"""Computes the global reconstruction distortion using the source X
    264     to reconstruct the features or samples of target Y based on a minimization
    265     by orthogonal regression:
   (...)    312 
    313     """
    314     pointwise_global_reconstruction_distortion_values = (
--> [315](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/course/lib/python3.11/site-packages/skmatter/metrics/_reconstruction_measures.py:315)         pointwise_global_reconstruction_distortion(
    316             X,
    317             Y,
    318             train_idx=train_idx,
    319             test_idx=test_idx,
    320             scaler=scaler,
...
    249     .predict(X_test)
    250 )
--> [252](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/course/lib/python3.11/site-packages/skmatter/metrics/_reconstruction_measures.py:252) return np.linalg.norm(predictions_Y_test - orthogonal_predictions_Y_test, axis=1)

ValueError: operands could not be broadcast together with shapes (5,4) (5,5)

However in the documentation it states that the number of features can be different.

Perhaps, it would make sense to update the documentation if indeed different dimensions are not supported

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions