Reputation: 2868
Iam using this command in R for building decision trees :
> library(party)
> ind = sample(2,nrow(iris),replace=TRUE,prob=c(0.8,0.2))
> myFormula <- Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width
> iris_ctree <- ctree(myFormula,data = iris[ind==1,])
> predict(iris_ctree)
What exactly does predict function compute and how does it perform the computation?
Upvotes: 1
Views: 4075
Reputation: 5167
the example first constructs "ind" based on a sampling of 1's with probability .8 and 2's with probability .2. It then specifies a Formula that defines the hypothesis function for the model. It then fits the conditional inference tree to the estimate the parameters based on the hypothesis specification using the sampled data - which is just the data containing 1's.
It then runs a prediction based on the full sample of 1's and 2's.
So basically it trained on 1's, but runs predict on 1's and 2's.
Upvotes: 1