aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2018-03-30 22:15:56 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2018-03-30 22:15:56 +0100
commit49ec439a56e55e7a6a170186c6b3d2182e4b1752 (patch)
treedd7be9941fabc3dccf60d0d17f5817ac024ed8d1
parentAdd fitted() method (diff)
downloadrgensvm-49ec439a56e55e7a6a170186c6b3d2182e4b1752.tar.gz
rgensvm-49ec439a56e55e7a6a170186c6b3d2182e4b1752.zip
Add fitted for grid class
-rw-r--r--NAMESPACE1
-rw-r--r--R/fitted.gensvm.grid.R42
-rw-r--r--man/fitted.gensvm.grid.Rd48
3 files changed, 91 insertions, 0 deletions
diff --git a/NAMESPACE b/NAMESPACE
index 1dce540..a9bf594 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -3,6 +3,7 @@
S3method(coef,gensvm)
S3method(coef,gensvm.grid)
S3method(fitted,gensvm)
+S3method(fitted,gensvm.grid)
S3method(plot,gensvm)
S3method(plot,gensvm.grid)
S3method(predict,gensvm)
diff --git a/R/fitted.gensvm.grid.R b/R/fitted.gensvm.grid.R
new file mode 100644
index 0000000..c6887c0
--- /dev/null
+++ b/R/fitted.gensvm.grid.R
@@ -0,0 +1,42 @@
+#' @title Fitted labels for the GenSVMGrid class
+#'
+#' @description Wrapper to get the fitted class labels from the best estimator
+#' of the fitted GenSVMGrid model. Only works if refit was enabled.
+#'
+#' @param grid A \code{gensvm.grid} object
+#' @param \dots further arguments are passed to fitted
+#'
+#' @return a vector of class labels, with the same type as the original class
+#' labels.
+#'
+#' @author
+#' Gerrit J.J. van den Burg, Patrick J.F. Groenen \cr
+#' Maintainer: Gerrit J.J. van den Burg <gertjanvandenburg@gmail.com>
+#'
+#' @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}.
+#'
+#' @seealso
+#' \code{\link{plot.gensvm}}, \code{\link{predict.gensvm.grid}},
+#' \code{\link{gensvm}}, \code{\link{gensvm-package}}
+#'
+#' @export
+#' @aliases fitted
+#'
+#' @examples
+#' x <- iris[, -5]
+#' y <- iris[, 5]
+#'
+#' # fit GenSVM and compute training set predictions
+#' fit <- gensvm(x, y)
+#' yhat <- fitted(fit)
+#'
+#' # compute the accuracy with gensvm.accuracy
+#' gensvm.accuracy(y, yhat)
+#'
+fitted.gensvm.grid <- function(grid, ...)
+{
+ return(predict(grid, ...))
+}
diff --git a/man/fitted.gensvm.grid.Rd b/man/fitted.gensvm.grid.Rd
new file mode 100644
index 0000000..49ebb70
--- /dev/null
+++ b/man/fitted.gensvm.grid.Rd
@@ -0,0 +1,48 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/fitted.gensvm.grid.R
+\name{fitted.gensvm.grid}
+\alias{fitted}
+\alias{fitted.gensvm.grid}
+\title{Fitted labels for the GenSVMGrid class}
+\usage{
+\method{fitted}{gensvm.grid}(grid, ...)
+}
+\arguments{
+\item{grid}{A \code{gensvm.grid} object}
+
+\item{\dots}{further arguments are passed to fitted}
+}
+\value{
+a vector of class labels, with the same type as the original class
+labels.
+}
+\description{
+Wrapper to get the fitted class labels from the best estimator
+of the fitted GenSVMGrid model. Only works if refit was enabled.
+}
+\examples{
+x <- iris[, -5]
+y <- iris[, 5]
+
+# fit GenSVM and compute training set predictions
+fit <- gensvm(x, y)
+yhat <- fitted(fit)
+
+# compute the accuracy with gensvm.accuracy
+gensvm.accuracy(y, yhat)
+
+}
+\author{
+Gerrit J.J. van den Burg, Patrick J.F. Groenen \cr
+Maintainer: Gerrit J.J. van den Burg <gertjanvandenburg@gmail.com>
+}
+\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}.
+}
+\seealso{
+\code{\link{plot.gensvm}}, \code{\link{predict.gensvm.grid}},
+\code{\link{gensvm}}, \code{\link{gensvm-package}}
+}
+