nearest_neighbors_regressor#
Provides a nearest neighbors regressor, which predicts next timesteps.
- class NearestNeighborsConfig(name: str = 'Nearest Neighbors Regressor', normalize: bool = True, n_neighbors: int = 5, weights: Weights = Weights.uniform)#
Bases:
SkLearnModelConfigDefines the configuration for the NearestNeighborsRegressor.
- name#
name of the model.
- Type:
str
- n_neighbors#
number of neighbors to use.
- Type:
int
- weights#
function to weight neighbors.
- class NearestNeighborsRegressorModel(time_series_params: TimeSeriesConfig, model_params: NearestNeighborsConfig)#
Bases:
SkLearnModelDefines a model, which uses a nearest neighbors regressor.
Initializes the configuration for the DecisionTreeRegressor.
- Parameters:
time_series_params – Time-series parameters that affect the training and architecture of models
model_params – configuration for the model.
- get_model(model_params: NearestNeighborsConfig) BaseEstimator#
Returns the model.
- Parameters:
model_params – configuration for the model.
- Returns:
The model.
- property name: str#
Returns the models name.
- Returns:
The models name.
- predict(data: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]#
Predicts the next time steps.
- Parameters:
data – 3 dimensional numpy array.
- Returns:
The predicted next time steps.
- train(train: list[numpy.ndarray[Any, numpy.dtype[numpy.float64]]]) None#
Trains the model with the train data flattened to two dimensions.
- Parameters:
train – training data.
- validate_prediction_input(data: ndarray[Any, dtype[float64]]) None#
Validates the input of the predict function.
- Parameters:
data – a single dataframe containing the input data, where the output will be predicted.
- Raises:
ValueError – if data has incorrect shape (row length does not equal )
- class Weights(value)#
Bases:
EnumThe function to weight the neighbors.
- distance = '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.
- uniform = 'uniform'#
All points in each neighborhood are weighted equally.