Skip to content

transform


method transform(X, y=None, pipeline=None, verbose=None) [source]

Transform new data through all transformers in the current branch. By default, transformers that are applied on the training set only are not used during the transformations. Use the pipeline parameter to customize this behaviour. This method can only be called from atom, not from the models.

Parameters:

X: dict, list, tuple, np.ndarray or pd.DataFrame
Features to transform, with shape=(n_samples, n_features).

y: int, str, sequence or None, optional (default=None)
  • If None: y is ignored in the transformers.
  • If int: Position of the target column in X.
  • If str: Name of the target column in X.
  • Else: Target column with shape=(n_samples,).
pipeline: bool, sequence or None, optional (default=None)
Transformers to use on the data before predicting.
  • If None: Only transformers that are applied on the whole dataset are used.
  • If False: Don't use any transformers.
  • If True: Use all transformers in the pipeline.
  • If sequence: Transformers to use, selected by their index in the pipeline.

verbose: int or None, optional (default=None)
Verbosity level of the output. If None, it uses the transformer's own verbosity.

Returns:

X: pd.DataFrame
Transformed feature set.

y: pd.Series
Transformed target column. Only returned if provided.


Example

from atom import ATOMClassifier

atom = ATOMClassifier(X, y)
atom.clean()
atom.impute(strat_num="knn", strat_cat="drop")
atom.prune(strategy="z-score", method="min_max", max_sigma=2)

# Transform new data through all transformers in the branch
X_transformed = atom.transform(X_new)
Back to top