Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: xclust
See also: cartsplitclass cartsplitregr

Quantlet: carttrimp
Description: returns the measure of tree impurity for both classification/regression tree

Reference(s):

Link:
Usage: Imp = carttrimp(Tree)
Input:
Tree Complex tree structure, list of different parameters Tree can be generated using CartClassificationSplit or CartRegressionSplit commands
Output:
TreeImpurity double between 0 and 1 1) for Classification tree, return the sum of missclassification errors for all terminal nodes 2) for Regression tree, returns the sum of terminal node's variance devided by total variance of the data Both sums are weighted for the number of observations in terminal nodes, i.e. for terminal node with with more observations more weight is assigned.

Example:
library("xclust");
x = #(1,2,3,4,40,50,60,80,90, 100, 110, 300, 500)~#(10,0,40,60,100,1,-91,20,20,34, 1, 3, -5);
y = #(1,1,1,1,2,1,1,2,3,2, 3, 3, 3)
// create tree
tr = cartsplitclass(x, y, 0, 10)
// return number of leaf nodes in the constructed tree
Impurity = carttrimp(tr);
Impurity

Result:
Contents of Impurity
[1,]  0.23077



Author: R. Timofeev, A. Andriyashin 20041215 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006