I am trying to implement a novelty detector using the kernlab library (ksvm function) in R. Here is a simple example of what I'm trying to do:
# Training data xxTrain <- matrix(rnorm(2000), nrow=1000, ncol=2, byrow=TRUE) y <- rep(1,1000) classifier <- ksvm(xxTrain, y, type="one-svc", kernel="rbfdot", kpar="automatic") # Test data x1 <- rnorm(1000) scale <- c(rep(1,500), rep(10,100), rep(1,400)) x2 <- rnorm(1000)*scale xxTest <- matrix(c(x1,x2), nrow=1000, ncol=2, byrow=TRUE) # Prediction p <- predict(classifier, xxTest, type="response") # Visualization plot(x2, type='l') lines(x1, col="red") points(5*as.integer(p), type='l', col="blue")

The figure above is the result that I get. The blue trace is a prediction, and it clearly shows the period in which it is 0. But it does not coincide in time or width with the ejection of the black trace. There are 100 points (black line) that have a large amplitude, and the output that I get in blue does not match the black line.
What am I doing wrong?
source share