*k*-nearest neighbor classifier model, returned
as a classifier model object.

Note that using the `'CrossVal'`

, `'KFold'`

, `'Holdout'`

, `'Leaveout'`

,
or `'CVPartition'`

options results in a model of
class `ClassificationPartitionedModel`

.
You cannot use a partitioned tree for prediction, so this kind of
tree does not have a `predict`

method.

Otherwise, `mdl`

is of class `ClassificationKNN`

,
and you can use the `predict`

method to make predictions.

Sample data used to train the model, specified as a table. Each
row of `tbl`

corresponds to one observation, and
each column corresponds to one predictor variable. Optionally, `tbl`

can
contain one additional column for the response variable. Multi-column
variables and cell arrays other than cell arrays of strings are not
allowed.

If `tbl`

contains the response variable
used to train `mdl`

, then you do not need to specify `ResponseVarName`

or `Y`

.

If you trained `mdl`

using sample data contained
in a `table`

, then the input data for this method
must also be in a table.

**Data Types: **`table`

Response variable name, specified as the name of a variable
in `tbl`

. If `tbl`

contains
the response variable used to train `mdl`

, then
you do not need to specify `ResponseVarName`

.

If you specify `ResponseVarName`

, then you
must do so as a string. For example, if the response variable is stored
as `tbl.response`

, then specify it as `'response'`

.
Otherwise, the software treats all columns of `tbl`

,
including `tbl.response`

, as predictors.

The response variable must be a categorical or character array,
logical or numeric vector, or cell array of strings. If the response
variable is a character array, then each element must correspond to
one row of the array.

Matrix of predictor values. Each column of `X`

represents
one variable, and each row represents one observation.

A categorical array, cell array of strings, character array,
logical vector, or a numeric vector with the same number of rows as `X`

.
Each row of `Y`

represents the classification of
the corresponding row of `X`

.

Specify optional comma-separated pairs of `Name,Value`

arguments.
`Name`

is the argument
name and `Value`

is the corresponding
value. `Name`

must appear
inside single quotes (`' '`

).
You can specify several name and value pair
arguments in any order as `Name1,Value1,...,NameN,ValueN`

.

Observation weights, specified as the comma-separated pair consisting
of `'Weights'`

and a numeric vector or the name of
a variable in `TBL`

.

If you specify `Weights`

as a numeric vector,
then the size of `Weights`

must be equal to the number
of rows in `X`

or `tbl`

.

If you specify `Weights`

as the name of a
variable in `tbl`

, you must do so as a string.
For example, if the weights are stored as `tbl.w`

,
then specify it as `'w'`

. Otherwise, the software
treats all columns of `tbl`

, including `tbl.w`

,
as predictors.

If you specify `Weights`

, `edge`

computes
weighted classification edge. The software weights the observations
in each row of `X`

or `tbl`

with
the corresponding weight in `Weights`

.