如何使用LOOCV查找比R中的完整集更好分类的子集

问题描述 投票:0回答:1

我正在使用遥远软件包中的wbca数据。恶性肿瘤的先验概率为π0= 1/3,良性肿瘤的先验概率为π1= 2/3。

[我正在尝试将朴素的贝叶斯分类器与多项式一起使用,以查看9个特征中是否有一个很好的子集,使用LOOCV进行分类要比完整分类更好。

我不确定从何处开始,因此任何Rcode帮助都将非常有用。谢谢!

r statistics probability naivebayes
1个回答
0
投票

您可以在下面尝试,预测变量的内核估计可能不是最准确的,但是您可以从以下内容开始:

library(faraway)
library(naivebayes)
library(caret)

x = wbca[,!grepl("Class",colnames(wbca))]
y = factor(wbca$Class)

ctrl <- rfeControl(functions = nbFuncs,
                   method = "LOOCV")

bayesProfile <- rfe(x, y,
                 sizes = subsets,
                 rfeControl = ctrl)

bayesProfile

Recursive feature selection

Outer resampling method: Leave-One-Out Cross-Validation 

Resampling performance over subset size:

 Variables Accuracy  Kappa Selected
         2   0.9501 0.8891         
         3   0.9648 0.9225         
         4   0.9648 0.9223         
         5   0.9677 0.9290         
         6   0.9750 0.9454        *
         7   0.9692 0.9322         
         8   0.9750 0.9455         
         9   0.9662 0.9255         

The top 5 variables (out of 6):
   USize, UShap, BNucl, Chrom, Epith

您可以获得最佳变量:

bayesProfile$optVariables
[1] "USize" "UShap" "BNucl" "Chrom" "Epith" "Thick"
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.