📄 hanleymcneilcomparator.cpp
字号:
//-------------------------------------------------------------------// Author........: Aleksander 豩rn// Date..........:// Description...: Implements the statistical hypothesis testing// described in://// @ARTICLE{hanley:roc83,// author = "James A. Hanley and Barbara J. McNeil",// title = "A Method of Comparing the Areas under Receiver Operating// Characteristic Curves Derived from the Same Cases",// journal = "Radiology",// year = 1983,// volume = 148,// month = sep,// pages = "839--843",// }//// Revisions.....://===================================================================#include <stdafx.h> // Precompiled headers.#include <copyright.h>#include <kernel/utilities/hanleymcneilcomparator.h>#include <kernel/utilities/mathkit.h>#include <kernel/structures/roccurve.h>//-------------------------------------------------------------------// Static stuff (file scope)://===================================================================#if defined(_MSC_VER) // Microsoft Visual C++.#pragma warning(disable:4305)#endifstatic float static_r_[][12] = {// 0.700 0.725 0.750 0.775 0.800 0.825 0.850 0.875 0.900 0.925 0.950 0.975 {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, 0.01, 0.01}, // 0.02 {0.04, 0.04, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.02, 0.02, 0.02}, // 0.04 {0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.04, 0.04, 0.04, 0.03, 0.02}, // 0.06 {0.07, 0.07, 0.07, 0.07, 0.07, 0.06, 0.06, 0.06, 0.06, 0.05, 0.04, 0.03}, // 0.08 {0.09, 0.09, 0.09, 0.09, 0.08, 0.08, 0.08, 0.07, 0.07, 0.06, 0.06, 0.04}, // 0.10 {0.11, 0.11, 0.11, 0.10, 0.10, 0.10, 0.09, 0.09, 0.08, 0.08, 0.07, 0.05}, // 0.12 {0.13, 0.12, 0.12, 0.12, 0.12, 0.11, 0.11, 0.11, 0.10, 0.09, 0.08, 0.06}, // 0.14 {0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.12, 0.11, 0.11, 0.09, 0.07}, // 0.16 {0.16, 0.16, 0.16, 0.16, 0.15, 0.15, 0.14, 0.14, 0.13, 0.12, 0.11, 0.09}, // 0.18 {0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 0.16, 0.15, 0.15, 0.14, 0.12, 0.10}, // 0.20 {0.20, 0.20, 0.19, 0.19, 0.19, 0.18, 0.18, 0.17, 0.16, 0.15, 0.14, 0.11}, // 0.22 {0.22, 0.22, 0.21, 0.21, 0.21, 0.20, 0.19, 0.19, 0.18, 0.17, 0.15, 0.12}, // 0.24 {0.24, 0.23, 0.23, 0.23, 0.22, 0.22, 0.21, 0.20, 0.19, 0.18, 0.16, 0.13}, // 0.26 {0.26, 0.25, 0.25, 0.25, 0.24, 0.24, 0.23, 0.22, 0.21, 0.20, 0.18, 0.15}, // 0.28 {0.27, 0.27, 0.27, 0.26, 0.26, 0.25, 0.25, 0.24, 0.23, 0.21, 0.19, 0.16}, // 0.30 {0.29, 0.29, 0.29, 0.28, 0.28, 0.27, 0.26, 0.26, 0.24, 0.23, 0.21, 0.18}, // 0.32 {0.31, 0.31, 0.31, 0.30, 0.30, 0.29, 0.28, 0.27, 0.26, 0.25, 0.23, 0.19}, // 0.34 {0.33, 0.33, 0.32, 0.32, 0.31, 0.31, 0.30, 0.29, 0.28, 0.26, 0.24, 0.21}, // 0.36 {0.35, 0.35, 0.34, 0.34, 0.33, 0.33, 0.32, 0.31, 0.30, 0.28, 0.26, 0.22}, // 0.38 {0.37, 0.37, 0.36, 0.36, 0.35, 0.35, 0.34, 0.33, 0.32, 0.30, 0.28, 0.24}, // 0.40 {0.39, 0.39, 0.38, 0.38, 0.37, 0.36, 0.36, 0.35, 0.33, 0.32, 0.29, 0.25}, // 0.42 {0.41, 0.40, 0.40, 0.40, 0.39, 0.38, 0.38, 0.37, 0.35, 0.34, 0.31, 0.27}, // 0.44 {0.43, 0.42, 0.42, 0.42, 0.41, 0.40, 0.39, 0.38, 0.37, 0.35, 0.33, 0.29}, // 0.46 {0.45, 0.44, 0.44, 0.43, 0.43, 0.42, 0.41, 0.40, 0.39, 0.37, 0.35, 0.30}, // 0.48 {0.47, 0.46, 0.46, 0.45, 0.45, 0.44, 0.43, 0.42, 0.41, 0.39, 0.37, 0.32}, // 0.50 {0.49, 0.48, 0.48, 0.47, 0.47, 0.46, 0.45, 0.44, 0.43, 0.41, 0.39, 0.34}, // 0.52 {0.51, 0.50, 0.50, 0.49, 0.49, 0.48, 0.47, 0.46, 0.45, 0.43, 0.41, 0.36}, // 0.54 {0.53, 0.52, 0.52, 0.51, 0.51, 0.50, 0.49, 0.48, 0.47, 0.45, 0.43, 0.38}, // 0.56 {0.55, 0.54, 0.54, 0.53, 0.53, 0.52, 0.51, 0.50, 0.49, 0.47, 0.45, 0.40}, // 0.58 {0.57, 0.56, 0.56, 0.55, 0.55, 0.54, 0.53, 0.52, 0.51, 0.49, 0.47, 0.42}, // 0.60 {0.59, 0.58, 0.58, 0.57, 0.57, 0.56, 0.55, 0.54, 0.53, 0.51, 0.49, 0.45}, // 0.62 {0.61, 0.60, 0.60, 0.59, 0.59, 0.58, 0.58, 0.57, 0.55, 0.54, 0.51, 0.47}, // 0.64 {0.63, 0.62, 0.62, 0.62, 0.61, 0.60, 0.60, 0.59, 0.57, 0.56, 0.53, 0.49}, // 0.66 {0.65, 0.64, 0.64, 0.64, 0.63, 0.62, 0.62, 0.61, 0.60, 0.58, 0.56, 0.51}, // 0.68 {0.67, 0.66, 0.66, 0.66, 0.65, 0.65, 0.64, 0.63, 0.62, 0.60, 0.58, 0.54}, // 0.70 {0.69, 0.69, 0.68, 0.68, 0.67, 0.67, 0.66, 0.65, 0.64, 0.63, 0.60, 0.56}, // 0.72 {0.71, 0.71, 0.70, 0.70, 0.69, 0.69, 0.68, 0.67, 0.66, 0.65, 0.63, 0.59}, // 0.74 {0.73, 0.73, 0.72, 0.72, 0.72, 0.71, 0.71, 0.70, 0.69, 0.67, 0.65, 0.61}, // 0.76 {0.75, 0.75, 0.75, 0.74, 0.74, 0.73, 0.73, 0.72, 0.71, 0.70, 0.68, 0.64}, // 0.78 {0.77, 0.77, 0.77, 0.76, 0.76, 0.76, 0.75, 0.74, 0.73, 0.72, 0.70, 0.67}, // 0.80 {0.79, 0.79, 0.79, 0.79, 0.78, 0.78, 0.77, 0.77, 0.76, 0.75, 0.73, 0.70}, // 0.82 {0.82, 0.81, 0.81, 0.81, 0.81, 0.80, 0.80, 0.79, 0.78, 0.77, 0.76, 0.73}, // 0.84 {0.84, 0.84, 0.83, 0.83, 0.83, 0.82, 0.82, 0.81, 0.81, 0.80, 0.78, 0.75}, // 0.86 {0.86, 0.86, 0.86, 0.85, 0.85, 0.85, 0.84, 0.84, 0.83, 0.82, 0.81, 0.79}, // 0.88 {0.88, 0.88, 0.88, 0.88, 0.87, 0.87, 0.87, 0.86, 0.86, 0.85, 0.84, 0.82} // 0.90};#if defined(_MSC_VER) // Microsoft Visual C++.#pragma warning(default:4305)#endif//-------------------------------------------------------------------// Methods for class HanleyMcNeilComparator.//===================================================================//-------------------------------------------------------------------// Constructors/destructors.//===================================================================//-------------------------------------------------------------------// Method........: Constructors// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......:// Revisions.....://===================================================================HanleyMcNeilComparator::HanleyMcNeilComparator() { auc1_ = Undefined::Float(); auc2_ = Undefined::Float(); se1_ = Undefined::Float(); se2_ = Undefined::Float(); corr0s_ = Undefined::Float(); corr1s_ = Undefined::Float(); r_ = Undefined::Float();}HanleyMcNeilComparator::HanleyMcNeilComparator(const Vector(String) &filenames, const Vector(bool) &swap, Correlation correlation, bool cindex) : BinaryOutcomeComparator(filenames, swap) { auc1_ = Undefined::Float(); auc2_ = Undefined::Float(); se1_ = Undefined::Float(); se2_ = Undefined::Float(); corr0s_ = Undefined::Float(); corr1s_ = Undefined::Float(); r_ = Undefined::Float(); bool error = false; // Check that things went OK further up. if (targets_.size() != 2 || outputs_.size() != 2) { Message::Error("The number of classifiers is not 2."); error = true; } else { if (targets_[0] != targets_[1]) { Message::Error("The actual outcomes for the two classifiers do not match up."); error = true; } } if (!error) Create(targets_[0], outputs_[0], outputs_[1], correlation, false, cindex);}//-------------------------------------------------------------------// Method........: Destructor// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......:// Revisions.....://===================================================================HanleyMcNeilComparator::~HanleyMcNeilComparator() {}//-------------------------------------------------------------------// Helper methods.//===================================================================//-------------------------------------------------------------------// Method........: ComputeROCQuantities// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......:// Revisions.....: A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -