R 理解 {caret} train(tuneLength = ) 和来自 {kernlab} 的 SVM 方法
R understanding {caret} train(tuneLength = ) and SVM methods from {kernlab}
试图更好地理解 train(tuneLength = )
在 {caret}
中的工作原理。当我试图理解来自 {kernlab}
的 SVM 方法之间的一些差异时,我感到困惑,我已经查看了文档 (here) and the caret training page (here)。
我的玩具示例是使用 iris
数据集创建五个模型。结果是 here, and reproducible code is here(它们相当长,所以我没有将它们复制并粘贴到 post)。
来自 {caret}
文档:
tuneLength
an integer denoting the amount of granularity in the tuning parameter grid. By default, this argument is the number of levels for each tuning parameters that should be generated by train. If trainControl has the option search = "random", this is the maximum number of tuning parameter combinations that will be generated by the random search. (NOTE: If given, this argument must be named.)
在this example、trainControl(search = "random")
和train(tuneLength = 30)
中,结果好像是67个,不是30个(调整参数组合的最大数量)?我试着四处看看是否有 30 个独特的 ROC
值,甚至 ydim
值,但据我统计它们不是。
对于玩具示例,我创建了以下 table:
有没有办法查看正在发生的事情"under the hood"?例如,M1
(svmRadial
) 和 M3
(svmRadialSigma
) 都采用并给出相同的调谐参数,但基于调用 $results
出现以不同的方式使用它们?
我对 train(tuneLength = 9)
的理解是,这两个模型都会产生 sigma
和 C
的结果,每个模型都带有 9 values, 9 times
,因为 9
是级别数对于每个调整参数(随机搜索除外)?类似地,M4
将是 9^3
,因为 train(tuneLength = 9)
并且有 3
个调整参数?
迈克尔
我需要更多地更新包文档,但是 package web page for random search 上拼写了详细信息:
"The total number of unique combinations is specified by the tuneLength
option to train
."
然而,这是使用 RBF 核的 SVM 特别泥泞。这是运行下来:
svmRadial
调整成本并根据 kern lab
的 sigest
函数使用单个值 sigma
。对于网格搜索,tuneLength
是要测试的成本值的数量,对于随机搜索,它是要评估的 (cost, sigma
) 对的总数。
svmRadialCost
与 svmRadial
相同,但 sigest
是每个重采样循环内的 运行。对于随机搜索,它不会调过sigma
。
svmRadialSigma
对成本和 sigma
进行网格搜索调整。在认知性能次优的时刻,我将其设置为在网格搜索期间最多尝试 sigma
的 6 个值,因为我觉得成本 space 需要更广泛的范围。对于随机搜索,它与 svmRadial
相同。
svmRadialWeight
与 svmRadial
相同,但也考虑了 class 权重,仅适用于 2-class 问题。
至于网页上的SOM示例,那是一个错误。我对 SOM 参数 space 进行了过度采样,因为 xdim <= ydim & xdim*ydim < nrow(x)
需要一个过滤器。该错误来自我没有保留正确数量的参数。
试图更好地理解 train(tuneLength = )
在 {caret}
中的工作原理。当我试图理解来自 {kernlab}
的 SVM 方法之间的一些差异时,我感到困惑,我已经查看了文档 (here) and the caret training page (here)。
我的玩具示例是使用 iris
数据集创建五个模型。结果是 here, and reproducible code is here(它们相当长,所以我没有将它们复制并粘贴到 post)。
来自 {caret}
文档:
tuneLength
an integer denoting the amount of granularity in the tuning parameter grid. By default, this argument is the number of levels for each tuning parameters that should be generated by train. If trainControl has the option search = "random", this is the maximum number of tuning parameter combinations that will be generated by the random search. (NOTE: If given, this argument must be named.)
在this example、trainControl(search = "random")
和train(tuneLength = 30)
中,结果好像是67个,不是30个(调整参数组合的最大数量)?我试着四处看看是否有 30 个独特的 ROC
值,甚至 ydim
值,但据我统计它们不是。
对于玩具示例,我创建了以下 table:
有没有办法查看正在发生的事情"under the hood"?例如,M1
(svmRadial
) 和 M3
(svmRadialSigma
) 都采用并给出相同的调谐参数,但基于调用 $results
出现以不同的方式使用它们?
我对 train(tuneLength = 9)
的理解是,这两个模型都会产生 sigma
和 C
的结果,每个模型都带有 9 values, 9 times
,因为 9
是级别数对于每个调整参数(随机搜索除外)?类似地,M4
将是 9^3
,因为 train(tuneLength = 9)
并且有 3
个调整参数?
迈克尔
我需要更多地更新包文档,但是 package web page for random search 上拼写了详细信息:
"The total number of unique combinations is specified by the
tuneLength
option totrain
."
然而,这是使用 RBF 核的 SVM 特别泥泞。这是运行下来:
svmRadial
调整成本并根据kern lab
的sigest
函数使用单个值sigma
。对于网格搜索,tuneLength
是要测试的成本值的数量,对于随机搜索,它是要评估的 (cost,sigma
) 对的总数。svmRadialCost
与svmRadial
相同,但sigest
是每个重采样循环内的 运行。对于随机搜索,它不会调过sigma
。svmRadialSigma
对成本和sigma
进行网格搜索调整。在认知性能次优的时刻,我将其设置为在网格搜索期间最多尝试sigma
的 6 个值,因为我觉得成本 space 需要更广泛的范围。对于随机搜索,它与svmRadial
相同。svmRadialWeight
与svmRadial
相同,但也考虑了 class 权重,仅适用于 2-class 问题。
至于网页上的SOM示例,那是一个错误。我对 SOM 参数 space 进行了过度采样,因为 xdim <= ydim & xdim*ydim < nrow(x)
需要一个过滤器。该错误来自我没有保留正确数量的参数。