************************************** :py:mod:`wildboar.dimension_selection` ************************************** .. py:module:: wildboar.dimension_selection .. autoapi-nested-parse:: Select a subset of dimensions .. !! processed by numpydoc !! Classes ------- .. autoapisummary:: wildboar.dimension_selection.DistanceVarianceThreshold wildboar.dimension_selection.ECSSelector wildboar.dimension_selection.SelectDimensionPercentile wildboar.dimension_selection.SelectDimensionSignificance wildboar.dimension_selection.SelectDimensionTopK wildboar.dimension_selection.SequentialDimensionSelector .. raw:: html
.. py:class:: DistanceVarianceThreshold(threshold=0, *, sample=None, metric='euclidean', metric_params=None, random_state=None, n_jobs=None) Distance selector that removes dimensions with low variance. This dimension selector is suitable for unsupervised learning since it only considers the input data and not the labels. For each dimension, the pairwise distance between time series is computed and dimensions with variance below the specified threshold are removed. :Parameters: **threshold** : float, optional The variance threshold. **sample** : int or float, optional Draw a sample of time series for the pairwise distance calculation. - If None, use all samples. - If float, use the specified fraction of samples. - If int, use the specified number of samples. **metric** : str, optional The distance metric. **metric_params** : dict, optional Optional parameters to the distance metric. Read more about the metrics and their parameters in the :ref:`User guide `. **random_state** : int or RandomState, optional Controls the random sampling of kernels. - If `int`, `random_state` is the seed used by the random number generator. - If :class:`numpy.random.RandomState` instance, `random_state` is the random number generator. - If `None`, the random number generator is the :class:`numpy.random.RandomState` instance used by :func:`numpy.random`. **n_jobs** : int, optional The number of parallel jobs. .. rubric:: Examples >>> from wildboar.datasets import load_ering >>> from wildboar.dimension_selection import DistanceVarianceThreshold >>> X, y = load_ering() >>> dv = DistanceVarianceThreshold(threshold=9) >>> dv.fit(X, y) DistanceVarianceThreshold(threshold=9) >>> dv.get_dimensions() array([ True, False, True, True]) >>> dv.transform(X).shape .. !! processed by numpydoc !! .. py:method:: fit(X, y=None) Learn the dimensions to select. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The training samples. **y** : array-like of shape (n_samples, ), optional Ignored. :Returns: object The instance itself. .. !! processed by numpydoc !! .. py:method:: fit_transform(X, y=None, **fit_params) 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** : ndarray array of shape (n_samples, n_features_new) Transformed array. .. !! processed by numpydoc !! .. py:method:: get_dimensions(indices=False) Get a boolean mask with the selected dimensions. :Parameters: **indices** : bool, optional If True, return the indices instead of a boolean mask. :Returns: ndarray of shape (n_selected_dims, ) An index that selects the retained dimensions. .. !! processed by numpydoc !! .. py:method:: get_metadata_routing() Get metadata routing of this object. Please check :ref:`User Guide ` on how the routing mechanism works. :Returns: **routing** : MetadataRequest A :class:`~sklearn.utils.metadata_routing.MetadataRequest` encapsulating routing information. .. !! processed by numpydoc !! .. py:method:: get_params(deep=True) Get parameters for this estimator. :Parameters: **deep** : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. :Returns: **params** : dict Parameter names mapped to their values. .. !! processed by numpydoc !! .. py:method:: inverse_transform(X) Reverse the transformation. :Parameters: **X** : array-like of shape (n_samples, n_selected_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_dims, n_timestep) The samples with zeros inserted where dimensions would have been removed by :meth:`transform`. .. !! processed by numpydoc !! .. py:method:: set_output(*, transform=None) Set output container. See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py` for an example on how to use the API. :Parameters: **transform** : {"default", "pandas", "polars"}, 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 .. versionadded:: 1.4 `"polars"` option was added. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: set_params(**params) Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``__`` so that it's possible to update each component of a nested object. :Parameters: **\*\*params** : dict Estimator parameters. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: transform(X) Reduce X to the selected dimensions. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_selected_dims, n_timestep) The samples with only the selected dimensions. .. !! processed by numpydoc !! .. py:class:: ECSSelector(prototype='mean', r=None, metric='euclidean', metric_params=None) ElbowClassSum (ECS) dimension selector. Select time series dimensions based on the sum of distances between pairs of classes. :Parameters: **prototype** : {"mean", "median", "dtw"}, optional The method for computing the class prototypes. **r** : float, optional The warping width if `prototype` is "dtw". **metric** : str, optional The distance metric. **metric_params** : dict, optional Optional parameters to the distance metric. Read more about the metrics and their parameters in the :ref:`User guide `. .. !! processed by numpydoc !! .. py:method:: fit(X, y) Learn the dimensions to select. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The training samples. **y** : array-like of shape (n_samples, ) Ignored. :Returns: object The instance itself. .. !! processed by numpydoc !! .. py:method:: fit_transform(X, y=None, **fit_params) 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** : ndarray array of shape (n_samples, n_features_new) Transformed array. .. !! processed by numpydoc !! .. py:method:: get_dimensions(indices=False) Get a boolean mask with the selected dimensions. :Parameters: **indices** : bool, optional If True, return the indices instead of a boolean mask. :Returns: ndarray of shape (n_selected_dims, ) An index that selects the retained dimensions. .. !! processed by numpydoc !! .. py:method:: get_metadata_routing() Get metadata routing of this object. Please check :ref:`User Guide ` on how the routing mechanism works. :Returns: **routing** : MetadataRequest A :class:`~sklearn.utils.metadata_routing.MetadataRequest` encapsulating routing information. .. !! processed by numpydoc !! .. py:method:: get_params(deep=True) Get parameters for this estimator. :Parameters: **deep** : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. :Returns: **params** : dict Parameter names mapped to their values. .. !! processed by numpydoc !! .. py:method:: inverse_transform(X) Reverse the transformation. :Parameters: **X** : array-like of shape (n_samples, n_selected_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_dims, n_timestep) The samples with zeros inserted where dimensions would have been removed by :meth:`transform`. .. !! processed by numpydoc !! .. py:method:: set_output(*, transform=None) Set output container. See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py` for an example on how to use the API. :Parameters: **transform** : {"default", "pandas", "polars"}, 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 .. versionadded:: 1.4 `"polars"` option was added. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: set_params(**params) Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``__`` so that it's possible to update each component of a nested object. :Parameters: **\*\*params** : dict Estimator parameters. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: transform(X) Reduce X to the selected dimensions. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_selected_dims, n_timestep) The samples with only the selected dimensions. .. !! processed by numpydoc !! .. py:class:: SelectDimensionPercentile(score_func=f_classif, *, sample=None, percentile=10, metric='euclidean', metric_params=None, n_jobs=None, random_state=None) Select the fraction of dimensions with largest score. For each dimension, the pairwise distance between time series is computed and dimensions with the lowest scores are removed. :Parameters: **score_func** : callable, optional Function taking two arrays X and y and returning scores and optionally p-values. The default is :func:`~sklearn.feature_selection.f_classif`. **sample** : int or float, optional Draw a sample of time series for the pairwise distance calculation. - If None, use all samples. - If float, use the specified fraction of samples. - If int, use the specified number of samples. **percentile** : float, optional Percent of dimensions to retain. **metric** : str, optional The distance metric. **metric_params** : dict, optional Optional parameters to the distance metric. Read more about the metrics and their parameters in the :ref:`User guide `. **random_state** : int or RandomState, optional Controls the random sampling of kernels. - If `int`, `random_state` is the seed used by the random number generator. - If :class:`numpy.random.RandomState` instance, `random_state` is the random number generator. - If `None`, the random number generator is the :class:`numpy.random.RandomState` instance used by :func:`numpy.random`. **random_state** : int or RandomState, optional Controls the random sampling of kernels. - If `int`, `random_state` is the seed used by the random number generator. - If :class:`numpy.random.RandomState` instance, `random_state` is the random number generator. - If `None`, the random number generator is the :class:`numpy.random.RandomState` instance used by :func:`numpy.random`. **n_jobs** : int, optional The number of parallel jobs. .. rubric:: Examples >>> from wildboar.datasets import load_ering >>> from wildboar.dimension_selection import SelectDimensionPercentile >>> X, y = load_ering() >>> sdp = SelectDimensionPercentile(percentile=50) >>> sdp.fit(X, y) SelectDimensionPercentile(percentile=50) >>> sdp.get_dimensions() array([False, False, True, True]) >>> sdp.transform(X).shape .. !! processed by numpydoc !! .. py:method:: fit(X, y=None) Learn the dimensions to select. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The training samples. **y** : array-like of shape (n_samples, ), optional Ignored. :Returns: object The instance itself. .. !! processed by numpydoc !! .. py:method:: fit_transform(X, y=None, **fit_params) 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** : ndarray array of shape (n_samples, n_features_new) Transformed array. .. !! processed by numpydoc !! .. py:method:: get_dimensions(indices=False) Get a boolean mask with the selected dimensions. :Parameters: **indices** : bool, optional If True, return the indices instead of a boolean mask. :Returns: ndarray of shape (n_selected_dims, ) An index that selects the retained dimensions. .. !! processed by numpydoc !! .. py:method:: get_metadata_routing() Get metadata routing of this object. Please check :ref:`User Guide ` on how the routing mechanism works. :Returns: **routing** : MetadataRequest A :class:`~sklearn.utils.metadata_routing.MetadataRequest` encapsulating routing information. .. !! processed by numpydoc !! .. py:method:: get_params(deep=True) Get parameters for this estimator. :Parameters: **deep** : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. :Returns: **params** : dict Parameter names mapped to their values. .. !! processed by numpydoc !! .. py:method:: inverse_transform(X) Reverse the transformation. :Parameters: **X** : array-like of shape (n_samples, n_selected_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_dims, n_timestep) The samples with zeros inserted where dimensions would have been removed by :meth:`transform`. .. !! processed by numpydoc !! .. py:method:: set_output(*, transform=None) Set output container. See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py` for an example on how to use the API. :Parameters: **transform** : {"default", "pandas", "polars"}, 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 .. versionadded:: 1.4 `"polars"` option was added. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: set_params(**params) Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``__`` so that it's possible to update each component of a nested object. :Parameters: **\*\*params** : dict Estimator parameters. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: transform(X) Reduce X to the selected dimensions. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_selected_dims, n_timestep) The samples with only the selected dimensions. .. !! processed by numpydoc !! .. py:class:: SelectDimensionSignificance(score_func=f_classif, *, sample=None, alpha=0.05, method='fpr', metric='euclidean', metric_params=None, random_state=None, n_jobs=None) Select dimensions with a p-value below `alpha`. For each dimension, the pairwise distance between time series is computed and dimensions with p-values above `alpha` is removed. :Parameters: **score_func** : callable, optional Function taking two arrays X and y and returning scores and optionally p-values. The default is :func:`~sklearn.feature_selection.f_classif`. **sample** : int or float, optional Draw a sample of time series for the pairwise distance calculation. - If None, use all samples. - If float, use the specified fraction of samples. - If int, use the specified number of samples. **alpha** : int, optional Percent of dimensions to retain. **method** : {"fpr", "fdr", "fwe"}, optional The method for correcting the alpha value. - If `"fpr"`, false positive rate, apply no correction. - If `"fdr"`, false discovery rate, apply the Benjamini-Hochberg procedure. - If `"fwer"`, family-wise error rate, apply the Bonferroni procedure. **metric** : str, optional The distance metric. **metric_params** : dict, optional Optional parameters to the distance metric. Read more about the metrics and their parameters in the :ref:`User guide `. **random_state** : int or RandomState, optional Controls the random sampling of kernels. - If `int`, `random_state` is the seed used by the random number generator. - If :class:`numpy.random.RandomState` instance, `random_state` is the random number generator. - If `None`, the random number generator is the :class:`numpy.random.RandomState` instance used by :func:`numpy.random`. **n_jobs** : int, optional The number of parallel jobs. .. rubric:: Examples >>> from wildboar.datasets import load_basic_motions >>> from wildboar.dimension_selection import SelectDimensionSignificance >>> X, y = load_basic_motions() >>> sds = SelectDimensionSignificance(alpha=0.01) >>> sds.fit(X, y) SelectDimensionSignificance(alpha=0.01) >>> sds.get_dimensions() array([ True, True, True, True, True, True]) >>> sds.transform(X).shape (80, 6, 100) .. !! processed by numpydoc !! .. py:method:: fit(X, y=None) Learn the dimensions to select. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The training samples. **y** : array-like of shape (n_samples, ), optional Ignored. :Returns: object The instance itself. .. !! processed by numpydoc !! .. py:method:: fit_transform(X, y=None, **fit_params) 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** : ndarray array of shape (n_samples, n_features_new) Transformed array. .. !! processed by numpydoc !! .. py:method:: get_dimensions(indices=False) Get a boolean mask with the selected dimensions. :Parameters: **indices** : bool, optional If True, return the indices instead of a boolean mask. :Returns: ndarray of shape (n_selected_dims, ) An index that selects the retained dimensions. .. !! processed by numpydoc !! .. py:method:: get_metadata_routing() Get metadata routing of this object. Please check :ref:`User Guide ` on how the routing mechanism works. :Returns: **routing** : MetadataRequest A :class:`~sklearn.utils.metadata_routing.MetadataRequest` encapsulating routing information. .. !! processed by numpydoc !! .. py:method:: get_params(deep=True) Get parameters for this estimator. :Parameters: **deep** : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. :Returns: **params** : dict Parameter names mapped to their values. .. !! processed by numpydoc !! .. py:method:: inverse_transform(X) Reverse the transformation. :Parameters: **X** : array-like of shape (n_samples, n_selected_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_dims, n_timestep) The samples with zeros inserted where dimensions would have been removed by :meth:`transform`. .. !! processed by numpydoc !! .. py:method:: set_output(*, transform=None) Set output container. See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py` for an example on how to use the API. :Parameters: **transform** : {"default", "pandas", "polars"}, 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 .. versionadded:: 1.4 `"polars"` option was added. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: set_params(**params) Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``__`` so that it's possible to update each component of a nested object. :Parameters: **\*\*params** : dict Estimator parameters. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: transform(X) Reduce X to the selected dimensions. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_selected_dims, n_timestep) The samples with only the selected dimensions. .. !! processed by numpydoc !! .. py:class:: SelectDimensionTopK(score_func=f_classif, *, sample=None, k=None, metric='euclidean', metric_params=None, random_state=None, n_jobs=None) Select the dimensions with the `k` highest scores. For each dimension, the pairwise distance between time series is computed and dimensions with the lowest scores are removed. :Parameters: **score_func** : callable, optional Function taking two arrays X and y and returning scores and optionally p-values. The default is :func:`~sklearn.feature_selection.f_classif`. **sample** : int or float, optional Draw a sample of time series for the pairwise distance calculation. - If None, use all samples. - If float, use the specified fraction of samples. - If int, use the specified number of samples. **k** : int, optional The number of top dimensions to select. **metric** : str, optional The distance metric. **metric_params** : dict, optional Optional parameters to the distance metric. Read more about the metrics and their parameters in the :ref:`User guide `. **random_state** : int or RandomState, optional Controls the random sampling of kernels. - If `int`, `random_state` is the seed used by the random number generator. - If :class:`numpy.random.RandomState` instance, `random_state` is the random number generator. - If `None`, the random number generator is the :class:`numpy.random.RandomState` instance used by :func:`numpy.random`. **n_jobs** : int, optional The number of parallel jobs. .. rubric:: Examples >>> from wildboar.datasets import load_ering >>> from wildboar.dimension_selection import SelectDimensionTopK >>> X, y = load_ering() >>> sdt = SelectDimensionTopK(k=1) >>> sdt.fit(X, y) SelectDimensionTopK(k=1) >>> sdt.get_dimensions() array([False, False, True, False]) >>> sdt.transform(X).shape (300, 65) .. !! processed by numpydoc !! .. py:method:: fit(X, y=None) Learn the dimensions to select. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The training samples. **y** : array-like of shape (n_samples, ), optional Ignored. :Returns: object The instance itself. .. !! processed by numpydoc !! .. py:method:: fit_transform(X, y=None, **fit_params) 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** : ndarray array of shape (n_samples, n_features_new) Transformed array. .. !! processed by numpydoc !! .. py:method:: get_dimensions(indices=False) Get a boolean mask with the selected dimensions. :Parameters: **indices** : bool, optional If True, return the indices instead of a boolean mask. :Returns: ndarray of shape (n_selected_dims, ) An index that selects the retained dimensions. .. !! processed by numpydoc !! .. py:method:: get_metadata_routing() Get metadata routing of this object. Please check :ref:`User Guide ` on how the routing mechanism works. :Returns: **routing** : MetadataRequest A :class:`~sklearn.utils.metadata_routing.MetadataRequest` encapsulating routing information. .. !! processed by numpydoc !! .. py:method:: get_params(deep=True) Get parameters for this estimator. :Parameters: **deep** : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. :Returns: **params** : dict Parameter names mapped to their values. .. !! processed by numpydoc !! .. py:method:: inverse_transform(X) Reverse the transformation. :Parameters: **X** : array-like of shape (n_samples, n_selected_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_dims, n_timestep) The samples with zeros inserted where dimensions would have been removed by :meth:`transform`. .. !! processed by numpydoc !! .. py:method:: set_output(*, transform=None) Set output container. See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py` for an example on how to use the API. :Parameters: **transform** : {"default", "pandas", "polars"}, 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 .. versionadded:: 1.4 `"polars"` option was added. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: set_params(**params) Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``__`` so that it's possible to update each component of a nested object. :Parameters: **\*\*params** : dict Estimator parameters. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: transform(X) Reduce X to the selected dimensions. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_selected_dims, n_timestep) The samples with only the selected dimensions. .. !! processed by numpydoc !! .. py:class:: SequentialDimensionSelector(estimator, *, n_dims='auto', cv=5, scoring=None, direction='forward', tol=None) Sequentially select a subset of dimensions. Sequentially select a set of dimensions by adding (forward) or removing (backward) dimensions to greedily form a subset. At each iteration, the algorithm chooses the best dimension to add or remove based on the cross validation score. :Parameters: **estimator** : estimator An unfitted estimator. **n_dims** : {"auto"} or int, optional The number of dimensions to select. If `"auto"`, the behavior depends on `tol`: - if `tol` is not `None`, dimensions are selected as long as the increase in performance is larger than `tol`. - otherwise, we select half of the dimensions. If integer, `n_dims` is the number of dimensions to select. **cv** : int, cross-validation generator or an iterable, optional The cross-validation splitting strategy. **scoring** : str or callable, optional A str (see: :ref:`sklearn:scoring_parameter`) or callable to evaluate the predictions on the test set. **direction** : {"forward", "backward"}, optional Backward of forward selection. **tol** : float, optional The tolerance. If the score is not increased by `tol` between two iterations, return. If `direction="backward"`, `tol` can be negative to reduce the number of dimensions. .. rubric:: Examples >>> from wildboar.datasets import load_ering >>> from wildboar.dimension_selection import SequentialDimensionSelector >>> from wildboar.distance import KNeighborsClassifier >>> X, y = load_ering() >>> clf = KNeighborsClassifier() >>> sds = SequentialDimensionSelector(clf, n_dims=2) >>> sds.fit(X, y) SequentialDimensionSelector(estimator=KNeighborsClassifier(), n_dims=2) >>> sds.get_dimensions() array([ True, False, False, True]) >>> sds.transform(X).shape (300, 2, 65) .. !! processed by numpydoc !! .. py:method:: fit(X, y) Learn the dimensions to select. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The training samples. **y** : array-like of shape (n_samples, ) The training labels. :Returns: object The instance itself. .. !! processed by numpydoc !! .. py:method:: fit_transform(X, y=None, **fit_params) 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** : ndarray array of shape (n_samples, n_features_new) Transformed array. .. !! processed by numpydoc !! .. py:method:: get_dimensions(indices=False) Get a boolean mask with the selected dimensions. :Parameters: **indices** : bool, optional If True, return the indices instead of a boolean mask. :Returns: ndarray of shape (n_selected_dims, ) An index that selects the retained dimensions. .. !! processed by numpydoc !! .. py:method:: get_metadata_routing() Get metadata routing of this object. Please check :ref:`User Guide ` on how the routing mechanism works. :Returns: **routing** : MetadataRequest A :class:`~sklearn.utils.metadata_routing.MetadataRequest` encapsulating routing information. .. !! processed by numpydoc !! .. py:method:: get_params(deep=True) Get parameters for this estimator. :Parameters: **deep** : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. :Returns: **params** : dict Parameter names mapped to their values. .. !! processed by numpydoc !! .. py:method:: inverse_transform(X) Reverse the transformation. :Parameters: **X** : array-like of shape (n_samples, n_selected_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_dims, n_timestep) The samples with zeros inserted where dimensions would have been removed by :meth:`transform`. .. !! processed by numpydoc !! .. py:method:: set_output(*, transform=None) Set output container. See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py` for an example on how to use the API. :Parameters: **transform** : {"default", "pandas", "polars"}, 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 .. versionadded:: 1.4 `"polars"` option was added. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: set_params(**params) Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``__`` so that it's possible to update each component of a nested object. :Parameters: **\*\*params** : dict Estimator parameters. :Returns: **self** : estimator instance Estimator instance. .. !! processed by numpydoc !! .. py:method:: transform(X) Reduce X to the selected dimensions. :Parameters: **X** : array-like of shape (n_samples, n_dims, n_timestep) The samples. :Returns: ndarray of shape (n_samples, n_selected_dims, n_timestep) The samples with only the selected dimensions. .. !! processed by numpydoc !!