KNeighborsTimeSeriesClassifierTslearnSKTimeWrapper
Python template · sinapsis_sktime.templates.sktime_classifiers
Overview
Template for SkTime classification model training and inference for the distance_based module.
KNeighborsTimeSeriesClassifierTslearn — inherited documentation
K-nearest neighbors Time Series Classifier, from tslearn.
Direct interface to ``tslearn.neighbors.KNeighborsTimeSeriesClassifier``.
Parameters ---------- n_neighbors : int (default: 5) Number of nearest neighbors to be considered for the decision.
weights : str or callable, optional (default: 'uniform') Weight function used in prediction. Possible values:
- 'uniform' : uniform weights. All points in each neighborhood are weighted equally. - 'distance' : weight points by the inverse of their distance. in this case, closer neighbors of a query point will have a greater influence than neighbors which are further away. - [callable] : a user-defined function which accepts an array of distances, and returns an array of the same shape containing the weights.
metric : {'dtw', 'softdtw', 'ctw', 'euclidean', 'sqeuclidean', 'cityblock', 'sax'} default: 'dtw'. Metric to be used at the core of the nearest neighbor procedure. When ``'sax'`` is provided as a metric, the data is expected to be normalized such that each time series has zero mean and unit variance. ``'euclidean'``, ``'sqeuclidean'``, ``'cityblock'`` are described in `scipy.spatial.distance doc <https://docs.scipy.org/doc/scipy/reference/spatial.distance.html>`_.
metric_params : dict or None (default: None) Dictionary of metric parameters. For metrics that accept parallelization of the cross-distance matrix computations, ``n_jobs`` and ``verbose`` keys passed in ``metric_params`` are overridden by the ``n_jobs`` and ``verbose`` arguments. For ``'sax'`` metric, these are hyper-parameters to be passed at the creation of the ``SymbolicAggregateApproximation`` object.
n_jobs : int or None, optional (default=None) The number of jobs to run in parallel for cross-distance matrix computations. Ignored if the cross-distance matrix cannot be computed using parallelization. ``None`` means 1 unless in a ``joblib.parallel_backend`` context. ``-1`` means using all processors.
verbose : int, optional (default=0) The verbosity level: if non zero, progress messages are printed. Above 50, the output is sent to stdout. The frequency of the messages increases with the verbosity level. If it more than 10, all iterations are reported.
Examples -------- >>> from sktime.classification.distance_based import ( ... KNeighborsTimeSeriesClassifierTslearn ... ) >>> from sktime.datasets import load_unit_test >>> X_train, y_train = load_unit_test(split="train") >>> X_test, y_test = load_unit_test(split="test") >>> clf = KNeighborsTimeSeriesClassifierTslearn( ... n_neighbors=5, ... weights="uniform", ... metric="dtw", ... metric_params=None, ... n_jobs=None, ... verbose=0, ... ) >>> clf.fit(X_train, y_train) KNeighborsTimeSeriesClassifierTslearn(...) >>> y_pred = clf.predict(X_test)
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-sktime==1.0.0uv pip install sinapsis-sktime==1.0.0uv add sinapsis-sktime==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Optional
Default: null
Optional
Default: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
Path where the trained model will be saved. kneighborstimeseriesclassifiertslearn_init n_neighbors <class 'int'>: default: 5 weights <class 'str'>: default: uniform metric typing.Union[str, typing.Any, NoneType]:… Read full field description
Path where the trained model will be saved. kneighborstimeseriesclassifiertslearn_init n_neighbors <class 'int'>: default: 5 weights <class 'str'>: default: uniform metric typing.Union[str, typing.Any, NoneType]: default: dtw metric_params <class 'NoneType'>: default: None n_jobs typing.Optional[int]: default: None verbose <class 'int'>: default: 0
Required
Default: null
Required
Default: null
Optional
Default: "dtw"
Optional
Default: null
Optional
Default: 0
Optional
Default: "uniform"
Optional
Default: 5
Optional
Default: null
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "KNeighborsTimeSeriesClassifierTslearnSKTimeWrapper"
class_name: "KNeighborsTimeSeriesClassifierTslearnSKTimeWrapper"
attributes:
root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
model_save_path: "<required>"
kneighborstimeseriesclassifiertslearn_init:
metric: "dtw"
n_jobs: null
verbose: 0
weights: "uniform"
n_neighbors: 5
metric_params: null
Inheritance
sinapsis_sktime.templates.sktime_classifiers.SKTimeDistanceClassifiersEnvironment variables
Environment definitions belong to their canonical Python modules.