优化e1071封装中的F分数 [英] Optimize F-score in e1071 package

查看:125
本文介绍了优化e1071封装中的F分数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用R中的e1071包来实现一类SVM。有人可以给我一些有关如何使用网格搜索来优化F分数的指针吗?

I'm trying to implement a one class SVM using the e1071 package in R. Can somebody give me pointers on how to optimize the F-score using a grid search ?

我已经尝试过tune.svm函数,但是它只会导致高灵敏度或高特异性。

I have tried the tune.svm functions but it has only resulted in high sensitivity or high Specificity.

我试图预测的阳性类别百分比大约占总人口的1-2%。

The percentage of positive class which I'm trying to predict is about 1-2% in the general population.

我得到的结果具有较高的准确度,但F得分却很低:

The results i get have high accuracy but with a very low F-score:

             Reference
Prediction    members Not members
  members           1           4
  Not members      12         983

           Accuracy : 0.984           
             95% CI : (0.9741, 0.9908)
No Information Rate : 0.987           
P-Value [Acc > NIR] : 0.83691         

              Kappa : 0.1046          

麦克纳马尔检验P值: 0.08012

Mcnemar's Test P-Value : 0.08012

        Sensitivity : 0.07692         
        Specificity : 0.99595 

以下是我的代码段:

tuned <- tune.svm(fo, data = df, 
                  nu =  0.001:0.5,
                  gamma = 10^(-2:0), 
                  type='one-classification'                 
                  );

model <-     svm(fo, data = df , 
                   nu = tuned$best.parameters$nu, 
                   gamma = tuned$best.parameters$gamma,
                   type='one-classification'
                 );


推荐答案

您可以提供tune.svm的tunecontrol参数。方法。

You can provide the tunecontrol parameter of the tune.svm method.

它采用调谐控件

然后,您需要使用所需参数创建对象。
通过在构建此对象时指定 error.fun 参数,可以定义要使用的错误函数。

You then need to create the object with the desired parameters. By specifying the error.fun parameter when building this object you can define the error function to be used.


error.fun
函数返回要最小化的错误度量。它有两个参数:真值向量和预测值向量。如果为NULL,则分类错误将用于分类预测,而均方误差将用于数字预测。

error.fun : function returning the error measure to be minimized. It takes two arguments: a vector of true values and a vector of predicted values. If NULL, the misclassification error is used for categorical predictions and the mean squared error for numeric predictions.

因此,应放置一个计算F分数的函数做这项工作。

So putting a function which computes the F-Score should do the job.

这篇关于优化e1071封装中的F分数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆