Target

sklearn_xarray.target

class Target(coord=None, transform_func=None, transformer=None, lazy=False, dim=None, reduce_func=None)[source]

A pointer to xarray coordinates or variables to be used as a target.

Parameters
coordstr, optional

The coordinate or variable that holds the data of the target. If not specified, the target will be the entire DataArray/Dataset.

transform_funccallable, optional

A function that transforms the coordinate values to an sklearn-compatible type and shape. If not specified, the coordinate(s) will be used as-is.

transformersklearn transformer, optional

Deprecated, use transform_func=Transformer().fit_transform instead.

lazybool, optinonal

If true, the target coordinate is only transformed by the transformer when needed. The transformer can implement a get_transformed_shape method that returns the shape after the transformation of the provided coordinate without actually transforming the data.

dimstr or sequence of str, optional

When set, multi-dimensional coordinates will be reduced to this dimension/these dimensions.

reduce_funccallable, optional

A callable that reduces the coordinate(s) to the dimension(s) in dim. If not specified, the values along dimensions not in dim will be reduced to the first element in each of these dimensions.

Attributes
ndim

The number of dimensions of the transformed target.

shape

The shape of the transformed target.

Methods

__call__(self, X)

Call self as a function.

assign_to(self, X)

Assign this target to a DataArray or Dataset.

assign_to(self, X)[source]

Assign this target to a DataArray or Dataset.

Parameters
Xxarray DataArray or Dataset

The data whose coordinate is used as the target.

Returns
self:

The target itself.

property ndim

The number of dimensions of the transformed target.

property shape

The shape of the transformed target.