search for: numclass

Displaying 5 results from an estimated 5 matches for "numclass".

Did you mean: mclass
2009 Apr 30
1
unexpected behavior of rpart 3.1-43, loss matrix
...p = ".")))(Y, offset, parms, wt) : Wrong length for loss matrix note that while the levels of the factor range from 1:6, for the concrete obseration data, only levels 1, 2, 3, 5 do occur. the error is caused by the code of rpart.class: fy <- as.factor(y) y <- as.integer(fy) numclass <- max(y[!is.na(y)]) ... temp2 <- parms$loss if (length(temp2) != numclass^2) stop("Wrong length for loss matrix") for the example, numclass is set to 5 instead of 6. while for that small example, it may be discussable whether or not numclass should be 6, consider a set of da...
2002 Jan 25
0
rpart subsets
...ro. Here is the change to gini.c: #if 1 // Bob's simple fix // This fixes a problem when predicting a categorical using a subset. // The subset may be missing one or more of the categories. Here // we make any zeros a very small number so that the rpart run will not fail. for (i=0; i<numclass; i++) { if (freq[i] == 0) freq[i] = 0.00000000001; } #endif for (i=0; i<numclass; i++) { prior[i] /= freq[i]; aprior[i] /= (temp * freq[i]); /* pi_i / n_i */ } } The calculation of the priors (existing code) above shows where I put the fix in giniinit (in gini.c...
2002 Jan 28
0
rpart subset fix
...ro. Here is the change to gini.c: #if 1 // Bob's simple fix // This fixes a problem when predicting a categorical using a subset. // The subset may be missing one or more of the categories. Here // we make any zeros a very small number so that the rpart run will not fail. for (i=0; i<numclass; i++) { if (freq[i] == 0) freq[i] = 0.00000000001; } #endif for (i=0; i<numclass; i++) { prior[i] /= freq[i]; aprior[i] /= (temp * freq[i]); /* pi_i / n_i */ } } The calculation of the priors (existing code) above shows where I put the fix in giniinit (in gini.c...
2002 Mar 13
0
rpart error with 0-frequency factor levels (with partial fix) (PR#1378)
...----------- I tried to trace the problem, and took a look at the beginning of rpart.class: "rpart.class" <- function (y, offset, parms, wt) { if (!is.null(offset)) stop("No offset allowed in classification models") fy <- as.factor(y) y <- as.integer(fy) numclass <- max(y[!is.na(y)]) ... } I thought the problem might have to do with the fact that numclass would register 3 for my examples t3 and t5, but 2 for my examples t2 and t4. So I tried substituting numclass <- length(unique(y[!is.na(y)])) to get the number of factors present rather than the...
2006 Nov 30
0
extending data.frame with S4 class
...te an instance, I get something that looks and acts like a numeric. When I extend "data.frame" and create an instance, I get a NULL 'core'. Why is this, and can it be fixed? setOldClass(), prototype=, and initialize() don't seem to help. Thanks, Tim ---- setClass("numClass",representation("numeric",num="numeric")) nn <- new("numClass",2,num=1) nn nn+1 setClass("dfClass",representation("data.frame",num="numeric")) df <- new("dfClass",as.data.frame(BOD),num=1) df