OpenMS
ROCCurve.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/config.h>
12 #include <OpenMS/CONCEPT/Types.h>
13 
14 #include <list>
15 #include <vector>
16 
17 namespace OpenMS
18 {
19  namespace Math
20  {
28  class OPENMS_DLLAPI ROCCurve
29  {
30 public:
31 
32  // @name Constructors and Destructors
33  // @{
36 
38  explicit ROCCurve(const std::vector<std::pair<double,bool>> & pairs);
39 
41  virtual ~ROCCurve() = default;
42 
44  ROCCurve(const ROCCurve & source);
45  // @}
46 
47  // @name Operators
48  // @{
50  ROCCurve & operator=(const ROCCurve & source);
51  // @}
52 
53  // @name Accessors
54  // @{
56  void insertPair(double score, bool clas);
57 
59  double AUC();
60 
62  double rocN(Size N);
63 
65  std::vector<std::pair<double, double> > curve(UInt resolution = 10);
66 
69  double cutoffPos(double fraction = 0.95);
70 
73  double cutoffNeg(double fraction = 0.95);
74 
75  // @}
76 
77 private:
79  inline void sort();
80 
82  inline void count();
83 
86  inline double trapezoidal_area(double x1, double x2, double y1, double y2);
87 
89  class OPENMS_DLLAPI simsortdec
90  {
91 public:
92 
93  bool operator()(const std::pair<double, bool> & a, const std::pair<double, bool> & b)
94  {
95  return b.first < a.first;
96  }
97 
98  };
99 
100 
101  std::vector<std::pair<double, bool> > score_clas_pairs_;
102 
103  UInt pos_{};
104 
105  UInt neg_{};
106 
107  bool sorted_{};
108  };
109  }
110 }
predicate for sort()
Definition: ROCCurve.h:90
bool operator()(const std::pair< double, bool > &a, const std::pair< double, bool > &b)
Definition: ROCCurve.h:93
ROCCurves show the trade-off in sensitivity and specificity for binary classifiers using different cu...
Definition: ROCCurve.h:29
void insertPair(double score, bool clas)
insert score, type pair
double AUC()
returns Area Under Curve
ROCCurve()
default constructor
ROCCurve & operator=(const ROCCurve &source)
assignment operator
std::vector< std::pair< double, double > > curve(UInt resolution=10)
some points in the ROC Curve
void sort()
sorts data and caches if sorted
std::vector< std::pair< double, bool > > score_clas_pairs_
Definition: ROCCurve.h:101
double rocN(Size N)
returns ROC-N score (e.g. ROC-50). Returns -1 if not enough false positives were found
ROCCurve(const ROCCurve &source)
copy constructor
virtual ~ROCCurve()=default
destructor
double trapezoidal_area(double x1, double x2, double y1, double y2)
double cutoffPos(double fraction=0.95)
ROCCurve(const std::vector< std::pair< double, bool >> &pairs)
constructor with value, class pairs
double cutoffNeg(double fraction=0.95)
void count()
counts global pos and neg
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19