;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; checker-train.lsp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (C) 2004 Statistical Computing Laboratory, University Of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 2004 ;;; ;;; (in-package :quail-user) ;;; The following is the so-called checker training data taken from ;;; Will Welch's STAT441/841 course notes of 2002 ;;; The data is used here to indicate how a linear discriminant ;;; might still work on data if the variables are expanded with ;;; appropriate functions of the original explanatory variates. (<- checker.train (array '(2.04 3.14 1.73 2.53 1.16 1.01 2.55 3.55 2.31 3.53 1.41 3.06 3.72 1.53 0.33 2.34 2 4.71 1.03 1.89 4.55 2.58 1.95 0.39 2.27 7.78 6.41 8.49 7.46 6.36 5.77 5.67 7.1 7.89 8.4 6.79 7.42 9.18 7.12 5.62 3.49 1.84 3.09 3.35 0.97 0.06 3.25 3.54 1.73 1.18 10.11 6.93 6.92 7.95 6.42 1.29 1.66 3.54 0.14 1.15 -2.65 -0.82 0.47 3.39 7.42 4.21 -0.15 6.21 4.22 2.69 4.35 4.44 5.38 2.31 2.02 4.94 3.35 0.7 4.38 4.34 10.98 11.53 9.25 7.81 6.21 7.24 6.72 8.17 6.84 6.76 4.17 8.49 11.02 7.44 6.24 7.73 10.15 7.19 7.27 7.59 3.41 4.23 10.12 8.27 6.32 0.86 -1.54 3.86 3.7 0.38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) :dimensions '(55 3) :fill :col) ) (dataset checker.train :name "Checker training data." :variates '("x1" "x2" "y") :identifiers '("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55") ) (<- checker.train.lda (cglue checker.train (* (ref checker.train T 0) (ref checker.train T 1)) (expt (ref checker.train T 0) 2) (expt (ref checker.train T 1) 2) ) ) (dataset checker.train.lda :name "Checker training data with x1 * x2, x1^2 and x2^2." :variates '("x1" "x2" "y" "x1*x2" "x1^2" "x2^2") :identifiers '("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55") ) ;;; Use the following to distinguish the two groups by ;;; interactively selecting each bar of the histogram ;;; and colouring it in turn. (histogram :data checker.train.lda :var "y" :draw? T :link? T :fill? T) ;;; Here is a plot of the two available explanatory variates (scatterplot :data checker.train.lda :x "x1" :y "x2" :draw? T :link? T) ;;; Coould look at all explanatory variables at once via all pairwise plots (scat-mat :data checker.train.lda :vars (list "x1" "x2" "x1^2" "x2^2" "x1*x2") :draw? T :link? T) ;;; Now look at these in 3d using the quadratic pieces (rotating-plot :data checker.train.lda :vars (list "x1" "x2^2" "x1^2") :draw? T :link? T) (rotating-plot :data checker.train.lda :vars (list "x2" "x1^2" "x2^2") :draw? T :link? T) ;;; The previous plots showed no obvious separating plane ;;; If we look however at the cross product or interaction term "x1*x2" ;;; with the original variates, we see the possibility of having a plane ;;; separate the two groups. (rotating-plot :data checker.train.lda :vars (list "x1" "x2" "x1*x2") :draw? T :link? T)