# $Id: ltplots.R,v 1.1 2007/10/02 10:43:07 kaip Exp $ # # # Copyright (c) 2007 Kai Puolamaki # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # # # T-61.3050 Machine Learning: Basic Principles # Stupid example for the 3/2007 lecture # # This is just "schematic illustration", therefore choose some functions # that "look right". pdf("ltcomplexity.pdf") plot(c(0,1),c(0,1),type="n",xlab="model complexity",ylab="error",xaxt="n",yaxt="n") x <- 0:200/200 lines(x,pmax(0,0.5*exp(-5*x)-.01),lty="solid") lines(x,.1+2*(x-.5)*(x-.5)*exp(x/2),lty="dashed") legend(x="topright",legend=c("test set","training set"),lty=c("dashed","solid"),bg="white") dev.off() pdf("ltdatasize.pdf") plot(c(0,1),c(0,1),type="n",xlab="training set size",ylab="error",xaxt="n",yaxt="n") x <- 0:200/200 lines(x,pmax(0,.3-exp(-5*x)),lty="solid") lines(x,.3+exp(-5*x),lty="dashed") legend(x="topright",legend=c("test set","training set"),lty=c("dashed","solid"),bg="white") dev.off()