We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4c549ad commit 0a51cd2Copy full SHA for 0a51cd2
1 file changed
pyvisim/encoders/_base_encoder.py
@@ -457,7 +457,12 @@ def learn(
457
print(" - Feature Extractor used:", self.feature_extractor.__class__.__name__)
458
print(" - Dimension of the feature space:", feat_dim := features.shape[1])
459
if dim_reduction_factor:
460
- self._pca = PCA(n_components=feat_dim // dim_reduction_factor)
+ if (n_components := feat_dim // dim_reduction_factor) <= 0:
461
+ raise ValueError(
462
+ f"dim_reduction_factor {dim_reduction_factor} is too large for the feature dimension {feat_dim}. "
463
+ f"Resulting PCA components would be {n_components}. Please choose a smaller dim_reduction_factor."
464
+ )
465
+ self._pca = PCA(n_components=n_components)
466
if self._pca is not None:
467
if not self._pca.is_fitted:
468
self._pca.fit(features)
0 commit comments