DivideM {lazy.tree} | R Documentation |
This function searches the average division of a given subset
by resmpling the subset.
Japanese help file: DivideM_JPH
DivideM(
ys,
Xs,
Ys = NULL,
impfunc,
S,
method = 1,
ncatx = 0,
app = 0,
maxapp = 10,
maxncut = 50,
levelsy = NULL,
levelsX = NULL,
majestic = 3,
nrepM = 50,
psampleM = 100,
rf = 1,
nxvarM = if (!is.null(ys) && !is.factor(ys)) max(floor(ncol(Xs)/3), 1) else
floor(sqrt(ncol(Xs))),
minLeftM = 0.5,
maxRightM = 0.5,
r = 0,
debug = 0
)
ys |
Criterion variable vector |
Xs |
Regressor matrix |
Ys |
The dichotomized criterion matrix for |
impfunc |
impurity function |
S |
Index vector indicating the original location of the rows of ys and X. |
method |
Treatment of the categorical regressor variable. |
ncatx |
Vector consisting of the # of cagegories of the regressors |
app |
= 0 not to use app (all possible partitions) |
maxapp |
Maximum # of categories of the regressor variables for which app is used. |
maxncut |
Maximum # of cut point (threshold) candidate |
levelsy |
# of levels of the criterion |
majestic |
> 0 to use within node resampling: |
nrepM |
# of divisions to try for majestic tree |
psampleM |
percentage of the sample for majestic tree |
rf |
= 0 not to sample regressor variables |
nxvarM |
# of variables to sample for majestic tree (Random Forest) |
minLeftM |
minimum proportion of x values to be classified as Left |
maxRightM |
maximum proportion of x values to be classified as Right |
r |
node number |
debug |
= 1 to print intermediate result |
levelsx |
a list of the # of levels of the regressors |
ncat=0
or ncat=1
means the variable is continuous,
ncat=2
means the variable is binary,
ncat >= 3
means the variable is polytomous.
A list consisting of the following:
j: the variable number used to divide the set threshold: the threshold of variable j when it is continuous valxj: the set of values of nominal variable j to be classified as left. Note that this is a numeric variable, not a factor. k: quantified variable number used or 0 nqx: # of unique quantified variables left: the set of observations classified as left right: the set of observations classified as right left.score: The nobs weighted impurity measure of left set right.score: The nobs weighted impurity measure of right set score: The sum of the above two.
N=500
Xc=data.frame(x1=as.factor(square3$x1), x2=square3$x2)
yc=as.factor(square3$y)
Xc=Xc[1:N,]
yc=yc[1:N]
S=1:N
maxncatx=max( apply( Xc, 2, function(x){length(unique(x))} ) )
ncaty=length(levels(yc))
id=gen01pat( ncaty, sort=-2, partition=1 ) == 1 # logical matrix
npart=nrow(id)
uy=unique(yc)
Yc=matrix(0,N,npart)
for(k in 1:npart ){
Yc[,k]=yc %in% uy[id[k,]]
}
nx=ncol(Xc)
ncatx=rep(0,nx)
for( j in 1:nx ){
if( is.factor(Xc[,j]) ) ncatx[j]=length(levels(Xc[,j]))
}
res00=DivideM( yc, Xc, Y=Yc, impfunc=entropy, S, method=1, ncatx=ncatx
, app=0, maxapp=10, maxncut=50
, levelsy=NULL, levelsX=NULL
, psampleM=100, nrepM=20, r=0 )