Displaying 2 results from an estimated 2 matches for "labelvar".
Did you mean:
labelv
2010 May 17
1
Help with RandomForest
...model to construct a map using the output. My input data are spatial,
and I have an independent set of rasterize maps for each of the predictor
variables, to map the classification solution.
Using the getTree function:
> getTree(randomForest(veg.physical[,-1], veg.physical[,1], ntree = 20, ),
labelVar = TRUE)
returns a "list" with dim(tree) 451 rows x 6 columns.
I assume that other folks using this package and publishing maps have used
this list to link the left and right daughters, split variable, and the
split point back to a map.
Here is a brief example( just the first 6 rows)...
2008 Feb 04
0
SOLVED: use classificators learned in R in "real-life", e.g. C
...rpart or
randomForest, I came to a much simpler and straight-forward solution:
with only a couple of lines, the corresponding c-code for a tree can be
emitted. e.g. for randomForest:
## generate C code from rforests. generate code for tree k
gen_code=function(rfobj,k) {
tree=getTree(rfobj,k,labelVar=TRUE);
count=0;
loc.env=environment();
visit=function(idx) {
assign('count',count+1,env=loc.env);
if (tree[idx,'status']==-1)
cat(sprintf("RETURN(%s)\n",tree[idx,'prediction']))
else {
cat(sprintf("if (GETVAR(%s)<=%f) {...