openModeller
Version 1.5.0
|
#include <RocCurve.hh>
Classes | |
struct | VectorCompare |
Public Member Functions | |
RocCurve () | |
~RocCurve () | |
void | initialize (int resolution=ROC_DEFAULT_RESOLUTION) |
void | initialize (int resolution, int num_background_points) |
void | initialize (int resolution, bool use_absences_as_background) |
void | reset () |
void | calculate (const Model &model, const SamplerPtr &sampler) |
int | numPoints () const |
double | getX (int point_index) const |
double | getY (int point_index) const |
double | getTotalArea () |
double | getPartialAreaRatio (double e=1.0) |
bool | ready () const |
ConfigurationPtr | getConfiguration () const |
Private Member Functions | |
void | _loadPredictions (const Model &model, const SamplerPtr &sampler) |
void | _calculateGraphPoints () |
bool | _calculateTotalArea () |
Private Attributes | |
std::vector< int > | _category |
std::vector< Scalar > | _prediction |
std::vector< std::vector < Scalar > > | _data |
int | _resolution |
int | _approach |
int | _num_background_points |
bool | _use_absences_as_background |
int | _true_negatives |
int | _true_positives |
double | _auc |
std::map< double, double > | _ratios |
std::vector< Scalar > | _thresholds |
std::vector< Scalar > | _proportions |
bool | _ready |
Class ROC curve
Definition at line 46 of file RocCurve.hh.
RocCurve::RocCurve | ( | ) |
Default constructor.
Definition at line 57 of file RocCurve.cpp.
RocCurve::~RocCurve | ( | ) |
Destructor.
Definition at line 64 of file RocCurve.cpp.
|
private |
Calculate all points of the curve.
Definition at line 410 of file RocCurve.cpp.
References Log::debug(), and Log::instance().
|
private |
Calculate the total area under the curve.
Definition at line 565 of file RocCurve.cpp.
|
private |
Get model predictions for each sample.
model | Model object to be evaluated. |
sampler | Sampler object with environment, presences and optionally absence points (no absences will trigger the background points approach). |
Definition at line 149 of file RocCurve.cpp.
References Log::debug(), Log::error(), Log::info(), Log::instance(), Sample::size(), and Log::warn().
void RocCurve::calculate | ( | const Model & | model, |
const SamplerPtr & | sampler | ||
) |
Calculate ROC curve given a Model and a Sampler object. This method loads model predictions for all sampler points, calculates all points for the curve and calculates the area under the curve.
model | Model object to be evaluated. |
sampler | Pointer to a Sampler object that will provide data for evaluation. |
Definition at line 131 of file RocCurve.cpp.
References Log::info(), and Log::instance().
Referenced by OpenModeller::calculateModelStatistics(), OpenModeller::getRocCurve(), and main().
ConfigurationPtr RocCurve::getConfiguration | ( | ) | const |
Serialize the ROC curve
Definition at line 739 of file RocCurve.cpp.
Referenced by OpenModeller::getModelConfiguration(), and main().
double RocCurve::getPartialAreaRatio | ( | double | e = 1.0 | ) |
Return the ratio between the area under the curve and the area under the diagonal considering only points where Y is greater than (1 - e), i.e, with omission error less than a specified value. Need to call "calculate" first.
e | Maximum accepted omission error [0,1]. |
Definition at line 615 of file RocCurve.cpp.
References Log::debug(), Log::info(), and Log::instance().
Referenced by OpenModeller::calculateModelStatistics(), and main().
double RocCurve::getTotalArea | ( | ) |
Return the total area under the curve. Need to call "calculate" first.
Definition at line 602 of file RocCurve.cpp.
Referenced by OpenModeller::calculateModelStatistics(), main(), and RequestFile::makeModel().
|
inline |
Return the X axis value for a particular point (1-specificity if absence points were provided, otherwise proportion of background points predicted present). Need to call "calculate" first.
point_index | Point index. |
Definition at line 115 of file RocCurve.hh.
|
inline |
Return the Y axis value of a particular point (sensitivity). Need to call "calculate" first.
point_index | Point index. |
Definition at line 123 of file RocCurve.hh.
void RocCurve::initialize | ( | int | resolution = ROC_DEFAULT_RESOLUTION | ) |
Default initializer. ROC approach will be determined automatically based on sampler data. If only presences are provided, the proportional area approach will be used (with the default number of background points). If presences and absences are provided, the traditional approach will be used.
resolution | Number of points to be calculated for the curve. |
Definition at line 70 of file RocCurve.cpp.
References ROC_DEFAULT_BACKGROUND_POINTS.
Referenced by OpenModeller::calculateModelStatistics(), and main().
void RocCurve::initialize | ( | int | resolution, |
int | num_background_points | ||
) |
Alternative initializer. In this case, the proportional area approach will be used, generating the specified number of background points. If absences are provided, they will be ignored.
resolution | Number of points to be calculated for the curve. |
num_background_points | Number of background points to be generated. |
Definition at line 80 of file RocCurve.cpp.
void RocCurve::initialize | ( | int | resolution, |
bool | use_absences_as_background | ||
) |
Alternative initializer. In this case, the proportional area approach will be used. If use_absences_as_background is true, then absence points will serve as background points, and the number of background points will be the number of absences. If use_absences_as_background is false, background points will be generated in the default number.
resolution | Number of points to be calculated for the curve. |
use_absences_as_background | Indicates if absence points should be used as background points to calculate the proportional area. Internally, when no absence points are provided, background points are randomly generated to use the proportional area approach anyway. |
Definition at line 90 of file RocCurve.cpp.
|
inline |
Return the number of points for the curve.
Definition at line 106 of file RocCurve.hh.
|
inline |
Check whether the ROC curve has been calculated already
Definition at line 144 of file RocCurve.hh.
Referenced by OpenModeller::getModelConfiguration(), OpenModeller::getRocCurve(), and main().
void RocCurve::reset | ( | ) |
Reset all internal values, keeping the same parameters passed in the constructor.
Definition at line 100 of file RocCurve.cpp.
References Log::debug(), and Log::instance().
Referenced by OpenModeller::calculateModelStatistics(), OpenModeller::createModel(), and OpenModeller::setModelConfiguration().
|
private |
Definition at line 195 of file RocCurve.hh.
|
private |
Definition at line 203 of file RocCurve.hh.
|
private |
Definition at line 188 of file RocCurve.hh.
|
private |
Definition at line 191 of file RocCurve.hh.
|
private |
Definition at line 197 of file RocCurve.hh.
|
private |
Definition at line 189 of file RocCurve.hh.
|
private |
Definition at line 209 of file RocCurve.hh.
|
private |
Definition at line 205 of file RocCurve.hh.
|
private |
Definition at line 211 of file RocCurve.hh.
|
private |
Definition at line 193 of file RocCurve.hh.
|
private |
Definition at line 207 of file RocCurve.hh.
|
private |
Definition at line 200 of file RocCurve.hh.
|
private |
Definition at line 201 of file RocCurve.hh.
|
private |
Definition at line 198 of file RocCurve.hh.