RangeCut#
- class chemotools.feature_selection.RangeCut(start: int = 0, end: int = -1, x_axis: ndarray | None = None, wavenumbers='deprecated')[source]
Bases:
XAxisMixin,SelectorMixin,BaseEstimatorSelect a contiguous spectral region by index or by x-axis value.
The range can be specified in two ways:
By integer indices (
startandend)- By x-axis values (
startandendinterpreted against the provided x_axisarray)
- By x-axis values (
If
x_axisis supplied, the closest indices to the given start / end x-axis values are located. Otherwise numericstart/endare treated directly as indices. X-axis values must be in ascending order.- Parameters:
start (int, default=0) – Index or x-axis value of the start of the range.
end (int, default=-1) – Index or x-axis value of the end of the range.
x_axis (array-like, optional) – X-axis values corresponding to columns. Must be ascending if provided.
wavenumbers (array-like, optional) – Deprecated alias for
x_axis. Usex_axisinstead.
- Variables:
Examples
>>> from chemotools.feature_selection import RangeCut >>> from chemotools.datasets import load_fermentation_train >>> X, _ = load_fermentation_train() >>> wavenumbers = X.columns.values >>> rc = RangeCut(start=1000, end=2000, x_axis=wavenumbers) >>> rc.fit(X) RangeCut(start=1000, end=2000, x_axis=wavenumbers) >>> X_cut = rc.transform(X) >>> X_cut.shape (21, 616)