classifier: Majority voting.

Description Usage Arguments Details Value Author(s) Examples

Description

Predict a class given a list of neighbours obtained from k-nn using majority voting.

Usage

1
classifier(cls, distance)

Arguments

cls

A list of neighbour classes found with knn.

distance

An equal length list of neighbour distances.

Details

Todo: Distance weighted majority voting/distance kernel.

Value

The majority prediction along with classification confidence.

Author(s)

phil

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# form the query instance.
query <- list(
    sepal.length=5.84,
    sepal.width=3.05,
    petal.length=3.76,
    petal.width=1.20)

# get the 10-nearest neighbours.
top.10 <- knn(query, iris.data, 10)

# classify the instance.
prediction <- classifier(top.10$species, top.10$distance)

# print the result.
print(paste("prediction =", prediction$pred,
            "confidence =", prediction$conf))

phil8192/lazy-iris documentation built on May 25, 2019, 2:56 a.m.