Skip to content
Snippets Groups Projects
Commit 55b6bcd0 authored by Felix Ramnelöv's avatar Felix Ramnelöv
Browse files

Lab 3: Updated assignment 3 to use built in rbf kernel

parent b3a36bed
No related branches found
No related tags found
No related merge requests found
......@@ -89,9 +89,7 @@ err3
# 3. Implementation of SVM predictions.
rbf_kernel <- function(x1, x2, lambda = 0.05) {
exp(-(dist(rbind(x1,x2)) ^ 2) * lambda)
}
rbf_kernel <- rbfdot(sigma = 0.05)
sv <- alphaindex(filter3)[[1]]
co <- coef(filter3)[[1]]
......@@ -100,9 +98,9 @@ k <- NULL
for (i in 1:10) {
# We produce predictions for just the first 10 points in the dataset.
k2 <- inte
data_point <- spam[i, -58]
data_point <- as.numeric(spam[i, -58])
for (j in 1:length(sv)) {
support_vector <- spam[sv[j], -58]
support_vector <- as.numeric(spam[sv[j], -58])
kernel_value <- rbf_kernel(support_vector, data_point)
k2 <- k2 + co[j] * kernel_value
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment