Some styling changes

This commit is contained in:
Sudhakar Brar
2020-11-26 08:10:12 +01:00
parent 83466773cd
commit 30a1dbcb28
3 changed files with 8 additions and 5 deletions
+4 -1
View File
@@ -42,6 +42,9 @@ namespace cv {
* where @f$ \bar{y} = frac{1}{y}\sum_{i=1}^{n} y_i @f$.
* For example, a model having R2Score = 0.85, explains 85 \% variability of
* the response data around its mean.
*
* @tparam AdjustedR2 If true, then the Adjusted R2 score will be used.
* Otherwise, the regular R2 score is used.
*/
template<bool AdjustedR2>
@@ -49,7 +52,7 @@ class R2Score
{
public:
/**
* Run prediction and calculate the R squared or Adjusted R sauared error.
* Run prediction and calculate the R squared or Adjusted R squared error.
*
* @param model A regression model.
* @param data Column-major data containing test items.
+4 -3
View File
@@ -18,8 +18,8 @@ namespace cv {
template<bool AdjustedR2>
template<typename MLAlgorithm, typename DataType, typename ResponsesType>
double R2Score<AdjustedR2>::Evaluate(MLAlgorithm& model,
const DataType& data,
const ResponsesType& responses)
const DataType& data,
const ResponsesType& responses)
{
if (data.n_cols != responses.n_cols)
{
@@ -50,7 +50,8 @@ double R2Score<AdjustedR2>::Evaluate(MLAlgorithm& model,
return totalSumSquared ? 1.0 : DBL_MIN;
// Returning adjusted R-squared.
double rsq = 1 - (residualSumSquared / totalSumSquared);
return (1 - ((1 - rsq) * ((data.n_cols - 1) / (data.n_cols - data.n_rows - 1))));
return (1 - ((1 - rsq) * ((data.n_cols - 1) /
(data.n_cols - data.n_rows - 1))));
}
else
{
-1
View File
@@ -212,7 +212,6 @@ TEST_CASE("AdjR2ScoreTest", "[CVTest]")
<= 1e-7);
}
/**
* Test the mean squared error with matrix responses.
*/