I stumbled upon a 2D problem that I am interested in visualizing (I already posted about it). The point is that I know now how to extract the decision function values for a grid so you are able to plot them. Again, I am surprised how difficult it is to find it on the Internet.

With e1071, you need the following code

im=predict(K.svm, ... ,scale=F,decision.values=T)Notice that we are extracting the value of the decision function with the attribute decision.values from the prediction SVM object. This prediction SVM object, obviously, was created with a grid of points with a range larger than the input data.

im=matrix(attributes(im)$decision.values,nrow=100,byrow=F)

image(seq(0, 20, length.out=100), seq(0, 20, length.out=100), im,xlab="",ylab="")

points(y)

pdf.options(reset=T)

## No comments:

## Post a Comment