nn_rank: Predicting rankings using the nearest neighbor algorithm

Description Usage Arguments Details Value Examples

View source: R/nn.R

Description

This function makes prediction of rankings based on the nearest neighbor

Usage

1
nn_rank(train.x, y, test.x, n = 1, k = 3)

Arguments

train.x

is matrix of numeric attributes in training sample

y

is matrix of training rankings

test.x

is a vector of new numeric attributes for which to predict rankings

n

is a parameter of 'memory' of how fast the past rankings gets forgotten. (see details of time_weights). By default, n=1 which means that a label ranking problem does not have timing effect.

k

is the number of the nearest neighbors to consider (default k=3)

Details

A function predicts the rankings based on the euclidean distance between train and test attributes.

Value

a vector of predicted ranking for attribute test.x

Examples

1
2
3
train.x <- lr.num[1:16,]
test.x <- lr.num[17,]
ranking <- nn_rank(train.x, y, test.x, n=1,k=3)

Example output



labelrank documentation built on May 2, 2019, 11:10 a.m.