slope 0.29.0
Loading...
Searching...
No Matches
score.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "losses/loss.h"
9#include <Eigen/Core>
10#include <memory>
11
12namespace slope {
13
25double
26binaryRocAuc(const Eigen::VectorXd& scores, const Eigen::VectorXd& labels);
27
41double
42rocAuc(const Eigen::MatrixXd& scores, const Eigen::MatrixXd& labels);
43
52class Score
53{
54public:
55 virtual ~Score() = default;
56
63 virtual bool isWorse(double other, double current) const = 0;
64
69 virtual double initValue() const = 0;
70
75 std::function<bool(double, double)> getComparator() const;
76
84 virtual double eval(const Eigen::MatrixXd& eta,
85 const Eigen::MatrixXd& y,
86 const std::unique_ptr<Loss>& loss) const = 0;
87
93 static std::unique_ptr<Score> create(const std::string& metric);
94};
95
103class MinimizeScore : public Score
104{
105public:
112 bool isWorse(double a, double b) const override;
113
118 double initValue() const override;
119};
120
128class MaximizeScore : public Score
129{
130public:
137 bool isWorse(double a, double b) const override;
138
143 double initValue() const override;
144};
145
159class MSE : public MinimizeScore
160{
161public:
168 double eval(const Eigen::MatrixXd& eta,
169 const Eigen::MatrixXd& y,
170 const std::unique_ptr<Loss>&) const override;
171};
172
189class MAE : public MinimizeScore
190{
191public:
198 double eval(const Eigen::MatrixXd& eta,
199 const Eigen::MatrixXd& y,
200 const std::unique_ptr<Loss>&) const override;
201};
202
217{
218public:
226 double eval(const Eigen::MatrixXd& eta,
227 const Eigen::MatrixXd& y,
228 const std::unique_ptr<Loss>& loss) const override;
229};
230
247{
248public:
256 double eval(const Eigen::MatrixXd& eta,
257 const Eigen::MatrixXd& y,
258 const std::unique_ptr<Loss>& loss) const override;
259};
260
273{
274public:
282 double eval(const Eigen::MatrixXd& eta,
283 const Eigen::MatrixXd& y,
284 const std::unique_ptr<Loss>& loss) const override;
285};
286
304class AUC : public MaximizeScore
305{
306public:
314 double eval(const Eigen::MatrixXd& eta,
315 const Eigen::MatrixXd& y,
316 const std::unique_ptr<Loss>& loss) const override;
317};
318
319} // namespace slope
Area Under the ROC Curve (AUC-ROC) scoring metric.
Definition score.h:305
double eval(const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &loss) const override
Definition score.cpp:173
Classification Accuracy scoring metric.
Definition score.h:217
double eval(const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &loss) const override
Definition score.cpp:143
Deviance scoring metric.
Definition score.h:273
double eval(const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &loss) const override
Definition score.cpp:165
Mean Absolute Error (MAE) scoring metric.
Definition score.h:190
double eval(const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &) const override
Definition score.cpp:135
Mean Squared Error (MSE) scoring metric.
Definition score.h:160
double eval(const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &) const override
Definition score.cpp:127
Scoring metric that aims to maximize the score value.
Definition score.h:129
bool isWorse(double a, double b) const override
Definition score.cpp:115
double initValue() const override
Definition score.cpp:121
Scoring metric that aims to minimize the score value.
Definition score.h:104
double initValue() const override
Definition score.cpp:109
bool isWorse(double a, double b) const override
Definition score.cpp:103
Misclassification Rate scoring metric.
Definition score.h:247
double eval(const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &loss) const override
Definition score.cpp:155
Base class for scoring metrics used in regularized generalized linear regression.
Definition score.h:53
std::function< bool(double, double)> getComparator() const
Definition score.cpp:97
virtual bool isWorse(double other, double current) const =0
static std::unique_ptr< Score > create(const std::string &metric)
Definition score.cpp:182
virtual double eval(const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &loss) const =0
virtual double initValue() const =0
The declartion of the Objctive class and its subclasses, which represent the data-fitting part of the...
Namespace containing SLOPE regression implementation.
Definition clusters.cpp:5
double binaryRocAuc(const Eigen::VectorXd &scores, const Eigen::VectorXd &labels)
Definition score.cpp:10
double rocAuc(const Eigen::MatrixXd &scores, const Eigen::MatrixXd &labels)
Definition score.cpp:54