class_docstr: K-Nearest Neighbors regressor.
  
  Samples are stored using a first-in, first-out strategy. The strategy to perform search
  queries in the data buffer is defined by the `engine` parameter. Predictions are obtained by
  aggregating the values of the closest n_neighbors stored samples with respect to a query sample.
  
  Parameters
  ----------
  n_neighbors
      The number of nearest neighbors to search for.
  engine
      The search engine used to store the instances and perform search queries. Depending
      on the choose engine, search will be exact or approximate. Please, consult the
      documentation of each available search engine for more details on its usage.
      By default, use the `SWINN` search engine for approximate search queries.
  aggregation_method
      The method to aggregate the target values of neighbors.
          | 'mean'
          | 'median'
          | 'weighted_mean'
  
  Examples
  --------
  >>> from river import datasets
  >>> from river import evaluate
  >>> from river import metrics
  >>> from river import neighbors
  >>> from river import preprocessing
  
  >>> dataset = datasets.TrumpApproval()
  
  >>> model = neighbors.KNNRegressor()
  >>> evaluate.progressive_val_score(dataset, model, metrics.RMSE())
  RMSE: 1.427743
class_docstr_tok: ["K-Nearest","Neighbors","regressor",".","Samples","are","stored","using","a","first-in",",","first-out","strategy",".","The","strategy","to","perform","search","queries","in","the","data","buffer","is","defined","by","the","`","engine","`","parameter",".","Predictions","are","obtained","by","aggregating","the","values","of","the","closest","n_neighbors","stored","samples","with","respect","to","a","query","sample",".","Parameters","--","--","--","--","--","n_neighbors","The","number","of","nearest","neighbors","to","search","for",".","engine","The","search","engine","used","to","store","the","instances","and","perform","search","queries",".","Depending","on","the","choose","engine",",","search","will","be","exact","or","approximate",".","Please",",","consult","the","documentation","of","each","available","search","engine","for","more","details","on","its","usage",".","By","default",",","use","the","`","SWINN","`","search","engine","for","approximate","search","queries",".","aggregation_method","The","method","to","aggregate","the","target","values","of","neighbors",".","|","'mean'","|","'median'","|","'weighted_mean'","Examples","--","--","--","--",">",">",">","from","river","import","datasets",">",">",">","from","river","import","evaluate",">",">",">","from","river","import","metrics",">",">",">","from","river","import","neighbors",">",">",">","from","river","import","preprocessing",">",">",">","dataset","=","datasets.TrumpApproval","(",")",">",">",">","model","=","neighbors.KNNRegressor","(",")",">",">",">","evaluate.progressive_val_score","(","dataset",",","model",",","metrics.RMSE","(",")",")","RMSE",":","1.427743"]
docstr: Ensure validation method is known to the model.
  
  Raises a ValueError if not.
  
  Parameters
  ----------
  method
      The suplied aggregration method.
docstr_tok: ["Ensure","validation","method","is","known","to","the","model",".","Raises","a","ValueError","if","not",".","Parameters","--","--","--","--","--","method","The","suplied","aggregration","method","."]
code: def _check_aggregation_method(self, method):
      """Ensure validation method is known to the model.
  
      Raises a ValueError if not.
  
      Parameters
      ----------
      method
          The suplied aggregration method.
      """
      if method not in {self._MEAN, self._MEDIAN, self._WEIGHTED_MEAN}:
          raise ValueError(
              f"Invalid aggregation_method: {method}.\n"
              f"Valid options are: {(self._MEAN, self._MEDIAN, self._WEIGHTED_MEAN)}"
          )
  
file_path: river/river/neighbors/knn_regressor.py
imports: from __future__ import annotations
  import functools
  import statistics
  from river import base, utils
  from river.neighbors import SWINN
  from .base import BaseNN, FunctionWrapper
label_desc: Use image node_id 3 for calling the KNNRegressor obj's underlying member method code with example usage: obj._check_aggregation_method(method) without return types