Commit fe0716dd authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

make other probabilist metrics uppercase

Showing with 49 additions and 49 deletions
+49 -49
......@@ -42,7 +42,7 @@ namespace evalhyd
// check that the metrics to be computed are valid
utils::check_metrics(
metrics,
{"bs", "bss", "bs_crd", "bs_lbd", "QS", "CRPS"}
{"BS", "BSS", "BS_CRD", "BS_LBD", "QS", "CRPS"}
);
// instantiate probabilist evaluator
......@@ -53,14 +53,14 @@ namespace evalhyd
std::unordered_map<std::string, std::vector<std::string>> dep;
// register potentially recurring computation elements across metrics
elt["bs"] = {"o_k", "y_k"};
elt["bss"] = {"o_k", "bar_o"};
elt["bs_crd"] = {"o_k", "bar_o", "y_k"};
elt["bs_lbd"] = {"o_k", "y_k"};
elt["qs"] = {"q_qnt"};
elt["BS"] = {"o_k", "y_k"};
elt["BSS"] = {"o_k", "bar_o"};
elt["BS_CRD"] = {"o_k", "bar_o", "y_k"};
elt["BS_LBD"] = {"o_k", "y_k"};
elt["QS"] = {"q_qnt"};
// register nested metrics (i.e. metric dependent on another metric)
dep["bss"] = {"bs"};
dep["BSS"] = {"BS"};
dep["QS"] = {"qs"};
dep["CRPS"] = {"qs", "crps"};
......@@ -86,8 +86,8 @@ namespace evalhyd
// pre-compute required dep
for (const auto& dependency : req_dep)
{
if ( dependency == "bs" )
evaluator.calc_bs();
if ( dependency == "BS" )
evaluator.calc_BS();
else if ( dependency == "qs" )
evaluator.calc_qs();
else if ( dependency == "crps" )
......@@ -99,33 +99,33 @@ namespace evalhyd
for (const auto& metric : metrics)
{
if ( metric == "bs" )
if ( metric == "BS" )
{
if (std::find(req_dep.begin(), req_dep.end(), metric)
== req_dep.end())
evaluator.calc_bs();
r.emplace_back(evaluator.bs);
evaluator.calc_BS();
r.emplace_back(evaluator.BS);
}
else if ( metric == "bss" )
else if ( metric == "BSS" )
{
if (std::find(req_dep.begin(), req_dep.end(), metric)
== req_dep.end())
evaluator.calc_bss();
r.emplace_back(evaluator.bss);
evaluator.calc_BSS();
r.emplace_back(evaluator.BSS);
}
else if ( metric == "bs_crd" )
else if ( metric == "BS_CRD" )
{
if (std::find(req_dep.begin(), req_dep.end(), metric)
== req_dep.end())
evaluator.calc_bs_crd();
r.emplace_back(evaluator.bs_crd);
evaluator.calc_BS_CRD();
r.emplace_back(evaluator.BS_CRD);
}
else if ( metric == "bs_lbd" )
else if ( metric == "BS_LBD" )
{
if (std::find(req_dep.begin(), req_dep.end(), metric)
== req_dep.end())
evaluator.calc_bs_lbd();
r.emplace_back(evaluator.bs_lbd);
evaluator.calc_BS_LBD();
r.emplace_back(evaluator.BS_LBD);
}
else if ( metric == "QS" )
{
......
......@@ -34,10 +34,10 @@ namespace evalhyd
xt::xtensor<double, 2> crps;
// members for evaluation metrics
xt::xtensor<double, 2> bs;
xt::xtensor<double, 2> bs_crd;
xt::xtensor<double, 2> bs_lbd;
xt::xtensor<double, 2> bss;
xt::xtensor<double, 2> BS;
xt::xtensor<double, 2> BS_CRD;
xt::xtensor<double, 2> BS_LBD;
xt::xtensor<double, 2> BSS;
xt::xtensor<double, 2> QS;
xt::xtensor<double, 2> CRPS;
......@@ -54,10 +54,10 @@ namespace evalhyd
void calc_crps();
// methods to compute metrics
void calc_bs();
void calc_bs_crd();
void calc_bs_lbd();
void calc_bss();
void calc_BS();
void calc_BS_CRD();
void calc_BS_LBD();
void calc_BSS();
void calc_QS();
void calc_CRPS();
};
......
......@@ -25,14 +25,14 @@ namespace evalhyd
// \require y_k:
// Event probability forecast.
// shape: (thresholds, time)
// \assign bs:
// \assign BS:
// 2D array of Brier score for each threshold.
// shape: (thresholds, 1)
void Evaluator::calc_bs()
void Evaluator::calc_BS()
{
// return computed Brier score(s)
// $BS = \frac{1}{n} \sum_{k=1}^{n} (o_k - y_k)^2$
bs = xt::mean(xt::square(o_k - y_k), -1, xt::keep_dims);
BS = xt::mean(xt::square(o_k - y_k), -1, xt::keep_dims);
}
// Compute the calibration-refinement decomposition of the Brier score
......@@ -49,11 +49,11 @@ namespace evalhyd
// \require y_k:
// Event probability forecast.
// shape: (thresholds, time)
// \assign bs_crd:
// \assign BS_CRD:
// 2D array of Brier score components (reliability, resolution,
// uncertainty) for each threshold.
// shape: (thresholds, components)
void Evaluator::calc_bs_crd()
void Evaluator::calc_BS_CRD()
{
// declare internal variables
// shape: (bins, thresholds, time)
......@@ -71,7 +71,7 @@ namespace evalhyd
// initialise output variable
// shape: (components, thresholds)
bs_crd = xt::zeros<double>({n_thr, n_cmp});
BS_CRD = xt::zeros<double>({n_thr, n_cmp});
// compute range of forecast values $y_i$
y_i = xt::arange<double>(double(n_mbr + 1)) / n_mbr;
......@@ -103,7 +103,7 @@ namespace evalhyd
// calculate reliability =
// $\frac{1}{n} \sum_{i=1}^{I} N_i (y_i - \bar{o_i})^2$
xt::col(bs_crd, 0) =
xt::col(BS_CRD, 0) =
xt::sum(
xt::square(
xt::view(y_i, xt::all(), xt::newaxis())
......@@ -114,7 +114,7 @@ namespace evalhyd
// calculate resolution =
// $\frac{1}{n} \sum_{i=1}^{I} N_i (\bar{o_i} - \bar{o})^2$
xt::col(bs_crd, 1) =
xt::col(BS_CRD, 1) =
xt::sum(
xt::square(
bar_o_i - bar_o
......@@ -123,7 +123,7 @@ namespace evalhyd
) / n;
// calculate uncertainty = $\bar{o} (1 - \bar{o})$
xt::col(bs_crd, 2) = bar_o * (1 - bar_o);
xt::col(BS_CRD, 2) = bar_o * (1 - bar_o);
}
// Compute the likelihood-base rate decomposition of the Brier score
......@@ -137,11 +137,11 @@ namespace evalhyd
// \require y_k:
// Event probability forecast.
// shape: (thresholds, time)
// \return bs_lbd:
// \return BS_LBD:
// 2D array of Brier score components (type 2 bias, discrimination,
// sharpness) for each threshold.
// shape: (thresholds, components)
void Evaluator::calc_bs_lbd()
void Evaluator::calc_BS_LBD()
{
// declare internal variables
// shape: (bins, thresholds, time)
......@@ -160,7 +160,7 @@ namespace evalhyd
// declare and initialise output variable
// shape: (components, thresholds)
bs_lbd = xt::zeros<double>({n_thr, n_cmp});
BS_LBD = xt::zeros<double>({n_thr, n_cmp});
// set the range of observed values $o_j$
o_j = {0., 1.};
......@@ -196,7 +196,7 @@ namespace evalhyd
// calculate type 2 bias =
// $\frac{1}{n} \sum_{j=1}^{J} M_j (o_j - \bar{y_j})^2$
xt::col(bs_lbd, 0) =
xt::col(BS_LBD, 0) =
xt::sum(
xt::square(
xt::view(o_j, xt::all(), xt::newaxis())
......@@ -207,7 +207,7 @@ namespace evalhyd
// calculate discrimination =
// $\frac{1}{n} \sum_{j=1}^{J} M_j (\bar{y_j} - \bar{y})^2$
xt::col(bs_lbd, 1) =
xt::col(BS_LBD, 1) =
xt::sum(
xt::square(
bar_y_j - bar_y
......@@ -217,7 +217,7 @@ namespace evalhyd
// calculate sharpness =
// $\frac{1}{n} \sum_{k=1}^{n} (\bar{y_k} - \bar{y})^2$
xt::col(bs_lbd, 2) =
xt::col(BS_LBD, 2) =
xt::sum(
xt::square(
y_k -
......@@ -235,13 +235,13 @@ namespace evalhyd
// \require bar_o:
// Mean event observed outcome.
// shape: (thresholds,)
// \require bs:
// \require BS:
// Brier score(s).
// shape: (thresholds,)
// \assign bss:
// \assign BSS:
// 2D array of Brier skill score for each threshold.
// shape: (thresholds, 1)
void Evaluator::calc_bss()
void Evaluator::calc_BSS()
{
// calculate reference Brier score(s)
// $BS_{ref} = \frac{1}{n} \sum_{k=1}^{n} (o_k - \bar{o})^2$
......@@ -256,7 +256,7 @@ namespace evalhyd
// return computed Brier skill score(s)
// $BSS = 1 - \frac{BS}{BS_{ref}}
bss = 1 - (bs / bs_ref);
BSS = 1 - (BS / bs_ref);
}
}
}
......@@ -24,7 +24,7 @@ TEST(ProbabilistTests, TestBrier) {
std::vector<xt::xtensor<double, 2>> metrics =
evalhyd::probabilist::evaluate(
{"bs", "bss", "bs_crd", "bs_lbd"},
{"BS", "BSS", "BS_CRD", "BS_LBD"},
xt::transpose(observed), xt::transpose(forecast),
thresholds
);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment