pROC 包中的 roc() 函数:使用控件和案例及其上下文
roc() function in pROC package: usage of controls and cases with its context
谁能解释一下 controls
和 cases
参数在 R 中 pROC 包的 roc()
函数中的含义,以及如何使用它们?如何查看数据集中可用的控件和案例的数量?
它是关于特定案例还是关于 ROC 曲线的一般功能?
如果你在 ROC 曲线项目中卡在 R 中,请记下代码。当您举个例子时,更容易解释这一点。
来自help(roc)
:
controls, cases
instead of response, predictor, the data can be supplied as two numeric or ordered vectors containing the predictor values for control and case observations.
通常在分类设置中使用 roc 曲线,其中您有两个标记为 类 的向量(factor()
在 R 中),一个是您预测的标签,另一个是事实,再次标记每个 obs。
其他时候你可以有一个控制组(比如在医学场景中),你可以给函数提供控制(一个数字向量)或案例(一个因子向量)。
对照组基本上是您不进行治疗的那部分人群。
再次来自 help
函数:
Data can be provided as response, predictor, where the predictor is the numeric (or ordered) level of the evaluated signal, and the response encodes the observation class (control or case). The level argument specifies which response level must be taken as controls (first value of level) or cases (second). It can safely be ignored when the response is encoded as 0 and 1, but it will frequently fail otherwise. By default, the first two values of levels(as.factor(response)) are taken, and the remaining levels are ignored. This means that if your response is coded “control” and “case”, the levels will be inverted.
In some cases, it is more convenient to pass the data as controls, cases, but both arguments are ignored if response, predictor was specified to non-NULL values. It is also possible to pass density data with density.controls, density.cases, which will result in a smoothed ROC curve even if smooth=FALSE, but are ignored if response, predictor or controls, cases are provided.
data(aSAH)
# With numeric controls/cases
roc(controls=aSAH$s100b[aSAH$outcome=="Good"], cases=aSAH$s100b[aSAH$outcome=="Poor"])
# With ordered controls/cases
roc(controls=aSAH$wfns[aSAH$outcome=="Good"], cases=aSAH$wfns[aSAH$outcome=="Poor"])
在二进制分类中,你总是有两个组。其中一组将对应于您想要检测的事物的观察结果。根据您的研究领域,它可以有多种称呼方式,但常用术语包括 hit、positive 或 case.
相比之下,没有您想要检测的观察结果被标记为 negative、miss 或 控制.
因此在 pROC 中这被称为 control 和 case,但您可以将其视为 negative 和 阳性 。
您无需检查可用控件和案例的数量。 pROC 将为您进行此检查,当您 print
曲线时,将报告实际使用的数字。
谁能解释一下 controls
和 cases
参数在 R 中 pROC 包的 roc()
函数中的含义,以及如何使用它们?如何查看数据集中可用的控件和案例的数量?
它是关于特定案例还是关于 ROC 曲线的一般功能? 如果你在 ROC 曲线项目中卡在 R 中,请记下代码。当您举个例子时,更容易解释这一点。
来自help(roc)
:
controls, cases instead of response, predictor, the data can be supplied as two numeric or ordered vectors containing the predictor values for control and case observations.
通常在分类设置中使用 roc 曲线,其中您有两个标记为 类 的向量(factor()
在 R 中),一个是您预测的标签,另一个是事实,再次标记每个 obs。
其他时候你可以有一个控制组(比如在医学场景中),你可以给函数提供控制(一个数字向量)或案例(一个因子向量)。
对照组基本上是您不进行治疗的那部分人群。
再次来自 help
函数:
Data can be provided as response, predictor, where the predictor is the numeric (or ordered) level of the evaluated signal, and the response encodes the observation class (control or case). The level argument specifies which response level must be taken as controls (first value of level) or cases (second). It can safely be ignored when the response is encoded as 0 and 1, but it will frequently fail otherwise. By default, the first two values of levels(as.factor(response)) are taken, and the remaining levels are ignored. This means that if your response is coded “control” and “case”, the levels will be inverted.
In some cases, it is more convenient to pass the data as controls, cases, but both arguments are ignored if response, predictor was specified to non-NULL values. It is also possible to pass density data with density.controls, density.cases, which will result in a smoothed ROC curve even if smooth=FALSE, but are ignored if response, predictor or controls, cases are provided.
data(aSAH)
# With numeric controls/cases
roc(controls=aSAH$s100b[aSAH$outcome=="Good"], cases=aSAH$s100b[aSAH$outcome=="Poor"])
# With ordered controls/cases
roc(controls=aSAH$wfns[aSAH$outcome=="Good"], cases=aSAH$wfns[aSAH$outcome=="Poor"])
在二进制分类中,你总是有两个组。其中一组将对应于您想要检测的事物的观察结果。根据您的研究领域,它可以有多种称呼方式,但常用术语包括 hit、positive 或 case.
相比之下,没有您想要检测的观察结果被标记为 negative、miss 或 控制.
因此在 pROC 中这被称为 control 和 case,但您可以将其视为 negative 和 阳性 。
您无需检查可用控件和案例的数量。 pROC 将为您进行此检查,当您 print
曲线时,将报告实际使用的数字。