When I attempt to run the code below, I get the following error
library(caret)
library(kernlab)
library(ROCR)
dim(svm.data)
set.seed(123)
ctrl <- trainControl(method="cv", number = 2, summaryFunction=twoClassSummary, classProbs=TRUE)
grid <- expand.grid(sigma = c(.01, .015, 0.2), C = c(0.75, 0.9, 1, 1.1, 1.25)
svm.tune <- train(x=trainX, y= svm.train$Class, method = “svmRadial”, metric=”ROC”, tuneGrid = grid, trControl=ctrl)
Error: could not find svmRadial function
mara
July 10, 2018, 6:14pm
2
Hmm, I'm not sure how to reproduce your error.
svmRadial
is a method in caret, not a function, so I'm not sure why you'd be getting that error (example from SO thread , below):
library(caret)
#> Loading required package: lattice
#> Loading required package: ggplot2
data(iris)
TrainData <- iris[,1:4]
TrainClasses <- iris[,5]
out1 <- train(TrainData, TrainClasses, method = "svmRadial")
class(out1$finalModel)
#> [1] "ksvm"
#> attr(,"package")
#> [1] "kernlab"
Created on 2018-07-10 by the reprex package (v0.2.0).
Could you please turn this into a self-contained reprex (short for repr oducible ex ample)? It will help us help you if we can be sure we're all working with/looking at the same stuff.
install.reprex("reprex")
If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page . The reprex dos and don'ts are also useful.
What to do if you run into clipboard problems
If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.
reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")
For pointers specific to the community site, check out the reprex FAQ , linked to below.
1 Like