SHOGUN
v1.1.0
|
00001 /* 00002 Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights 00003 embodied in the content of this file are licensed under the BSD 00004 (revised) open source license. 00005 00006 Copyright (c) 2011 Berlin Institute of Technology and Max-Planck-Society. 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 Modifications (w) 2011 Shashwat Lal Das 00014 */ 00015 00016 #ifndef _LOSSFUNCTION_H__ 00017 #define _LOSSFUNCTION_H__ 00018 00019 #include <shogun/base/SGObject.h> 00020 #include <shogun/lib/common.h> 00021 #include <math.h> 00022 00023 namespace shogun 00024 { 00026 enum ELossType 00027 { 00028 L_HINGELOSS = 0, 00029 L_SMOOTHHINGELOSS = 10, 00030 L_SQUAREDHINGELOSS = 20, 00031 L_SQUAREDLOSS = 30, 00032 L_LOGLOSS = 100, 00033 L_LOGLOSSMARGIN = 110 00034 }; 00035 } 00036 00037 namespace shogun 00038 { 00052 class CLossFunction: public CSGObject 00053 { 00054 public: 00055 00059 CLossFunction(): CSGObject() {} 00060 00064 virtual ~CLossFunction() {}; 00065 00074 virtual float64_t loss(float64_t prediction, float64_t label) = 0; 00075 00084 virtual float64_t first_derivative(float64_t prediction, float64_t label) = 0; 00085 00094 virtual float64_t second_derivative(float64_t prediction, float64_t label) = 0; 00095 00106 virtual float64_t get_update(float64_t prediction, float64_t label, float64_t eta_t, float64_t norm) = 0; 00107 00116 virtual float64_t get_square_grad(float64_t prediction, float64_t label) = 0; 00117 00125 virtual ELossType get_loss_type()=0; 00126 00132 virtual const char* get_name() const { return "LossFunction"; } 00133 }; 00134 } 00135 #endif // _LOSSFUNCTION_H__