summaryrefslogtreecommitdiff
path: root/training/risk.h
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-06-26 14:47:46 +0200
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-06-26 14:47:46 +0200
commit55cafb1189cac406aa0e5c4fc7d8fd57da69c9a4 (patch)
treead24c01bcda6f835432cd08798dbb52e24c71961 /training/risk.h
parentea2c5fb04f69844fe81101283deaaf69a63ce865 (diff)
parent9c1dd817177331baeea66441861682fa29cf0262 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'training/risk.h')
-rw-r--r--training/risk.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/training/risk.h b/training/risk.h
new file mode 100644
index 00000000..2e8db0fb
--- /dev/null
+++ b/training/risk.h
@@ -0,0 +1,26 @@
+#ifndef _RISK_H_
+#define _RISK_H_
+
+#include <vector>
+#include "sparse_vector.h"
+class EvaluationMetric;
+
+namespace training {
+ class CandidateSet;
+
+ class CandidateSetRisk {
+ public:
+ explicit CandidateSetRisk(const CandidateSet& cs, const EvaluationMetric& metric) :
+ cands_(cs),
+ metric_(metric) {}
+ // compute the risk (expected loss) of a CandidateSet
+ // (optional) the gradient of the risk with respect to params
+ double operator()(const std::vector<double>& params,
+ SparseVector<double>* g = NULL) const;
+ private:
+ const CandidateSet& cands_;
+ const EvaluationMetric& metric_;
+ };
+};
+
+#endif