OccupationMeasureTransformer#
- class skfda.preprocessing.feature_construction.OccupationMeasureTransformer(intervals, *, n_points=None)[source]#
Transformer that works as an adapter for the occupation_measure function.
- Parameters:
intervals (Sequence[Tuple[float, float]]) – ndarray of tuples containing the intervals we want to consider. The shape should be (n_sequences, 2)
n_points (Optional[int]) – Number of points to evaluate in the domain. By default will be used the points defined on the FDataGrid. On a FDataBasis this value should be specified.
Example
We will create the FDataGrid that we will use to extract the occupation measure >>> from skfda.representation import FDataGrid >>> import numpy as np >>> t = np.linspace(0, 10, 100) >>> fd_grid = FDataGrid( … data_matrix=[ … t, … 2 * t, … np.sin(t), … ], … grid_points=t, … )
Finally we call to the occupation measure function with the intervals that we want to consider. In our case (0.0, 1.0) and (2.0, 3.0). We need also to specify the number of points we want that the function takes into account to interpolate. We are going to use 501 points. >>> from skfda.preprocessing.feature_construction import ( … OccupationMeasureTransformer, … ) >>> occupation_measure = OccupationMeasureTransformer( … intervals=[(0.0, 1.0), (2.0, 3.0)], … n_points=501, … )
>>> np.around(occupation_measure.fit_transform(fd_grid), decimals=2) array([[ 0.98, 1. ], [ 0.5 , 0.52], [ 6.28, 0. ]])
Methods
fit
(X[, y])fit_transform
(X[, y])Fit to data, then transform it.
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
set_output
(*[, transform])Set output container.
set_params
(**params)Set the parameters of this estimator.
transform
(X[, y])Transform the provided data using the occupation_measure function.
- fit(X, y=None)[source]#
- Parameters:
self (SelfType) –
X (Input) –
y (Target | None) –
- Return type:
SelfType
- fit_transform(X, y=None, **fit_params)[source]#
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Input samples.
y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) – Target values (None for unsupervised transformations).
**fit_params (dict) – Additional fit parameters.
- Returns:
X_new – Transformed array.
- Return type:
ndarray array of shape (n_samples, n_features_new)
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)#
Get parameters for this estimator.
- set_output(*, transform=None)#
Set output container.
See Introducing the set_output API for an example on how to use the API.
- Parameters:
transform ({"default", "pandas"}, default=None) –
Configure output of transform and fit_transform.
”default”: Default output format of a transformer
”pandas”: DataFrame output
”polars”: Polars output
None: Transform configuration is unchanged
New in version 1.4: “polars” option was added.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- 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:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance