From 004941896bac692d354c41a3334d20ee1d4627f7 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Tue, 27 Mar 2018 12:31:28 +0100 Subject: GenSVM R package --- R/plot.gensvm.grid.R | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 R/plot.gensvm.grid.R (limited to 'R/plot.gensvm.grid.R') diff --git a/R/plot.gensvm.grid.R b/R/plot.gensvm.grid.R new file mode 100644 index 0000000..da101e6 --- /dev/null +++ b/R/plot.gensvm.grid.R @@ -0,0 +1,39 @@ +#' @title Plot the simplex space of the best fitted model in the GenSVMGrid +#' +#' @description This is a wrapper which calls the plot function for the best +#' model in the provided GenSVMGrid object. See the documentation for +#' \code{\link{plot.gensvm}} for more information. +#' +#' @param grid A \code{gensvm.grid} object trained with refit=TRUE +#' @param x the dataset to plot +#' @param ... further arguments are passed to the plot function +#' +#' @return returns the object passed as input +#' +#' @export +#' +#' @author +#' Gerrit J.J. van den Burg, Patrick J.F. Groenen \cr +#' Maintainer: Gerrit J.J. van den Burg +#' +#' @references +#' Van den Burg, G.J.J. and Groenen, P.J.F. (2016). \emph{GenSVM: A Generalized +#' Multiclass Support Vector Machine}, Journal of Machine Learning Research, +#' 17(225):1--42. URL \url{http://jmlr.org/papers/v17/14-526.html}. +#' +#' @examples +#' x <- iris[, -5] +#' y <- iris[, 5] +#' +#' grid <- gensvm.grid(x, y) +#' plot(grid, x) +#' +plot.gensvm.grid <- function(grid, x, ...) +{ + if (is.null(grid$best.estimator)) { + cat("Error: Can't plot, the best.estimator element is NULL\n") + return + } + fit <- grid$best.estimator + return(plot(fit, x, ...)) +} -- cgit v1.2.3