In [1]:
load("../transformed data/paper3.rda")
load("DP.rda")
In [2]:
# Build the classifier
cl_nn = function(new_s, train, train_label){
# use Pearson correlation
corr = apply(train, 1, cor, new_s)
train_label[corr==max(corr)]
}
# prediction
nn_train_pr = apply(train_cl,1, cl_nn, train_cl, train_response)
nn_test_pr = apply(test_cl,1, cl_nn, train_cl, train_response)
# show result of prediction
table(Train_Predict = nn_train_pr, Train_Actual = train_response)
table(Test_Predict = nn_test_pr, Test_Actual = test_response)
In [ ]: