From 75d6ed3e5d919b4e5b7bd1e81283131c92530d26 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Wed, 28 Mar 2018 13:41:14 +0100 Subject: Validate params in gensvm() function Parameter validation was only done for some parameters in the gensvm() function and for the parameter grid in gensvm.grid() With this commit the parameters will be tested properly for both functions. --- R/gensvm.R | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'R/gensvm.R') diff --git a/R/gensvm.R b/R/gensvm.R index 32ab61b..cc30b4b 100644 --- a/R/gensvm.R +++ b/R/gensvm.R @@ -133,21 +133,16 @@ gensvm <- function(X, y, p=1.0, lambda=1e-8, kappa=0.0, epsilon=1e-6, if (gamma == 'auto') gamma <- 1.0/n.features + if (!gensvm.validate.params(p=p, kappa=kappa, lambda=lambda, + epsilon=epsilon, gamma=gamma, weights=weights, + kernel=kernel)) + return(NULL) + # Convert weights to index weight.idx <- which(c("unit", "group") == weights) - if (length(weight.idx) == 0) { - cat("Error: Incorrect weight specification. ", - "Valid options are 'unit' and 'group'") - return - } # Convert kernel to index (remember off-by-one for R vs. C) kernel.idx <- which(c("linear", "poly", "rbf", "sigmoid") == kernel) - 1 - if (length(kernel.idx) == 0) { - cat("Error: Incorrect kernel specification. ", - "Valid options are 'linear', 'poly', 'rbf', and 'sigmoid'") - return - } seed.rows <- if(is.null(seed.V)) -1 else nrow(seed.V) seed.cols <- if(is.null(seed.V)) -1 else ncol(seed.V) -- cgit v1.2.3