TemplateTransformer#

class skltemplate.TemplateTransformer(demo_param='demo')#

An example transformer that returns the element-wise square root.

For more information regarding how to build your own transformer, read more in the User Guide.

Parameters:
demo_paramstr, default=’demo’

A parameter used for demonstation of how to pass and store paramters.

Attributes:
n_features_in_int

Number of features seen during fit.

feature_names_in_ndarray of shape (n_features_in_,)

Names of features seen during fit. Defined only when X has feature names that are all strings.

Methods

fit(X[, y])

A reference implementation of a fitting function for a transformer.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

A reference implementation of a transform function.

fit(X, y=None)#

A reference implementation of a fitting function for a transformer.

Parameters:
X{array-like, sparse matrix}, shape (n_samples, n_features)

The training input samples.

yNone

There is no need of a target in a transformer, yet the pipeline API requires this parameter.

Returns:
selfobject

Returns self.

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:
Xarray-like of shape (n_samples, n_features)

Input samples.

yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None

Target values (None for unsupervised transformations).

**fit_paramsdict

Additional fit parameters.

Returns:
X_newndarray array of shape (n_samples, n_features_new)

Transformed array.

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

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”}, default=None

Configure output of transform and fit_transform.

  • "default": Default output format of a transformer

  • "pandas": DataFrame output

  • "polars": Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: "polars" option was added.

Returns:
selfestimator instance

Estimator instance.

set_params(**params)#

Set the parameters of this estimator.

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

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

transform(X)#

A reference implementation of a transform function.

Parameters:
X{array-like, sparse-matrix}, shape (n_samples, n_features)

The input samples.

Returns:
X_transformedarray, shape (n_samples, n_features)

The array containing the element-wise square roots of the values in X.

Examples using skltemplate.TemplateTransformer#

Plotting Template Transformer

Plotting Template Transformer