skdownscale.pointwise_models.PointWiseDownscaler

class skdownscale.pointwise_models.PointWiseDownscaler(model, dim='time')[source]

Bases: object

Pointwise downscaling model wrapper

Apply a scikit-learn model (e.g. Pipeline) point-by-point. The pipeline must implement the fit and predict methods.

Parameters:
  • model (sklearn.Pipeline or similar) – Object that implements the scikit-learn fit/predict api.

  • dim (str, optional) – Dimension to apply the model along. Default is time.

__init__(model, dim='time')[source]

Methods

__init__(model[, dim])

fit(X, *args, **kwargs)

Fit the model

get_attr(key, dtype[, template_output])

Get attribute values specified in key from each of the pointwise models

inverse_transform(X, **kwargs)

Apply inverse transforms to the data, and transform with the final estimator

predict(X, **kwargs)

Apply transforms to the data, and predict with the final estimator

transform(X, **kwargs)

Apply transforms to the data, and transform with the final estimator

fit(X, *args, **kwargs)[source]

Fit the model

Fit all the transforms one after the other and transform the data, then fit the transformed data using the final estimator.

Parameters:
  • X (xarray.DataArray or xarray.Dataset) – Training data. Must fulfill input requirements of first step of the pipeline. If an xarray.Dataset is passed, it will be converted to an array using to_array().

  • y (xarray.DataArray, optional) – Training targets. Must fulfill label requirements for all steps of the pipeline.

  • feature_dim (str, optional) – Name of feature dimension.

  • **fit_params (dict of string -> object) – Parameters passed to the fit method of the this model. If the model is a sklearn Pipeline, parameters can be passed to each step, where each parameter name is prefixed such that parameter p for step s has key s__p.

get_attr(key, dtype, template_output=None)[source]

Get attribute values specified in key from each of the pointwise models

Parameters:
  • key (str)

  • dtype (expected dtype of the values)

  • template_output (template data array or dataset of the output dimensions)

inverse_transform(X, **kwargs)[source]

Apply inverse transforms to the data, and transform with the final estimator

Parameters:
  • X (xarray.DataArray) – Data to transform on. Must fulfill input requirements of first step of the model or pipeline.

  • feature_dim (str, optional) – Name of feature dimension.

  • **transform_params (dict of string -> object) – Parameters to the transform called at the end of all transformations in the pipeline.

Returns:

y_inverse_trans (xarray.DataArray)

predict(X, **kwargs)[source]

Apply transforms to the data, and predict with the final estimator

Parameters:
  • X (xarray.DataArray) – Data to predict on. Must fulfill input requirements of first step of the model or pipeline.

  • feature_dim (str, optional) – Name of feature dimension.

  • **predict_params (dict of string -> object) – Parameters to the predict called at the end of all transformations in the pipeline. Note that while this may be used to return uncertainties from some models with return_std or return_cov, uncertainties that are generated by the transformations in the pipeline are not propagated to the final estimator.

Returns:

y_pred (xarray.DataArray)

transform(X, **kwargs)[source]

Apply transforms to the data, and transform with the final estimator

Parameters:
  • X (xarray.DataArray) – Data to transform on. Must fulfill input requirements of first step of the model or pipeline.

  • feature_dim (str, optional) – Name of feature dimension.

  • **transform_params (dict of string -> object) – Parameters to the transform called at the end of all transformations in the pipeline.

Returns:

y_trans (xarray.DataArray)