SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MeanAbsoluteError.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  * Copyright (C) 2011 Soeren Sonnenburg, Sergey Lisitsyn
8  */
9 
11 #include <shogun/features/Labels.h>
13 
14 using namespace shogun;
15 
17 {
18  ASSERT(predicted->get_num_labels() == ground_truth->get_num_labels());
19  int32_t length = predicted->get_num_labels();
20  float64_t mae = 0.0;
21  for (int32_t i=0; i<length; i++)
22  mae += CMath::abs(predicted->get_label(i) - ground_truth->get_label(i));
23  mae /= length;
24  return mae;
25 }

SHOGUN Machine Learning Toolbox - Documentation