SHOGUN
v1.1.0
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
shogun
evaluation
MeanSquaredError.cpp
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2011 Sergey Lisitsyn
8
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9
*/
10
11
#include <
shogun/evaluation/MeanSquaredError.h
>
12
#include <
shogun/features/Labels.h
>
13
#include <
shogun/mathematics/Math.h
>
14
15
using namespace
shogun;
16
17
float64_t
CMeanSquaredError::evaluate
(
CLabels
* predicted,
CLabels
* ground_truth)
18
{
19
ASSERT
(predicted->
get_num_labels
() == ground_truth->
get_num_labels
());
20
int32_t length = predicted->
get_num_labels
();
21
float64_t
mse = 0.0;
22
for
(int32_t i=0; i<length; i++)
23
mse +=
CMath::sq
(predicted->
get_label
(i) - ground_truth->
get_label
(i));
24
mse /= length;
25
return
mse;
26
}
Math.h
shogun::CLabels
The class Labels models labels, i.e. class assignments of objects.
Definition:
Labels.h:35
shogun::CMath::sq
static T sq(T x)
x^2
Definition:
Math.h:277
shogun::CLabels::get_num_labels
int32_t get_num_labels()
Definition:
Labels.cpp:240
ASSERT
#define ASSERT(x)
Definition:
SGIO.h:102
shogun::CMeanSquaredError::evaluate
virtual float64_t evaluate(CLabels *predicted, CLabels *ground_truth)
Definition:
MeanSquaredError.cpp:17
float64_t
double float64_t
Definition:
common.h:56
shogun::CLabels::get_label
float64_t get_label(int32_t idx)
Definition:
Labels.cpp:223
Labels.h
MeanSquaredError.h
SHOGUN
Machine Learning Toolbox - Documentation