Train an SPLS model using spls::spls
(Regression) and spls::splsda
(Classification)
s.SPLS(x, y = NULL, x.test = NULL, y.test = NULL, x.name = NULL,
y.name = NULL, k = 2, eta = 0.5, kappa = 0.5, select = "pls2",
fit = "simpls", scale.x = TRUE, scale.y = TRUE, maxstep = 100,
classifier = c("lda", "logistic"),
grid.resample.rtset = rtset.resample("kfold", 5),
grid.search.type = c("exhaustive", "randomized"),
grid.randomized.p = 0.1, metric = NULL, maximize = NULL,
print.plot = TRUE, plot.fitted = NULL, plot.predicted = NULL,
plot.theme = getOption("rt.fit.theme", "lightgrid"), question = NULL,
rtclass = NULL, verbose = TRUE, trace = 0, grid.verbose = TRUE,
outdir = NULL, save.mod = ifelse(!is.null(outdir), TRUE, FALSE),
n.cores = rtCores, ...)
Numeric vector or matrix / data frame of features i.e. independent variables
Numeric vector of outcome, i.e. dependent variable
Numeric vector or matrix / data frame of testing set features
Columns must correspond to columns in x
Numeric vector of testing set outcome
Character: Name for feature set
Character: Name for outcome
[gS] Integer: Number of components to estimate. Default = 2
[gS] Float [0, 1): Thresholding parameter. Default = .5
[gS] Float [0, .5]: Only relevant for multivariate responses: controls effect of concavity of objective function. Default = .5
[gS] String: "pls2", "simpls". PLS algorithm for variable selection. Default = "pls2"
[gS] String: "kernelpls", "widekernelpls", "simpls", "oscorespls". Algorithm for model fitting. Default = "simpls"
Logical: if TRUE, scale features by dividing each column by its sample standard deviation
Logical: if TRUE, scale outcomes by dividing each column by its sample standard deviation
[gS] Integer: Maximum number of iteration when fitting direction vectors. Default = 100
String: Classifier used by spls::splsda
"lda" or "logistic": Default = "lda"
List: Output of rtset.resample defining gridSearchLearn parameters.
Default = rtset.resample("kfold", 5)
String: Type of grid search to perform: "exhaustive" or "randomized". Default = "exhaustive"
Float (0, 1): If grid.search.type = "randomized"
, randomly run this proportion of
combinations. Default = .1
String: Metric to minimize, or maximize if maximize = TRUE
during grid search.
Default = NULL, which results in "Balanced Accuracy" for Classification,
"MSE" for Regression, and "Coherence" for Survival Analysis.
Logical: If TRUE, metric
will be maximized if grid search is run. Default = FALSE
Logical: if TRUE, produce plot using mplot3
Takes precedence over plot.fitted
and plot.predicted
Logical: if TRUE, plot True (y) vs Fitted
Logical: if TRUE, plot True (y.test) vs Predicted.
Requires x.test
and y.test
String: "zero", "dark", "box", "darkbox"
String: the question you are attempting to answer with this model, in plain language.
Logical: If TRUE, print summary to screen.
Logical: Passed to gridSearchLearn
Path to output directory.
If defined, will save Predicted vs. True plot, if available,
as well as full model output, if save.mod
is TRUE
Logical. If TRUE, save all output as RDS file in outdir
save.mod
is TRUE by default if an outdir
is defined. If set to TRUE, and no outdir
is defined, outdir defaults to paste0("./s.", mod.name)
Integer: Number of cores to be used by gridSearchLearn, if applicable
Additional parameters to be passed to npreg
Object of class rtemis
[gS] denotes argument can be passed as a vector of values, which will trigger a grid search using gridSearchLearn
np::npreg
allows inputs with mixed data types.
elevate for external cross-validation
Other Supervised Learning: s.ADABOOST
,
s.ADDTREE
, s.BART
,
s.BAYESGLM
, s.BRUTO
,
s.C50
, s.CART
,
s.CTREE
, s.DA
,
s.ET
, s.EVTREE
,
s.GAM.default
, s.GAM.formula
,
s.GAMSEL
, s.GAM
,
s.GBM3
, s.GBM
,
s.GLMNET
, s.GLM
,
s.GLS
, s.H2ODL
,
s.H2OGBM
, s.H2ORF
,
s.IRF
, s.KNN
,
s.LDA
, s.LM
,
s.MARS
, s.MLRF
,
s.MXN
, s.NBAYES
,
s.NLA
, s.NLS
,
s.NW
, s.POLYMARS
,
s.PPR
, s.PPTREE
,
s.QDA
, s.QRNN
,
s.RANGER
, s.RFSRC
,
s.RF
, s.SGD
,
s.SVM
, s.TFN
,
s.XGBLIN
, s.XGB
# NOT RUN {
x <- rnorm(100)
y <- .6 * x + 12 + rnorm(100)
mod <- s.SPLS(x, y)
# }
Run the code above in your browser using DataLab