From bc4d342eb9a7e11ae74003d43e1178b7f3658fa5 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Fri, 30 Mar 2018 22:08:24 +0100 Subject: Add fitted() method --- NAMESPACE | 1 + R/fitted.gensvm.R | 42 ++++++++++++++++++++++++++++++++++++++++++ man/fitted.gensvm.Rd | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 R/fitted.gensvm.R create mode 100644 man/fitted.gensvm.Rd diff --git a/NAMESPACE b/NAMESPACE index 6d37b12..1dce540 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ S3method(coef,gensvm) S3method(coef,gensvm.grid) +S3method(fitted,gensvm) S3method(plot,gensvm) S3method(plot,gensvm.grid) S3method(predict,gensvm) diff --git a/R/fitted.gensvm.R b/R/fitted.gensvm.R new file mode 100644 index 0000000..72b5db6 --- /dev/null +++ b/R/fitted.gensvm.R @@ -0,0 +1,42 @@ +#' @title Show fitted labels for the GenSVM model +#' +#' @description This function shows the fitted class labels of training data +#' using a fitted GenSVM model. +#' +#' @param fit Fitted \code{gensvm} object +#' @param \dots further arguments are passed to predict +#' +#' @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 +#' +#' @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 <- function(fit, ...) +{ + return(predict(fit, ...)) +} diff --git a/man/fitted.gensvm.Rd b/man/fitted.gensvm.Rd new file mode 100644 index 0000000..148b233 --- /dev/null +++ b/man/fitted.gensvm.Rd @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fitted.gensvm.R +\name{fitted.gensvm} +\alias{fitted} +\alias{fitted.gensvm} +\title{Show fitted labels for the GenSVM model} +\usage{ +\method{fitted}{gensvm}(fit, ...) +} +\arguments{ +\item{fit}{Fitted \code{gensvm} object} + +\item{\dots}{further arguments are passed to predict} +} +\value{ +a vector of class labels, with the same type as the original class +labels. +} +\description{ +This function shows the fitted class labels of training data +using a fitted GenSVM model. +} +\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 +} +\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}} +} + -- cgit v1.2.3