Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the What you really need to know section for the big picture.

julearn.transformers.JuColumnTransformer

class julearn.transformers.JuColumnTransformer(name, transformer, apply_to, needed_types=None, row_select_col_type=None, row_select_vals=None, **params)

Column transformer that can be used in a julearn pipeline.

This column transformer is a wrapper around the sklearn column transformer, so it can be used directly with julearn pipelines.

Parameters:
  • name (str) – Name of the transformer.

  • transformer (EstimatorLikeFit1 | EstimatorLikeFit2 | EstimatorLikeFity) – The transformer to apply to the columns.

  • apply_to (list[str] | set[str] | str | ColumnTypes) – To which column types the transformer needs to be applied to.

  • needed_types (list[str] | set[str] | str | ColumnTypes | None, default: None) – Which feature types are needed for the transformer to work.

  • row_select_col_type (list[str] | set[str] | str | ColumnTypes | None, default: None) – The column types needed to select rows (default is None).

  • row_select_vals (str | int | list | bool | None, default: None) – The value(s) which should be selected in the row_select_col_type to select the rows used for training (default is None).

  • **params (Any) – Extra keyword arguments for the transformer.

__init__(name, transformer, apply_to, needed_types=None, row_select_col_type=None, row_select_vals=None, **params)
transform(X)

Apply the transformer.

Parameters:

X (DataFrame) – Data to be transformed.

Returns:

Transformed data.

get_feature_names_out(input_features=None)

Get names of features to be returned.

Parameters:

input_features (list[str] | None, default: None) – Input features to use.

Returns:

Names of features to be kept in the output pd.DataFrame.

get_params(deep=True)

Get parameters for this estimator.

Parameters:

deep (bool, default: True) – Not used. Kept for compatibility with scikit-learn.

Returns:

Parameter names mapped to their values.

set_params(**kwargs)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**kwargs (Any) – Estimator parameters.

Returns:

JuColumnTransformer instance with params set.

filter_columns(X)

Get the apply_to columns of a pandas DataFrame.

Parameters:

X (DataFrame) – The DataFrame to filter.

Returns:

The DataFrame with only the apply_to columns.

fit(X, y=None, **fit_params)

Fit the model.

This method will fit the model using only the columns selected by apply_to.

Parameters:
  • X (DataFrame) – The data to fit the model on.

  • y (Series | None, default: None) – The target data (default is None).

  • **fit_params (Any) – Additional parameters to pass to the model’s fit method.

Returns:

The fitted model.

fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Input samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) – Target values (None for unsupervised transformations).

  • **fit_params (dict) – Additional fit parameters. Pass only if the estimator accepts additional params in its fit method.

Returns:

Transformed array.

get_apply_to()

Get the column types the estimator applies to.

Returns:

The column types the estimator applies to.

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

A MetadataRequest encapsulating routing information.

get_needed_types()

Get the column types needed by the estimator.

Returns:

The column types needed by the estimator.

set_output(*, transform=None)

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:

transform ({“default”, “pandas”, “polars”}, default=None, default: None) – Configure output of transform and fit_transform.

Returns:

Estimator instance.