|
a |
|
b/partyMod/man/ctree_memory.Rd |
|
|
1 |
\name{Memory Allocation} |
|
|
2 |
\alias{ctree_memory} |
|
|
3 |
\title{ Memory Allocation } |
|
|
4 |
\description{ |
|
|
5 |
|
|
|
6 |
This function sets up the memory needed for tree growing. It might be |
|
|
7 |
convenient to allocate memory only once but build multiple trees. |
|
|
8 |
} |
|
|
9 |
\usage{ |
|
|
10 |
ctree_memory(object, MPinv = FALSE) |
|
|
11 |
} |
|
|
12 |
\arguments{ |
|
|
13 |
\item{object}{an object of class \code{LearningSample}.} |
|
|
14 |
\item{MPinv}{a logical indicating whether memory for the Moore-Penrose |
|
|
15 |
inverse of covariance matrices should be allocated. } |
|
|
16 |
} |
|
|
17 |
\details{ |
|
|
18 |
|
|
|
19 |
This function is normally not to be called by users. However, for |
|
|
20 |
performance reasons it might be nice to allocate memory and re-fit trees |
|
|
21 |
using the same memory for the computations. Below is an example. |
|
|
22 |
|
|
|
23 |
} |
|
|
24 |
\value{ |
|
|
25 |
An object of class \code{TreeFitMemory}. |
|
|
26 |
} |
|
|
27 |
\examples{ |
|
|
28 |
|
|
|
29 |
set.seed(290875) |
|
|
30 |
|
|
|
31 |
### setup learning sample |
|
|
32 |
airq <- subset(airquality, !is.na(Ozone)) |
|
|
33 |
ls <- dpp(conditionalTree, Ozone ~ ., data = airq) |
|
|
34 |
|
|
|
35 |
### setup memory and controls |
|
|
36 |
mem <- ctree_memory(ls) |
|
|
37 |
ct <- ctree_control(teststat = "max") |
|
|
38 |
|
|
|
39 |
### fit 50 trees on bootstrap samples |
|
|
40 |
bs <- rmultinom(50, nrow(airq), rep(1, nrow(airq))/nrow(airq)) |
|
|
41 |
storage.mode(bs) <- "double" |
|
|
42 |
cfit <- conditionalTree@fit |
|
|
43 |
ens <- apply(bs, 2, function(w) cfit(ls, ct, weights = w, |
|
|
44 |
fitmem = mem)) |
|
|
45 |
|
|
|
46 |
} |
|
|
47 |
\keyword{misc} |