histogram.train {caret}R Documentation

Lattice functions for plotting resampling results

Description

A set of lattice functions are provided to plot the resampled performance estimates (e.g. classification accuracy, RMSE) over tuning parameters (if any).

Usage

## S3 method for class 'train':
histogram(x, data = NULL, metric = x$metric, ...)

## S3 method for class 'train':
densityplot(x, data = NULL, metric = x$metric, ...)

## S3 method for class 'train':
xyplot(x, data = NULL, metric = x$metric, ...)

## S3 method for class 'train':
stripplot(x, data = NULL, metric = x$metric, ...)

Arguments

x An object produced by train
data This argument is not used
metric A character string specifying the single performance metric that will be plotted
... arguments to pass to either histogram, densityplot, xyplot or stripplot

Details

By default, only the resampling results for the optimal model are saved in the train object. The function trainControl can be used to save all the results (see the example below).

If leave-one-out or out-of-bag resampling was specified, plots cannot be produced (see the method argument of trainControl)

For xyplot and stripplot, the tuning parameter with the most unique values will be plotted on the x-axis. The remaining parameters (if any) will be used as conditioning variables. For densityplot and histogram, all tuning parameters are used for conditioning.

Using horizontal = FALSE in stripplot works.

Value

A lattice plot object

Author(s)

Max Kuhn

See Also

train, trainControl, histogram, densityplot, xyplot, stripplot

Alias

stripplot.train, xyplot.train, densityplot.train, histogram.train

Keyword

hplot

Examples

library(mlbench)
data(BostonHousing)

library(rpart)
rpartFit <- train(medv ~ .,
                  data = BostonHousing,
                  "rpart", 
                  tuneLength = 9,
                  trControl = trainControl(
                    method = "boot", 
                    returnResamp = "all"))

densityplot(rpartFit,
            adjust = 1.25)

xyplot(rpartFit,
       metric = "Rsquared",
       type = c("p", "a"))

stripplot(rpartFit,
          horizontal = FALSE,
          jitter = TRUE)

Results


R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

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(caret)
> png(filename="images/lattice_%03d.png" ,width=480, height=480)
> ### Name: histogram.train
> ### Title: Lattice functions for plotting resampling results
> ### Aliases: stripplot.train xyplot.train densityplot.train histogram.train
> ### Keywords: hplot
> 
> ### ** Examples
> 
> library(mlbench)
> data(BostonHousing)
> 
> library(rpart)
> rpartFit <- train(medv ~ .,
+                   data = BostonHousing,
+                   "rpart", 
+                   tuneLength = 9,
+                   trControl = trainControl(
+                     method = "boot", 
+                     returnResamp = "all"))
Fitting: maxdepth=9 
> 
> densityplot(rpartFit,
+             adjust = 1.25)
> 
> xyplot(rpartFit,
+        metric = "Rsquared",
+        type = c("p", "a"))
> 
> stripplot(rpartFit,
+           horizontal = FALSE,
+           jitter = TRUE)
> 
> 
> 
> dev.off()
null device 
          1 
> 




[Package caret Index]