Last data update: 2014.03.03

R: prediction function for tsp.gbm
predict.tsp.gbmR Documentation

prediction function for tsp.gbm

Description

prediction function for tsp.gbm

Usage

## S3 method for class 'tsp.gbm'
predict(object, newdata, n.trees, type = "link", single.tree = FALSE, ...)

Arguments

object

a tsp.gbm object

newdata

new data matrix

n.trees

Number of trees used in the prediction. n.trees may be a vector in which case predictions are returned for each iteration specified

type

The scale on which gbm makes the predictions

single.tree

If single.tree=TRUE then predict.tsp.gbm returns only the predictions from tree(s) n.trees

...

not used.

Author(s)

Xiaolin Yang, Han Liu

References

gbm package

Examples

library(gbm)
x=matrix(rnorm(100*20),100,20)
y=rbinom(100,1,0.5)
fit=tsp.gbm(x,y)
predict(fit,x[1:10,],n.trees=5)

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.gbm.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predict.tsp.gbm
> ### Title: prediction function for tsp.gbm
> ### Aliases: predict.tsp.gbm
> ### Keywords: ~kwd1 ~kwd2
> 
> ### ** Examples
> 
> library(gbm)
> x=matrix(rnorm(100*20),100,20)
> y=rbinom(100,1,0.5)
> fit=tsp.gbm(x,y)
Iter   TrainDeviance   ValidDeviance   StepSize   Improve
     1        1.3825            -nan     0.0010    0.0000
     2        1.3824            -nan     0.0010    0.0000
     3        1.3823            -nan     0.0010   -0.0000
     4        1.3822            -nan     0.0010    0.0000
     5        1.3820            -nan     0.0010    0.0000
     6        1.3818            -nan     0.0010   -0.0000
     7        1.3815            -nan     0.0010    0.0000
     8        1.3813            -nan     0.0010    0.0001
     9        1.3811            -nan     0.0010   -0.0000
    10        1.3808            -nan     0.0010    0.0001
    20        1.3793            -nan     0.0010   -0.0000
    40        1.3761            -nan     0.0010   -0.0000
    60        1.3733            -nan     0.0010    0.0000
    80        1.3704            -nan     0.0010   -0.0001
   100        1.3673            -nan     0.0010   -0.0001

Warning message:
In gbm.fit(newx, y, offset = offset, misc = misc, distribution = distribution,  :
  Parameter 'train.fraction' of gbm.fit is deprecated, please specify 'nTrain' instead
> predict(fit,x[1:10,],n.trees=5)
 [1] -0.1203752 -0.1159165 -0.1159165 -0.1173633 -0.1159165 -0.1204180
 [7] -0.1218282 -0.1202272 -0.1173633 -0.1218710
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>