Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Margin of *k*-nearest neighbor classifier

`m = margin(mdl,tbl,ResponseVarName)`

`m = margin(mdl,tbl,Y)`

`m = margin(mdl,X,Y)`

returns the classification margins for
`m`

= margin(`mdl`

,`tbl`

,`ResponseVarName`

)`mdl`

with data `tbl`

and classification
`tbl.ResponseVarName`

. If `tbl`

contains the
response variable used to train `mdl`

, then you do not need to
specify `ResponseVarName`

.

`m`

is returned as a numeric vector of length
`size(tbl,1)`

. Each entry in `m`

represents
the margin for the corresponding row of `tbl`

and the
corresponding true class label in `tbl.ResponseVarName`

, computed
using `mdl`

.