Transform 2D data back to its original feature shape. Parameters ---------- X : array-like, shape (n_samples, n_features) Data to be transformed back to original shape. Returns ------- X : array The data transformed into shap
(self, X)
| 375 | return self.fit(X).transform(X) |
| 376 | |
| 377 | def inverse_transform(self, X): |
| 378 | """Transform 2D data back to its original feature shape. |
| 379 | |
| 380 | Parameters |
| 381 | ---------- |
| 382 | X : array-like, shape (n_samples, n_features) |
| 383 | Data to be transformed back to original shape. |
| 384 | |
| 385 | Returns |
| 386 | ------- |
| 387 | X : array |
| 388 | The data transformed into shape as used in fit. The first |
| 389 | dimension is of length n_samples. |
| 390 | """ |
| 391 | X = self._check_data(X, atleast_3d=False, check_n_features=False) |
| 392 | if X.ndim not in (2, 3): |
| 393 | raise ValueError( |
| 394 | f"X should be of 2 or 3 dimensions but has shape {X.shape}" |
| 395 | ) |
| 396 | return X.reshape(X.shape[:-1] + self.features_shape_) |
| 397 | |
| 398 | |
| 399 | @fill_doc |