knnregressorpredict

Predicts target values for the test data points using parameters computed by knnregressorfit function.

Attention: Available only with Activate commercial edition.

Syntax

predictions = knnregressorpredict(parameters,X)

Inputs

parameters
Output of knnregressorfit function.
Type: struct
X
Test data.
Type: double
Dimension: vector | matrix

Outputs

predictions
Predictions for the test data.
Type: double
Dimension: vector | matrix

Example

Usage of knnregressorpredict

X = [0; 1; 2; 3];
y = [0; 0; 1; 1];
options = struct;
options.n_neighbors = 2;
parameters = knnregressorfit(X, y, options);
predictions = knnregressorpredict(parameters, [1.5]);
disp(predictions);
0.5

Comments

It performs regression based on K Nearest Neighbors algorithm. Once the neighbors are found, target is predicted using aggregation of nearest neighbors.