SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
evaluation
MeanSquaredError.cpp
浏览该文件的文档.
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/labels/Labels.h
>
13
#include <
shogun/labels/RegressionLabels.h
>
14
#include <
shogun/mathematics/Math.h
>
15
16
using namespace
shogun;
17
18
float64_t
CMeanSquaredError::evaluate
(
CLabels
* predicted,
CLabels
* ground_truth)
19
{
20
ASSERT
(predicted && ground_truth)
21
ASSERT
(predicted->
get_num_labels
() == ground_truth->
get_num_labels
())
22
ASSERT
(predicted->
get_label_type
() ==
LT_REGRESSION
)
23
ASSERT
(ground_truth->
get_label_type
() ==
LT_REGRESSION
)
24
int32_t length = predicted->
get_num_labels
();
25
float64_t
mse = 0.0;
26
for
(int32_t i=0; i<length; i++)
27
mse +=
CMath::sq
(((
CRegressionLabels
*) predicted)->get_label(i) - ((
CRegressionLabels
*) ground_truth)->get_label(i));
28
mse /= length;
29
return
mse;
30
}
SHOGUN
机器学习工具包 - 项目文档