knn_cv: K-Nearest Nehbors Cross Validation

Description Usage Arguments Value Author(s) References Examples

Description

Tests each provided k value and plots it as well as returning the minimum error value and related k-values. This cross validation method works with more than two colors.
knn_cv_ is the alternate and less graphical version

Usage

1
2
3
knn_cv(df, ..., color, k=1:200, nfold=10, times=10, na.action="mutate", l=0, prob=FALSE, use.all=TRUE)

knn_cv_(df, ..., color,k=1:50, nfold=10, times=1, na.action="mutate", l=0, prob=FALSE, use.all=TRUE)

Arguments

df

The dataframe to test

...

Columns to determine distance in knn prediction

color

The predicted column

k

The k-values to test the data with

nfold

The ratio of train rows to test rows as well as the times to test
Must be greater than 1

times

How many folds to preduce

na.action

What to do with NA values.
"mutate": Convert to empty strings
"remove": Removes all NAs
"mutate|remove": Applies mutate on color and remove on other columns other: No action

l

minimum vote for definite decision, otherwise doubt. (More precisely, less than k-l dissenting votes are allowed, even if k is increased by ties.)

prob

If this is true, the proportion of the votes for the winning class are returned as attribute prob.

use.all

controls handling of ties. If true, all distances equal to the kth largest are included. If false, a random selection of distances equal to the kth is chosen to use exactly k neighbours.

Value

A list of objects:
$err: A table of all predictions
$sum: Summary of the data
$plot: The plot of the knn_cv
$min: The minumum value(s) as a table

Author(s)

zekrom_vale

References

knn The function that

Examples

1
sleep%>%knn_cv(extra, ID, color=group, k=1:10)

zekrom-vale/zUtil.R documentation built on June 2, 2019, 10:57 p.m.