SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LossFunction.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
3  embodied in the content of this file are licensed under the BSD
4  (revised) open source license.
5 
6  Copyright (c) 2011 Berlin Institute of Technology and Max-Planck-Society.
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  Modifications (w) 2011 Shashwat Lal Das
14  Modifications (w) 2012 Fernando José Iglesias García
15 */
16 
17 #ifndef _LOSSFUNCTION_H__
18 #define _LOSSFUNCTION_H__
19 
20 #include <shogun/lib/config.h>
21 
22 #include <shogun/base/SGObject.h>
23 #include <shogun/lib/common.h>
24 #include <math.h>
25 
26 namespace shogun
27 {
29  enum ELossType
30  {
38  L_LOGLOSS = 100,
40  };
41 }
42 
43 namespace shogun
44 {
58 class CLossFunction: public CSGObject
59 {
60 public:
61 
66 
70  virtual ~CLossFunction() {};
71 
80  virtual float64_t loss(float64_t prediction, float64_t label)
81  {
82  return loss(prediction * label);
83  }
84 
92  virtual float64_t loss(float64_t z) = 0;
93 
102  virtual float64_t first_derivative(float64_t prediction, float64_t label)
103  {
104  return loss(prediction * label);
105  }
106 
114  virtual float64_t first_derivative(float64_t z) = 0;
115 
124  virtual float64_t second_derivative(float64_t prediction, float64_t label)
125  {
126  return loss(prediction * label);
127  }
128 
136  virtual float64_t second_derivative(float64_t z) = 0;
137 
148  virtual float64_t get_update(float64_t prediction, float64_t label, float64_t eta_t, float64_t norm) = 0;
149 
158  virtual float64_t get_square_grad(float64_t prediction, float64_t label) = 0;
159 
167  virtual ELossType get_loss_type()=0;
168 
174  virtual const char* get_name() const { return "LossFunction"; }
175 };
176 }
177 #endif // _LOSSFUNCTION_H__

SHOGUN Machine Learning Toolbox - Documentation