skdownscale.pointwise_models.PointWiseDownscaler¶
- class skdownscale.pointwise_models.PointWiseDownscaler(model, dim='time')[source]¶
Bases:
objectPointwise 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.Pipelineorsimilar) – Object that implements the scikit-learn fit/predict api.dim (
str, optional) – Dimension to apply the model along. Default istime.
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.DataArrayorxarray.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 (
dictofstring -> object) – Parameters passed to thefitmethod 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 parameterpfor stepshas keys__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 dtypeofthe values)template_output (
template data arrayordatasetofthe 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 (
dictofstring -> object) – Parameters to thetransformcalled 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 (
dictofstring -> object) – Parameters to thepredictcalled 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 (
dictofstring -> object) – Parameters to thetransformcalled at the end of all transformations in the pipeline.
- Returns:
y_trans (
xarray.DataArray)