SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
LossFunction.h
浏览该文件的文档.
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 
25 namespace shogun
26 {
28  enum ELossType
29  {
37  L_LOGLOSS = 100,
39  };
40 }
41 
42 namespace shogun
43 {
57 class CLossFunction: public CSGObject
58 {
59 public:
60 
65 
69  virtual ~CLossFunction() {};
70 
79  virtual float64_t loss(float64_t prediction, float64_t label)
80  {
81  return loss(prediction * label);
82  }
83 
91  virtual float64_t loss(float64_t z) = 0;
92 
101  virtual float64_t first_derivative(float64_t prediction, float64_t label)
102  {
103  return loss(prediction * label);
104  }
105 
113  virtual float64_t first_derivative(float64_t z) = 0;
114 
123  virtual float64_t second_derivative(float64_t prediction, float64_t label)
124  {
125  return loss(prediction * label);
126  }
127 
135  virtual float64_t second_derivative(float64_t z) = 0;
136 
147  virtual float64_t get_update(float64_t prediction, float64_t label, float64_t eta_t, float64_t norm) = 0;
148 
157  virtual float64_t get_square_grad(float64_t prediction, float64_t label) = 0;
158 
166  virtual ELossType get_loss_type()=0;
167 
173  virtual const char* get_name() const { return "LossFunction"; }
174 };
175 }
176 #endif // _LOSSFUNCTION_H__
double norm(double *v, double p, int n)
Definition: epph.cpp:452
Class CLossFunction is the base class of all loss functions.
Definition: LossFunction.h:57
virtual ~CLossFunction()
Definition: LossFunction.h:69
virtual float64_t get_update(float64_t prediction, float64_t label, float64_t eta_t, float64_t norm)=0
virtual ELossType get_loss_type()=0
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
double float64_t
Definition: common.h:50
virtual const char * get_name() const
Definition: LossFunction.h:173
virtual float64_t loss(float64_t prediction, float64_t label)
Definition: LossFunction.h:79
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float64_t second_derivative(float64_t prediction, float64_t label)
Definition: LossFunction.h:123
virtual float64_t first_derivative(float64_t prediction, float64_t label)
Definition: LossFunction.h:101
ELossType
shogun loss type
Definition: LossFunction.h:28
virtual float64_t get_square_grad(float64_t prediction, float64_t label)=0

SHOGUN 机器学习工具包 - 项目文档