Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] k-nearest neighbors regressor: support for non-brute algorithms and non-precomputed mode to improve memory efficiency #6217

Merged
merged 3 commits into from Apr 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions sktime/regression/distance_based/_time_series_neighbors.py
Expand Up @@ -246,3 +246,40 @@ def _predict(self, X):
y_pred = self.knn_estimator_.predict(dist_mat)

return y_pred

@classmethod
def get_test_params(cls, parameter_set="default"):
"""Return testing parameter settings for the estimator.

Parameters
----------
parameter_set : str, default="default"
Name of the set of test parameters to return, for use in tests. If no
special parameters are defined for a value, will return ``"default"`` set.

Returns
-------
params : dict or list of dict, default={}
Parameters to create testing instances of the class.
Each dict are parameters to construct an "interesting" test instance, i.e.,
``MyClass(**params)`` or ``MyClass(**params[i])`` creates a valid test
instance.
``create_test_instance`` uses the first (or only) dictionary in ``params``.
"""
param1 = {
"n_neighbors": 1,
"weights": "uniform",
"algorithm": "auto",
"distance": "euclidean",
"distance_params": None,
"n_jobs": None,
}
param2 = {
"n_neighbors": 3,
"weights": "distance",
"algorithm": "ball_tree",
"distance": "dtw",
"distance_params": {"window": 0.5},
"n_jobs": -1,
}
return [param1, param2]