我想了解在使用R包kernlab中的命令ksvm时,SVM predict函数是如何工作的。
我尝试使用以下命令查看predict函数:
methods(class="ksvm")
getAnywhere(ksvm:::predict)
然而,我得到了以下输出,而不是完整的预测函数:
A single object matching ‘:::’ ‘ksvm’ ‘predict’ was found
It was found in the following places
package:base
namespace:base
with value
function (pkg, name)
{
pkg <- as.character(substitute(pkg))
name <- as.character(substitute(name))
get(name, envir = asNamespace(pkg), inherits = FALSE)
}
<bytecode: 0x00000000088be4f8>
<environment: namespace:base>
Warning message:
In find(x, numeric = TRUE) :
elements of 'what' after the first will be ignored
有人能帮忙获取完整的预测函数吗?
更新1:
misspelled 的建议对 kernlab 包中 ksvm 的预测函数有效,但在 e1071 包中的 svm 上似乎无效。
它会抛出以下错误:
> getMethod("predict", "svm")
Error in getMethod("predict", "svm") :
no generic function found for 'predict'
通常来说,如何知道使用哪个get方法?