Transform X according to the fitted transformer. Parameters ---------- X : array-like, shape = [n_samples, n_features] Input vectors, where n_samples is the number of samples and n_features is the number of features. Returns -------
(self, X)
| 1476 | return output.replace("',", ",\n").replace("'", "") |
| 1477 | |
| 1478 | def transform(self, X): |
| 1479 | """Transform X according to the fitted transformer. |
| 1480 | |
| 1481 | Parameters |
| 1482 | ---------- |
| 1483 | X : array-like, shape = [n_samples, n_features] |
| 1484 | Input vectors, where n_samples is the number of samples |
| 1485 | and n_features is the number of features. |
| 1486 | |
| 1487 | Returns |
| 1488 | ------- |
| 1489 | X_new : array-like, shape = [n_samples, n_components] |
| 1490 | Transformed array. |
| 1491 | |
| 1492 | """ |
| 1493 | if not hasattr(self, '_best_programs'): |
| 1494 | raise NotFittedError('SymbolicTransformer not fitted.') |
| 1495 | |
| 1496 | X = validate_data(self, X, reset=False) |
| 1497 | |
| 1498 | _, n_features = X.shape |
| 1499 | if self.n_features_in_ != n_features: |
| 1500 | raise ValueError('Number of features of the model must match the ' |
| 1501 | 'input. Model n_features is %s and input ' |
| 1502 | 'n_features is %s.' |
| 1503 | % (self.n_features_in_, n_features)) |
| 1504 | |
| 1505 | X_new = np.array([gp.execute(X) for gp in self._best_programs]).T |
| 1506 | |
| 1507 | return X_new |
| 1508 | |
| 1509 | def fit_transform(self, X, y, sample_weight=None): |
| 1510 | """Fit to data, then transform it. |