SmoothHingeLoss.cpp

Go to the documentation of this file.
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/SmoothHingeLoss.h>
00012 
00013 using namespace shogun;
00014 
00015 float64_t CSmoothHingeLoss::loss(float64_t prediction, float64_t label)
00016 {
00017     float64_t z = prediction * label;
00018     if (z < 0)
00019         return 0.5 - z;
00020     if (z < 1)
00021         return 0.5 * (1-z) * (1-z);
00022     return 0;
00023 }
00024 
00025 float64_t CSmoothHingeLoss::first_derivative(float64_t prediction, float64_t label)
00026 {
00027     float64_t z = prediction * label;
00028     if (z < 0)
00029         return -1;
00030     if (z < 1)
00031         return z-1;
00032     return 0;
00033 }
00034 
00035 float64_t CSmoothHingeLoss::second_derivative(float64_t prediction, float64_t label)
00036 {
00037     float64_t z = prediction * label;
00038     if (z < 0)
00039         return 0;
00040     if (z < 1)
00041         return 1;
00042     return 0;
00043 }
00044 
00045 float64_t CSmoothHingeLoss::get_update(float64_t prediction, float64_t label, float64_t eta_t, float64_t norm)
00046 {
00047     SG_NOTIMPLEMENTED;
00048     return -1;
00049 }
00050 
00051 float64_t CSmoothHingeLoss::get_square_grad(float64_t prediction, float64_t label)
00052 {
00053     SG_NOTIMPLEMENTED;
00054     return -1;
00055 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation