Learn R Programming

labelrank (version 0.1)

nn_rank: Predicting rankings using the nearest neighbor algorithm

Description

This function makes prediction of rankings based on the nearest neighbor

Usage

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)

Value

a vector of predicted ranking for attribute test.x

Details

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

Examples

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

Run the code above in your browser using DataLab