Predict class for the test set and calculate prediction error after finding the PPtree structure, .
Source:R/PPclassify2.R
PPclassify2.Rd
Predict class for the test set and calculate prediction error after finding the PPtree structure, .
Arguments
- Tree.result
the result of PP.Tree
- test.data
the test dataset
- Rule
split rule 1:mean of two group means, 2:weighted mean, 3: mean of max(left group) and min(right group), 4: weighted mean of max(left group) and min(right group)
- true.class
true class of test dataset if available
References
Lee, YD, Cook, D., Park JW, and Lee, EK(2013) PPtree: Projection pursuit classification tree, Electronic Journal of Statistics, 7:1369-1386.
Examples
#crab data set
Tree.crab <- PPtree_split('Type~.', data = crab, PPmethod = 'LDA', size.p = 0.5)
Tree.crab
#> $Tree.Struct
#> id L.node.ID R.F.node.ID Coef.ID Index
#> [1,] 1 2 3 1 0.8355102
#> [2,] 2 4 5 2 0.3146831
#> [3,] 3 6 7 3 0.6983331
#> [4,] 4 0 4 0 0.0000000
#> [5,] 5 0 3 0 0.0000000
#> [6,] 6 0 2 0 0.0000000
#> [7,] 7 0 1 0 0.0000000
#>
#> $projbest.node
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] -0.7569527 0.0000000 -0.3091091 0.575738 0.0000000
#> [2,] 0.8821206 0.0000000 -0.2211300 0.000000 -0.4158904
#> [3,] 0.0000000 0.9202723 -0.3734248 0.000000 0.1168454
#>
#> $splitCutoff.node
#> Rule1 Rule2 Rule3 Rule4 Rule5 Rule6 Rule7
#> 1 -0.7544874 -0.7544874 -0.6154436 -0.6154436 -0.7648766 -0.7648766 -0.5880624
#> 2 1.1036784 1.1036784 1.0526596 1.0526596 1.0890368 1.0890368 1.0697875
#> 3 1.2228713 1.2228713 1.3260548 1.3260548 1.2439543 1.2439543 1.3654261
#> Rule8
#> 1 -0.5880624
#> 2 1.0697875
#> 3 1.3654261
#>
#> $origclass
#> [1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [38] 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 4 4 4 4
#> [112] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
#> [149] 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
#> [186] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
#>
#> $origdata
#> FL RW CL CW BD
#> [1,] 8.1 6.7 16.1 19.0 7.0
#> [2,] 8.8 7.7 18.1 20.8 7.4
#> [3,] 9.2 7.8 19.0 22.4 7.7
#> [4,] 9.6 7.9 20.1 23.1 8.2
#> [5,] 9.8 8.0 20.3 23.0 8.2
#> [6,] 10.8 9.0 23.0 26.5 9.8
#> [7,] 11.1 9.9 23.8 27.1 9.8
#> [8,] 11.6 9.1 24.5 28.4 10.4
#> [9,] 11.8 9.6 24.2 27.8 9.7
#> [10,] 11.8 10.5 25.2 29.3 10.3
#> [11,] 12.2 10.8 27.3 31.6 10.9
#> [12,] 12.3 11.0 26.8 31.5 11.4
#> [13,] 12.6 10.0 27.7 31.7 11.4
#> [14,] 12.8 10.2 27.2 31.8 10.9
#> [15,] 12.8 10.9 27.4 31.5 11.0
#> [16,] 12.9 11.0 26.8 30.9 11.4
#> [17,] 13.1 10.6 28.2 32.3 11.0
#> [18,] 13.1 10.9 28.3 32.4 11.2
#> [19,] 13.3 11.1 27.8 32.3 11.3
#> [20,] 13.9 11.1 29.2 33.3 12.1
#> [21,] 14.3 11.6 31.3 35.5 12.7
#> [22,] 14.6 11.3 31.9 36.4 13.7
#> [23,] 15.0 10.9 31.4 36.4 13.2
#> [24,] 15.0 11.5 32.4 37.0 13.4
#> [25,] 15.0 11.9 32.5 37.2 13.6
#> [26,] 15.2 12.1 32.3 36.7 13.6
#> [27,] 15.4 11.8 33.0 37.5 13.6
#> [28,] 15.7 12.6 35.8 40.3 14.5
#> [29,] 15.9 12.7 34.0 38.9 14.2
#> [30,] 16.1 11.6 33.8 39.0 14.4
#> [31,] 16.1 12.8 34.9 40.7 15.7
#> [32,] 16.2 13.3 36.0 41.7 15.4
#> [33,] 16.3 12.7 35.6 40.9 14.9
#> [34,] 16.4 13.0 35.7 41.8 15.2
#> [35,] 16.6 13.5 38.1 43.4 14.9
#> [36,] 16.8 12.8 36.2 41.8 14.9
#> [37,] 16.9 13.2 37.3 42.7 15.6
#> [38,] 17.1 12.6 36.4 42.0 15.1
#> [39,] 17.1 12.7 36.7 41.9 15.6
#> [40,] 17.2 13.5 37.6 43.9 16.1
#> [41,] 17.7 13.6 38.7 44.5 16.0
#> [42,] 17.9 14.1 39.7 44.6 16.8
#> [43,] 18.0 13.7 39.2 44.4 16.2
#> [44,] 18.8 15.8 42.1 49.0 17.8
#> [45,] 19.3 13.5 41.6 47.4 17.8
#> [46,] 19.3 13.8 40.9 46.5 16.8
#> [47,] 19.7 15.3 41.9 48.5 17.8
#> [48,] 19.8 14.2 43.2 49.7 18.6
#> [49,] 19.8 14.3 42.4 48.9 18.3
#> [50,] 21.3 15.7 47.1 54.6 20.0
#> [51,] 7.2 6.5 14.7 17.1 6.1
#> [52,] 9.0 8.5 19.3 22.7 7.7
#> [53,] 9.1 8.1 18.5 21.6 7.7
#> [54,] 9.1 8.2 19.2 22.2 7.7
#> [55,] 9.5 8.2 19.6 22.4 7.8
#> [56,] 9.8 8.9 20.4 23.9 8.8
#> [57,] 10.1 9.3 20.9 24.4 8.4
#> [58,] 10.3 9.5 21.3 24.7 8.9
#> [59,] 10.4 9.7 21.7 25.4 8.3
#> [60,] 10.8 9.5 22.5 26.3 9.1
#> [61,] 11.0 9.8 22.5 25.7 8.2
#> [62,] 11.2 10.0 22.8 26.9 9.4
#> [63,] 11.5 11.0 24.7 29.2 10.1
#> [64,] 11.6 11.0 24.6 28.5 10.4
#> [65,] 11.6 11.4 23.7 27.7 10.0
#> [66,] 11.7 10.6 24.9 28.5 10.4
#> [67,] 11.9 11.4 26.0 30.1 10.9
#> [68,] 12.0 10.7 24.6 28.9 10.5
#> [69,] 12.0 11.1 25.4 29.2 11.0
#> [70,] 12.6 12.2 26.1 31.6 11.2
#> [71,] 12.8 11.7 27.1 31.2 11.9
#> [72,] 12.8 12.2 26.7 31.1 11.1
#> [73,] 12.8 12.2 27.9 31.9 11.5
#> [74,] 13.0 11.4 27.3 31.8 11.3
#> [75,] 13.1 11.5 27.6 32.6 11.1
#> [76,] 13.2 12.2 27.9 32.1 11.5
#> [77,] 13.4 11.8 28.4 32.7 11.7
#> [78,] 13.7 12.5 28.6 33.8 11.9
#> [79,] 13.9 13.0 30.0 34.9 13.1
#> [80,] 14.7 12.5 30.1 34.7 12.5
#> [81,] 14.9 13.2 30.1 35.6 12.0
#> [82,] 15.0 13.8 31.7 36.9 14.0
#> [83,] 15.0 14.2 32.8 37.4 14.0
#> [84,] 15.1 13.3 31.8 36.3 13.5
#> [85,] 15.1 13.5 31.9 37.0 13.8
#> [86,] 15.1 13.8 31.7 36.6 13.0
#> [87,] 15.2 14.3 33.9 38.5 14.7
#> [88,] 15.3 14.2 32.6 38.3 13.8
#> [89,] 15.4 13.3 32.4 37.6 13.8
#> [90,] 15.5 13.8 33.4 38.7 14.7
#> [91,] 15.6 13.9 32.8 37.9 13.4
#> [92,] 15.6 14.7 33.9 39.5 14.3
#> [93,] 15.7 13.9 33.6 38.5 14.1
#> [94,] 15.8 15.0 34.5 40.3 15.3
#> [95,] 16.2 15.2 34.5 40.1 13.9
#> [96,] 16.4 14.0 34.2 39.8 15.2
#> [97,] 16.7 16.1 36.6 41.9 15.4
#> [98,] 17.4 16.9 38.2 44.1 16.6
#> [99,] 17.5 16.7 38.6 44.5 17.0
#> [100,] 19.2 16.5 40.9 47.9 18.1
#> [101,] 9.1 6.9 16.7 18.6 7.4
#> [102,] 10.2 8.2 20.2 22.2 9.0
#> [103,] 10.7 8.6 20.7 22.7 9.2
#> [104,] 11.4 9.0 22.7 24.8 10.1
#> [105,] 12.5 9.4 23.2 26.0 10.8
#> [106,] 12.5 9.4 24.2 27.0 11.2
#> [107,] 12.7 10.4 26.0 28.8 12.1
#> [108,] 13.2 11.0 27.1 30.4 12.2
#> [109,] 13.4 10.1 26.6 29.6 12.0
#> [110,] 13.7 11.0 27.5 30.5 12.2
#> [111,] 14.0 11.5 29.2 32.2 13.1
#> [112,] 14.1 10.4 28.9 31.8 13.5
#> [113,] 14.1 10.5 29.1 31.6 13.1
#> [114,] 14.1 10.7 28.7 31.9 13.3
#> [115,] 14.2 10.6 28.7 31.7 12.9
#> [116,] 14.2 10.7 27.8 30.9 12.7
#> [117,] 14.2 11.3 29.2 32.2 13.5
#> [118,] 14.6 11.3 29.9 33.5 12.8
#> [119,] 14.7 11.1 29.0 32.1 13.1
#> [120,] 15.1 11.4 30.2 33.3 14.0
#> [121,] 15.1 11.5 30.9 34.0 13.9
#> [122,] 15.4 11.1 30.2 33.6 13.5
#> [123,] 15.7 12.2 31.7 34.2 14.2
#> [124,] 16.2 11.8 32.3 35.3 14.7
#> [125,] 16.3 11.6 31.6 34.2 14.5
#> [126,] 17.1 12.6 35.0 38.9 15.7
#> [127,] 17.4 12.8 36.1 39.5 16.2
#> [128,] 17.5 12.0 34.4 37.3 15.3
#> [129,] 17.5 12.7 34.6 38.4 16.1
#> [130,] 17.8 12.5 36.0 39.8 16.7
#> [131,] 17.9 12.9 36.9 40.9 16.5
#> [132,] 18.0 13.4 36.7 41.3 17.1
#> [133,] 18.2 13.7 38.8 42.7 17.2
#> [134,] 18.4 13.4 37.9 42.2 17.7
#> [135,] 18.6 13.4 37.8 41.9 17.3
#> [136,] 18.6 13.5 36.9 40.2 17.0
#> [137,] 18.8 13.4 37.2 41.1 17.5
#> [138,] 18.8 13.8 39.2 43.3 17.9
#> [139,] 19.4 14.1 39.1 43.2 17.8
#> [140,] 19.4 14.4 39.8 44.3 17.9
#> [141,] 20.1 13.7 40.6 44.5 18.0
#> [142,] 20.6 14.4 42.8 46.5 19.6
#> [143,] 21.0 15.0 42.9 47.2 19.4
#> [144,] 21.5 15.5 45.5 49.7 20.9
#> [145,] 21.6 15.4 45.7 49.7 20.6
#> [146,] 21.6 14.8 43.4 48.2 20.1
#> [147,] 21.9 15.7 45.4 51.0 21.1
#> [148,] 22.1 15.8 44.6 49.6 20.5
#> [149,] 23.0 16.8 47.2 52.1 21.5
#> [150,] 23.1 15.7 47.6 52.8 21.6
#> [151,] 10.7 9.7 21.4 24.0 9.8
#> [152,] 11.4 9.2 21.7 24.1 9.7
#> [153,] 12.5 10.0 24.1 27.0 10.9
#> [154,] 12.6 11.5 25.0 28.1 11.5
#> [155,] 12.9 11.2 25.8 29.1 11.9
#> [156,] 14.0 11.9 27.0 31.4 12.6
#> [157,] 14.0 12.8 28.8 32.4 12.7
#> [158,] 14.3 12.2 28.1 31.8 12.5
#> [159,] 14.7 13.2 29.6 33.4 12.9
#> [160,] 14.9 13.0 30.0 33.7 13.3
#> [161,] 15.0 12.3 30.1 33.3 14.0
#> [162,] 15.6 13.5 31.2 35.1 14.1
#> [163,] 15.6 14.0 31.6 35.3 13.8
#> [164,] 15.6 14.1 31.0 34.5 13.8
#> [165,] 15.7 13.6 31.0 34.8 13.8
#> [166,] 16.1 13.6 31.6 36.0 14.0
#> [167,] 16.1 13.7 31.4 36.1 13.9
#> [168,] 16.2 14.0 31.6 35.6 13.7
#> [169,] 16.7 14.3 32.3 37.0 14.7
#> [170,] 17.1 14.5 33.1 37.2 14.6
#> [171,] 17.5 14.3 34.5 39.6 15.6
#> [172,] 17.5 14.4 34.5 39.0 16.0
#> [173,] 17.5 14.7 33.3 37.6 14.6
#> [174,] 17.6 14.0 34.0 38.6 15.5
#> [175,] 18.0 14.9 34.7 39.5 15.7
#> [176,] 18.0 16.3 37.9 43.0 17.2
#> [177,] 18.3 15.7 35.1 40.5 16.1
#> [178,] 18.4 15.5 35.6 40.0 15.9
#> [179,] 18.4 15.7 36.5 41.6 16.4
#> [180,] 18.5 14.6 37.0 42.0 16.6
#> [181,] 18.6 14.5 34.7 39.4 15.0
#> [182,] 18.8 15.2 35.8 40.5 16.6
#> [183,] 18.9 16.7 36.3 41.7 15.3
#> [184,] 19.1 16.0 37.8 42.3 16.8
#> [185,] 19.1 16.3 37.9 42.6 17.2
#> [186,] 19.7 16.7 39.9 43.6 18.2
#> [187,] 19.9 16.6 39.4 43.9 17.9
#> [188,] 19.9 17.9 40.1 46.4 17.9
#> [189,] 20.0 16.7 40.4 45.1 17.7
#> [190,] 20.1 17.2 39.8 44.1 18.6
#> [191,] 20.3 16.0 39.4 44.1 18.0
#> [192,] 20.5 17.5 40.0 45.5 19.2
#> [193,] 20.6 17.5 41.5 46.2 19.2
#> [194,] 20.9 16.5 39.9 44.7 17.5
#> [195,] 21.3 18.4 43.8 48.4 20.0
#> [196,] 21.4 18.0 41.2 46.2 18.7
#> [197,] 21.7 17.1 41.7 47.2 19.6
#> [198,] 21.9 17.2 42.6 47.4 19.5
#> [199,] 22.5 17.2 43.0 48.7 19.8
#> [200,] 23.1 20.2 46.2 52.5 21.1
#>
#> attr(,"class")
#> [1] "list" "PPtreeclass"
PPclassify2(Tree.crab)
#> $predict.error
#> [1] NA
#>
#> $predict.class
#> [,1]
#> [1,] 2
#> [2,] 2
#> [3,] 2
#> [4,] 2
#> [5,] 2
#> [6,] 2
#> [7,] 1
#> [8,] 2
#> [9,] 2
#> [10,] 1
#> [11,] 2
#> [12,] 1
#> [13,] 2
#> [14,] 2
#> [15,] 2
#> [16,] 1
#> [17,] 2
#> [18,] 2
#> [19,] 2
#> [20,] 2
#> [21,] 2
#> [22,] 2
#> [23,] 2
#> [24,] 2
#> [25,] 2
#> [26,] 2
#> [27,] 2
#> [28,] 2
#> [29,] 2
#> [30,] 2
#> [31,] 2
#> [32,] 2
#> [33,] 2
#> [34,] 2
#> [35,] 2
#> [36,] 2
#> [37,] 2
#> [38,] 2
#> [39,] 2
#> [40,] 2
#> [41,] 2
#> [42,] 2
#> [43,] 2
#> [44,] 2
#> [45,] 2
#> [46,] 2
#> [47,] 2
#> [48,] 2
#> [49,] 2
#> [50,] 2
#> [51,] 2
#> [52,] 1
#> [53,] 1
#> [54,] 1
#> [55,] 2
#> [56,] 1
#> [57,] 1
#> [58,] 1
#> [59,] 1
#> [60,] 1
#> [61,] 1
#> [62,] 1
#> [63,] 1
#> [64,] 1
#> [65,] 1
#> [66,] 1
#> [67,] 1
#> [68,] 1
#> [69,] 1
#> [70,] 1
#> [71,] 1
#> [72,] 1
#> [73,] 1
#> [74,] 1
#> [75,] 1
#> [76,] 1
#> [77,] 1
#> [78,] 1
#> [79,] 1
#> [80,] 1
#> [81,] 1
#> [82,] 1
#> [83,] 1
#> [84,] 1
#> [85,] 1
#> [86,] 1
#> [87,] 1
#> [88,] 1
#> [89,] 1
#> [90,] 1
#> [91,] 1
#> [92,] 1
#> [93,] 1
#> [94,] 1
#> [95,] 1
#> [96,] 1
#> [97,] 1
#> [98,] 1
#> [99,] 1
#> [100,] 1
#> [101,] 3
#> [102,] 4
#> [103,] 4
#> [104,] 4
#> [105,] 3
#> [106,] 4
#> [107,] 4
#> [108,] 4
#> [109,] 4
#> [110,] 4
#> [111,] 4
#> [112,] 4
#> [113,] 4
#> [114,] 4
#> [115,] 4
#> [116,] 4
#> [117,] 4
#> [118,] 4
#> [119,] 3
#> [120,] 4
#> [121,] 4
#> [122,] 3
#> [123,] 4
#> [124,] 4
#> [125,] 3
#> [126,] 4
#> [127,] 4
#> [128,] 3
#> [129,] 4
#> [130,] 4
#> [131,] 4
#> [132,] 4
#> [133,] 4
#> [134,] 4
#> [135,] 4
#> [136,] 3
#> [137,] 4
#> [138,] 4
#> [139,] 4
#> [140,] 4
#> [141,] 3
#> [142,] 4
#> [143,] 4
#> [144,] 4
#> [145,] 4
#> [146,] 4
#> [147,] 4
#> [148,] 3
#> [149,] 4
#> [150,] 4
#> [151,] 4
#> [152,] 3
#> [153,] 3
#> [154,] 4
#> [155,] 4
#> [156,] 3
#> [157,] 4
#> [158,] 3
#> [159,] 4
#> [160,] 4
#> [161,] 4
#> [162,] 4
#> [163,] 4
#> [164,] 3
#> [165,] 3
#> [166,] 3
#> [167,] 3
#> [168,] 3
#> [169,] 3
#> [170,] 3
#> [171,] 3
#> [172,] 3
#> [173,] 3
#> [174,] 3
#> [175,] 3
#> [176,] 1
#> [177,] 3
#> [178,] 3
#> [179,] 3
#> [180,] 3
#> [181,] 3
#> [182,] 3
#> [183,] 3
#> [184,] 3
#> [185,] 3
#> [186,] 4
#> [187,] 3
#> [188,] 1
#> [189,] 3
#> [190,] 3
#> [191,] 3
#> [192,] 3
#> [193,] 4
#> [194,] 3
#> [195,] 4
#> [196,] 3
#> [197,] 3
#> [198,] 3
#> [199,] 3
#> [200,] 3
#>