- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设我有两个矩阵:A 表示标签矩阵,B 表示 A 的对应预测概率矩阵。现在我想根据矩阵 A 和 B 计算 AUPR(Area Under Precision/Recall Curve)。对于普通 AUC(Area Under ROC Curve),R中有很多包,比如ROCR,pROC,可以直接计算AUC值,但是目前R中有哪些包可以计算AUPR呢?或者你能帮助给出计算 AUPR 的方法吗?
这是两个示例矩阵:
> pp
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 0.01792 0.00155 -0.00140 0.00522 0.01320 0.22506 0.00454
[2,] 0.05883 0.11256 0.82862 0.12406 0.08298 -0.00392 0.30724
[3,] 0.00743 0.06357 0.14500 0.00213 0.00545 0.03452 0.11189
[4,] 0.02571 0.01460 0.01108 0.00494 0.01246 0.11880 0.05504
[5,] 0.02407 0.00961 0.00720 0.00382 0.01039 0.10974 0.04512
> ll
D00040 D00066 D00067 D00075 D00088 D00094 D00105
hsa190 0 0 0 0 0 1 0
hsa2099 0 1 1 0 0 0 1
hsa2100 0 0 0 0 0 0 1
hsa2101 0 0 0 0 0 0 0
hsa2103 0 0 0 0 0 0 0
pp
是真实标签的预测概率矩阵
ll
矩阵,和
ll
只是标签矩阵。
最佳答案
我首先将预测分数和类别从矩阵转换为向量。
有一个“PRROC”包,它提供了与“ROCR”类似的生成ROC和PRC的功能,并且还给出了PRC的AUC。
具体来说,我正在使用数据 ROCR.simple
以“ROCR”包为例。
library(PRROC)
library(ROCR)
data("ROCR.simple")
scores <- data.frame(ROCR.simple$predictions, ROCR.simple$labels)
pr <- pr.curve(scores.class0=scores[scores$ROCR.simple.labels=="1",]$ROCR.simple.predictions,
scores.class1=scores[scores$ROCR.simple.labels=="0",]$ROCR.simple.predictions,
curve=T)
pr
中多变的。
pr
Precision-recall curve
Area under curve (Integral):
0.7815038
Area under curve (Davis & Goadrich):
0.7814246
Curve for scores from 0.005422562 to 0.9910964
( can be plotted with plot(x) )
plot(pr)
绘制中国。或使用 ggplot:
y <- as.data.frame(pr$curve)
ggplot(y, aes(y$V1, y$V2))+geom_path()+ylim(0,1)
关于r - 在 R : calculate Area Under Precision/Recall Curve (AUPR)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25020788/
当我用 g++ 编译时出现以下错误: Parser.cpp:(.text+0x2478): 未定义对“Curve::Curve()”的引用 Parser.cpp 的标题如下: #include "Be
问题 假设我知道希尔伯特曲线面和四叉树,例如 4/032212303102122 (第 4 面,第 15 层)。 或者我可能知道 S2 Geometry CellId,例如 9749618424903
我正在尝试将文本包裹在贝塞尔曲线中,并遵循此链接中的教程,http://www.planetclegg.com/projects/WarpingTextToSplines.html 我通过此代码获得衍
如果我有一组来 self 扫描的黑白图像的点。 它看起来像一条曲线,我想使用这些点的三次贝塞尔曲线来模拟一条平滑的曲线。 如何确定起点、2 个控制点和终点? 从图像中可以模拟出几条三次贝塞尔曲线,但我
我想将具有已知端点(p0 和 p3)的贝塞尔曲线拟合到嘈杂的二维数据。这似乎比传统的 4 点贝塞尔曲线拟合更简单,但我仍然难以弄清楚。 有人可以指出我现有的代码或算法来找到控制点 p1 和 p2 的最
我正在尝试使用 B 样条曲线拟合。 B样条曲线的阶数为4。当我有很多控制点时,它工作得很好。但是,如果控制点的数量很少,比如两个,我的程序就会崩溃。我意识到控制点的数量与结的数量和顺序有关。谁能帮我澄
我有三个形成抛物线的 X/Y 点。我只需要计算通过这三个点的抛物线顶点是多少。最好是一种快速的方法,因为我必须做很多这些计算! “Ask A Scientist”网站提供this answer : T
我想绘制 x 的函数,其中 x 应用于向量。无论如何,最简单的是举一个简单的例子: var <- c(1,2,3) curve(mean(var)+x) curve(mean(var+x)) 虽然第一
一位同事问我这个问题,我一直在努力解决这个问题。 假设我想定义一个函数,它接受一个表达式(具体来说,假设为 x^2)作为参数,并将该参数传递给 curve()。 如果我想以简单的方式做到这一点,我只需
我想绘制 x 的函数,其中 x 应用于向量。无论如何,最简单的是举一个简单的例子: var <- c(1,2,3) curve(mean(var)+x) curve(mean(var+x)) 虽然第一
ECDSA算法中256位EC key 的签名长度将是多少? 我想验证签名长度是否相同。如果某个机构可以帮助我设置一个EC key ,那将是很棒的。 最佳答案 这取决于您如何对签名进行编码。这是来自Op
我有以下代码生成四个图,但它们最终被压扁(见下图)。我该如何解决这个问题? par(mfrow=c(2,2)) curve(.5*exp(-.5*x),from=0,to=10,main="f(x)"
我编写了一个程序,它处理当前资源到几何图形表面的欧氏距离。在我们的几何考虑中,y 坐标始终为零 - 因此它在 x 和 z 维度上是一个二维结构。该图显示了它的外观: (length yellow =
为什么curve似乎不适用于从列表中提取的元素? 考虑两个看似相同的函数,但构建方式不同: a curve(m[[1]]) Error in curve(m[[1]]) : 'expr' mus
我有一个公式作为字符向量,并希望在曲线中使用它。 curve(-8*cos(2*x), 0, 10) #works as expected formula <- "-8*cos(2*x)" # not
为什么curve似乎不适用于从列表中提取的元素? 考虑两个看似相同的函数,但构建方式不同: a curve(m[[1]]) Error in curve(m[[1]]) : 'expr' mus
是否可以循环动画此图像? 我试图通过创建一个相对父级并将每个图像设置为动画(业务解决方案 div、it 解决方案 div、生命周期解决方案 div 和教育解决方案 div 为绝对)。我使用了这段代码,
如何在Flex中弯曲我的文本小部件?我有一个被文本包围的圆圈,我需要为文本创建这个样式。另外,这个圆圈占屏幕宽度的50%,所以这个曲线效果也应该是动态的
我怎样才能弯曲一张纸(立方体)?我想控制弯曲/曲线的角度。 例如 立方体([50,50,2]); 最佳答案 您可以 rotate_extrude()一个带有参数角的矩形。这需要 openscad 版本
我正在尝试寻找一种聪明的方法来创建像下一个一样的曲线(使用 Unity3d 2D 部分(不使用网格对撞机))),但我没有找到 任何帮助,将不胜感激。 最佳答案 看到最后一个答案(已删除)不符合我的要求
我是一名优秀的程序员,十分优秀!