skfolio.descriptor.ChangeInIntensity#

class skfolio.descriptor.ChangeInIntensity(field, scale_field, lag)[source]#

Lagged change in a field-to-scale ratio.

Computes the change in the ratio \(A/S\) over a fixed lag:

\[\text{ChangeInIntensity}_\ell(t) = \frac{A(t)}{S(t)} - \frac{A(t - \ell)}{S(t - \ell)}\]

where \(A\) is the field value and \(S\) is the scale_field value.

The first lag observations are NaN because no lagged history is available.

This descriptor is appropriate when the economic concept of interest is the ratio itself, such as capex/assets, R&D/sales or a margin, and whether that ratio improved or deteriorated over the lag window. NaNs are allowed as missing observations and propagate when the current, lagged or scale value is missing.

Non-missing numerator values must be finite. Non-missing scale values must be finite and strictly positive. A ValueError is raised otherwise.

Parameters:
fieldstr

Field name in the AssetPanel used as numerator \(A\). Non-missing values must be finite.

scale_fieldstr

Field name in the AssetPanel used as denominator \(S\). Non-missing values must be finite and strictly positive.

lagint

Number of observations to look back. The interpretation depends on the data frequency: lag=12 means 1 year for monthly data, lag=252 for daily data, lag=4 for quarterly data.

Attributes:
n_assets_int

Number of assets seen during fitting.

asset_names_ndarray of shape (n_assets,)

Asset names seen during fitting.

change_in_intensity_ndarray of shape (n_assets,)

Last change-in-intensity value for each asset.

Methods

fit_transform(X[, y])

Compute changes in the intensity ratio over the configured lag.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

partial_fit_transform(X[, y])

Compute changes in the intensity ratio over the configured lag.

set_params(**params)

Set the parameters of this estimator.

See also

ChangeToScale

Change in \(A\) normalized by current \(S\).

GrowthRate

Simple growth rate for positive-definite characteristics.

Examples

>>> from skfolio.descriptor import ChangeInIntensity
>>>
>>> # Capex intensity change (capex / total_assets)
>>> capex_int = ChangeInIntensity("capex_ttm", "total_assets", lag=12)
>>>
>>> # R&D intensity change (R&D / sales)
>>> rd_int = ChangeInIntensity("rd_ttm", "sales_ttm", lag=12)
fit_transform(X, y=None, **fit_params)[source]#

Compute changes in the intensity ratio over the configured lag.

Parameters:
XAssetPanel

Input panel containing the field and scale_field characteristics configured at construction.

yNone

Ignored. Present for compatibility with scikit-learn’s API.

**fit_paramsdict

Additional fit parameters. Ignored.

Returns:
change_in_intensityndarray of shape (n_observations, n_assets)

Change in field / scale_field over the lag window for each observation and asset.

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.

partial_fit_transform(X, y=None, **fit_params)[source]#

Compute changes in the intensity ratio over the configured lag.

This method supports online updates by continuing from the current fitted state. Use fit_transform to start from a clean state.

Parameters:
XAssetPanel

Input panel containing the field and scale_field fields configured at construction.

yNone

Ignored. Present for compatibility with scikit-learn’s API.

**fit_paramsdict

Additional fit parameters. Ignored.

Returns:
change_in_intensityndarray of shape (n_observations, n_assets)

Change in field / scale_field over the lag window for each observation and asset.

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.