00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2011 Shashwat Lal Das 00008 * Copyright (c) 2011 Berlin Institute of Technohingey and Max-Planck-Society. 00009 */ 00010 00011 #include <shogun/loss/SquaredHingeLoss.h> 00012 00013 using namespace shogun; 00014 00015 float64_t CSquaredHingeLoss::loss(float64_t prediction, float64_t label) 00016 { 00017 float64_t z = prediction * label; 00018 if (z < 1) 00019 return 0.5 * (1-z) * (1-z); 00020 return 0; 00021 } 00022 00023 float64_t CSquaredHingeLoss::first_derivative(float64_t prediction, float64_t label) 00024 { 00025 float64_t z = prediction * label; 00026 if (z < 1) 00027 return z-1; 00028 return 0; 00029 } 00030 00031 float64_t CSquaredHingeLoss::second_derivative(float64_t prediction, float64_t label) 00032 { 00033 float64_t z = prediction * label; 00034 if (z < 1) 00035 return 1; 00036 return 0; 00037 } 00038 00039 float64_t CSquaredHingeLoss::get_update(float64_t prediction, float64_t label, float64_t eta_t, float64_t norm) 00040 { 00041 SG_NOTIMPLEMENTED; 00042 return -1; 00043 } 00044 00045 float64_t CSquaredHingeLoss::get_square_grad(float64_t prediction, float64_t label) 00046 { 00047 SG_NOTIMPLEMENTED; 00048 return -1; 00049 }