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: SkLearnModelConfig

Defines 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.

Type:

simba_ml.prediction.time_series.models.sk_learn.nearest_neighbors_regressor.Weights

class NearestNeighborsRegressorModel(time_series_params: TimeSeriesConfig, model_params: NearestNeighborsConfig)#

Bases: SkLearnModel

Defines 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: Enum

The 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.