Learn R Programming

DSWE (version 1.6.1)

KnnUpdate: KNN : Update

Description

The function can be used to update KNN model when new data is provided

Usage

KnnUpdate(knnMdl, newData)

Value

a list containing :

  • data - The updated data using old data set and new data

  • xCol - The column number of features provided by user or the best subset column number

  • yCol - The column number of target provided by user

  • bestK - The best k nearest neighbor calculated for the new data using user specified features and target

Arguments

knnMdl

a list containing:

  • knnMdl$data - The data set provided by user

  • knnMdl$xCol - The column number of features provided by user or the best subset column number

  • knnMdl$yCol - The column number of target provided by user

  • knn$bestK - The best k nearest neighbor calculated using the function KnnFit

newData

a dataframe or a matrix, to be used for updating the model

Examples

Run this code

data = data1[c(1:100),]
xCol = 2
yCol = 7
subsetSelection = FALSE

knn_model = KnnPCFit(data, xCol, yCol, subsetSelection)
newData = data1[c(101:110), ]

knn_newmodel = KnnUpdate(knn_model, newData)

Run the code above in your browser using DataLab