Last data update: 2014.03.03

R: prediction function for tsp.tree
predict.tsp.treeR Documentation

prediction function for tsp.tree

Description

prediction function for tsp.tree

Usage

## S3 method for class 'tsp.tree'
predict(object, newdata, type = c("vector", "tree", "class", "where"), split = FALSE, nwts, eps = 0.001, ...)

Arguments

object

a tsp.tree object

newdata

new data matrix

type

character string denoting whether the predictions are returned as a vector (default) or as a tsp.tree object.

split

governs the handling of missing values. If false, cases with missing values are dropped down the tree until a leaf is reached or a node for which the attribute is missing, and that node is used for prediction. If split = TRUE cases with missing attributes are split into fractional cases and dropped down each side of the split. The predicted values are averaged over the fractions to give the prediction.

nwts

weights for the newdata cases, used when predicting a tsp.tree.

eps

a lower bound for the probabilities, used if events of predicted probability zero occur in newdata when predicting a tree.

...

other arguments.

Author(s)

Xiaolin Yang, Han Liu

Examples

library(tree)
x=matrix(rnorm(100*20),100,20)
y=rbinom(100,1,0.5)
y=as.factor(y)
data=data.frame(y,x)
tr=tsp.tree(x,y)
predict(tr,data[1:10,])

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(BigTSP)
Loading required package: glmnet
Loading required package: Matrix
Loading required package: foreach
Loaded glmnet 2.0-5

Loading required package: tree
Loading required package: randomForest
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
Loading required package: gbm
Loading required package: survival
Loading required package: lattice
Loading required package: splines
Loading required package: parallel
Loaded gbm 2.1.1
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BigTSP/predict.tsp.tree.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predict.tsp.tree
> ### Title: prediction function for tsp.tree
> ### Aliases: predict.tsp.tree
> ### Keywords: ~kwd1 ~kwd2
> 
> ### ** Examples
> 
> library(tree)
> x=matrix(rnorm(100*20),100,20)
> y=rbinom(100,1,0.5)
> y=as.factor(y)
> data=data.frame(y,x)
> tr=tsp.tree(x,y)
> predict(tr,data[1:10,])
     0   1
1  1.0 0.0
2  0.6 0.4
3  0.0 1.0
4  1.0 0.0
5  1.0 0.0
6  0.5 0.5
7  0.0 1.0
8  0.0 1.0
9  0.0 1.0
10 0.0 1.0
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>