# # Written by: # -- # John L. Weatherwax 2007-07-05 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- yf = seq( -2, +2, length.out=100 ) #postscript("../../WriteUp/Graphics/Chapter10/dup_fig_10_4.eps", onefile=FALSE, horizontal=FALSE) # Missclassification loss: # miss_classification_loss = rep( 0, length(yf) ) miss_classification_loss[ yf<0 ] = 1.0 plot( yf, miss_classification_loss, type="l", col="gray", xlim=c(-2,+2), ylim=c(0,3), xlab="y f", ylab="loss" ) # Exponential loss: # exp_loss = exp( - yf ) lines( yf, exp_loss, type="l", col="cyan" ) # Binomial deviance (try all possible "scalings"): # lines( yf, log( 1 + exp( -2 * yf ) )/log(2), type="l", col="orange" ) # here we "scale" binomial deviance ###t = + 0.5 * log( exp(1) - 1 ) ###lines( yf, log( 1 + exp( -2 * (yf-t) ) ), type="l", col="orange" ) # here we shift the x-axis of binomial deviance ###lines( yf, log( 1 + exp( -2 * yf ) ) - log(2) + 1, type="l", col="orange" ) # here we shift the y-axis of binomial deviance # Squared Error loss: # lines( yf, ( 1 - yf )^2, type="l", col="red" ) # Hinge loss: # hinge_loss = 1 - yf hinge_loss[ hinge_loss<0 ] = 0 lines( yf, hinge_loss, type="l", col="darkgreen" ) #dev.off()