knnclassifierpredict

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

Attention: Available only with Twin Activate commercial edition.

Syntax

predictions = knnclassifierpredict(parameters,X)

predictions = knnclassifierpredict(parameters,X)

Inputs

parameters
Output of knnClassifierFit 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 knnclassifierpredict

data = dlmread('digits.csv', ',');
X = data(:, 1:end-1);
y = data(:, end);

parameters = knnclassifierfit(X, y);
predictions = knnclassifierpredict(parameters, X);
> mean(predictions == y')
ans = 0.990539789