discontinuum.pipeline#

Functions

datetime_to_decimal_year(x)

Convert a timeseries to decimal year.

decimal_year_to_datetime(x)

Convert a decimal year to a datetime.

Classes

BaseTransformer()

Base class for transformers.

ClipTransformer([min, max])

Clip a variable.

ErrorPipeline(steps, *[, transform_input, ...])

LogErrorPipeline()

Pipeline to transform error

LogStandardPipeline()

LogTransformer()

Log-transform a variable.

MetadataManager()

NoOpPipeline()

SquareTransformer()

Square a variable.

StandardErrorPipeline()

Pipeline to transform error

StandardPipeline()

StandardScaler(*[, with_mean, with_std])

Rescale a variable to have a mean of 0 and a standard deviation of 1.

TimePipeline()

TimeTransformer()

Convert a datetime to decimal year.

UnitPipeline()

UnitScaler([zero_value])

Rescale a variable to have a minimum of 0 and a maximum of 1.

class discontinuum.pipeline.BaseTransformer#

Base class for transformers.

class discontinuum.pipeline.ClipTransformer(min: float = None, max: float = None)#

Clip a variable.

class discontinuum.pipeline.ErrorPipeline(steps, *, transform_input=None, memory=None, verbose=False)#
abstractmethod ci(mean, se, ci=0.95)#

Calculate confidence interval for a variable.

Parameters:
  • mean (float) – Mean of the variable.

  • se (float) – Standard error of the variable.

  • ci (float) – Confidence level.

Returns:

lower, upper – Lower and upper bound of the confidence interval.

Return type:

Tuple[float, float]

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') ErrorPipeline#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

selfobject

The updated object.

class discontinuum.pipeline.LogErrorPipeline#

Pipeline to transform error

inverse_transform converts variance (in log space) to a GSE

ci(mean, se, ci=0.95)#

Calculate confidence interval for a log-transformed variable.

Parameters:
  • mean (float) – Mean of the variable.

  • se (float) – Standard error of the variable.

  • ci (float) – Confidence level.

Returns:

lower, upper – Lower and upper bound of the confidence interval.

Return type:

Tuple[float, float]

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') LogErrorPipeline#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

selfobject

The updated object.

class discontinuum.pipeline.LogStandardPipeline#
set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') LogStandardPipeline#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

selfobject

The updated object.

class discontinuum.pipeline.LogTransformer#

Log-transform a variable.

class discontinuum.pipeline.MetadataManager#
fit(X, y=None)#

Store metadata from a xarray DataArray.

Parameters:
  • X (DataArray)

  • y (None) – Ignored.

inverse_transform(X)#

Add xarray metadata to a numpy array.

Parameters:

X (Numpy array)

Return type:

DataArray

transform(X)#

Extract values (numpy array) from xarray DataArray

Parameters:

X (DataArray)

Return type:

Numpy array

class discontinuum.pipeline.NoOpPipeline#
set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') NoOpPipeline#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

selfobject

The updated object.

class discontinuum.pipeline.SquareTransformer#

Square a variable.

class discontinuum.pipeline.StandardErrorPipeline#

Pipeline to transform error

inverse_transform converts variance to SE.

ci(mean, se, ci=0.95)#

Calculate confidence interval for a standard variable.

Parameters:
  • mean (float) – Mean of the variable.

  • se (float) – Standard error of the variable.

  • ci (float) – Confidence level.

Returns:

lower, upper – Lower and upper bound of the confidence interval.

Return type:

Tuple[float, float]

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') StandardErrorPipeline#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

selfobject

The updated object.

class discontinuum.pipeline.StandardPipeline#
set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') StandardPipeline#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

selfobject

The updated object.

class discontinuum.pipeline.StandardScaler(*, with_mean=True, with_std=True)#

Rescale a variable to have a mean of 0 and a standard deviation of 1.

Reimplemens the sklearn.preprocessing.StandardScaler but removes the requirement of having 2D arrays.

class discontinuum.pipeline.TimePipeline#
set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') TimePipeline#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

selfobject

The updated object.

class discontinuum.pipeline.TimeTransformer#

Convert a datetime to decimal year.

class discontinuum.pipeline.UnitPipeline#
set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') UnitPipeline#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

selfobject

The updated object.

class discontinuum.pipeline.UnitScaler(zero_value=0)#

Rescale a variable to have a minimum of 0 and a maximum of 1.

discontinuum.pipeline.datetime_to_decimal_year(x: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]#

Convert a timeseries to decimal year.

Parameters:

x (DataArray) – Timeseries to convert.

Returns:

Decimal year array.

Return type:

ArrayLike

discontinuum.pipeline.decimal_year_to_datetime(x: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]#

Convert a decimal year to a datetime.

Parameters:

x (ArrayLike) – Decimal year to convert.

Returns:

Datetime array.

Return type:

ArrayLike