KNNPowerCurve

K-nearest neighbors (KNN) based power curve estimation.

from dwse import KNNPowerCurve
model = KNNPowerCurve()
model.fit(X_train, y_train)
prediction = model.predict(X_test)
model.update(X_update, y_update)
prediction = model.predict(X_test_new)
class dswe.knn.KNNPowerCurve(algorithm='auto', weights='uniform', subset_selection=False)[source]
Parameters
  • algorithm (list) – Algorithm used to compute the nearest neighbors. ‘auto’ attempt to decide the most appropriate algorithm based on the values passed to ‘fit’ method. Default is ‘auto’.

  • weights (list) – Weight function used in prediction. Can take either ‘uniform’ or ‘distance’. ‘uniform’ means uniform weights i.e., all points in each neighborhood are weighted equally. ‘distance’ means weight points by the inverse of their distance. Default is ‘uniform’.

  • subset_selection (bool) – A boolean (True/False) to select the best feature columns. Default is set to False.

fit(X_train, y_train)[source]
Parameters
  • X_train (np.ndarray or pd.DataFrame) – A matrix or dataframe of input variable values in the training dataset.

  • y_train (np.array) – A numeric array for response values in the training dataset.

Returns

self with trained parameter values.

Return type

KNNPowerCurve

predict(X_test)[source]
Parameters

X_test (np.ndarray or pd.DataFrame) – A matrix or dataframe of input variable values in the test dataset.

Returns

A numeric array for predictions at the data points in the test dataset.

Return type

np.array

update(X_update, y_update)[source]
Parameters
  • X_update (np.ndarray or pd.DataFrame) – A matrix or dataframe of input variable values in the new added dataset.

  • y_update (np.array) – A numeric array for response values in the new added dataset.

Returns

self with updated trained parameter values.

Return type

KNNPowerCurve