SHOGUN  6.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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  */
12 #include <shogun/labels/Labels.h>
16 using namespace shogun;
19 {
20  REQUIRE(predicted, "Predicted labels must be not null.\n")
21  REQUIRE(ground_truth, "Ground truth labels must be not null.\n")
22  REQUIRE(predicted->get_num_labels() == ground_truth->get_num_labels(), "The number of predicted labels (%d) must be equal to the number of ground truth labels (%d).\n")
23  REQUIRE(predicted->get_label_type() == LT_REGRESSION, "Predicted label type (%d) must be regression (%d).\n", predicted->get_label_type(), LT_REGRESSION)
24  REQUIRE(ground_truth->get_label_type() == LT_REGRESSION, "Ground truth label type (%d) must be regression (%d).\n", ground_truth->get_label_type(), LT_REGRESSION)
25  int32_t length = predicted->get_num_labels();
26  float64_t mse = 0.0;
27  for (int32_t i=0; i<length; i++)
28  mse += CMath::sq(((CRegressionLabels*) predicted)->get_label(i) - ((CRegressionLabels*) ground_truth)->get_label(i));
29  mse /= length;
30  return mse;
31 }
virtual ELabelType get_label_type() const =0
Real Labels are real-valued labels.
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
virtual int32_t get_num_labels() const =0
real valued labels (e.g. for regression, classifier outputs)
Definition: LabelTypes.h:22
static T sq(T x)
Definition: Math.h:445
#define REQUIRE(x,...)
Definition: SGIO.h:205
virtual float64_t evaluate(CLabels *predicted, CLabels *ground_truth)
double float64_t
Definition: common.h:60
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18

SHOGUN Machine Learning Toolbox - Documentation