XAxisInterpolator#
- class chemotools.adaptation.XAxisInterpolator(common_x_axis: ndarray, method: str = 'cubic', left=nan, right=nan)[ソース]
ベースクラス:
DocLinkMixin,TransformerMixin,BaseEstimatorInterpolate every row of
Xonto a sharedcommon_x_axis.The transformer resamples each row of
Xfrom a sample-specific (or shared) input gridx_axisonto a fixedcommon_x_axisprovided at instantiation time.x_axisis consumed as metadata so it flows correctly throughPipeline,ColumnTransformer,GridSearchCV,cross_validateetc., once metadata routing is enabled via:sklearn.set_config(enable_metadata_routing=True).- パラメータ:
common_x_axis (array-like of shape (n_output_features,)) -- Strictly increasing target grid.
transformreturns an array withn_output_featurescolumns.method (str, default="cubic") -- The interpolation mode. One of:
"linear","cubic"or"pchip".left (float, default=np.nan) -- Value returned for query points below the input grid (passed to
numpy.interp()).right (float, default=np.nan) -- Value returned for query points above the input grid.
- 変数:
common_x_axis (ndarray of shape (n_output_features,)) -- Validated copy of
common_x_axis.n_features_in (int) -- Number of input features seen during
fit.feature_names_in (ndarray of shape (
n_features_in_,)) -- Names of features seen duringfit(only ifXhad names).
- fit(X: ndarray, y=None, x_axis=None) XAxisInterpolator[ソース]
Validate input and the configured
common_x_axis.- パラメータ:
X (array-like of shape (n_samples, n_features)) -- The input data to fit the transformer to.
y (Ignored) -- Ignored to align with API.
x_axis (Ignored) -- Accepted only so that metadata routing through
fit_transform(used byPipeline) generates aset_fit_requestmethod.fititself does not use it.
- 戻り値:
self
- 戻り値の型:
- transform(X: ndarray, x_axis=None)[ソース]
Interpolate
Xfromx_axisontocommon_x_axis_.x_axisis metadata and must be requested explicitly viaset_transform_request(x_axis=True)for routing to work in aPipeline/GridSearchCV.- パラメータ:
X (array-like of shape (n_samples, n_features)) -- Signal values sampled on
x_axis.x_axis (array-like, required metadata) -- Either shape
(n_features,)(shared grid for every row) or(n_samples, n_features)(per-row grid). Must be strictly increasing along the feature axis.
- 戻り値:
X_transformed
- 戻り値の型:
ndarray of shape (n_samples, n_output_features)
- fit_transform(X, y=None, **fit_params)[ソース]
Fit to data, then transform it.
fitdoes not consumex_axis; onlytransformdoes. This custom implementation ensuresx_axisis forwarded only totransform, not tofit.- パラメータ:
X (array-like of shape (n_samples, n_features))
y (Ignored)
x_axis (array-like, optional metadata) -- Input grid for interpolation, forwarded to
transform.
- 戻り値:
X_new
- 戻り値の型:
ndarray of shape (n_samples, n_output_features)
- get_feature_names_out(input_features=None)[ソース]
Names are the positions of the common grid.
- set_fit_request(*, x_axis: bool | None | str = '$UNCHANGED$') XAxisInterpolator
Configure whether metadata should be requested to be passed to the
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.
- set_transform_request(*, x_axis: bool | None | str = '$UNCHANGED$') XAxisInterpolator
Configure whether metadata should be requested to be passed to the
transformmethod.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(seesklearn.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 totransformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it totransform.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.