Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 304 streamline tune #348

Merged
merged 75 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
48db6ab
update tune.splsda so runs perf if test.keepX=NULL, update docs and e…
evaham1 Nov 22, 2024
eee25cc
add unit testing for edited tune.splsda functionality
evaham1 Nov 22, 2024
e9ba70a
update tune.spca docs as these depended on tune.splsda docs
evaham1 Nov 22, 2024
b56a9e6
update tune.splsda docs
evaham1 Nov 22, 2024
07ad57d
init tune.plsda which calls perf
evaham1 Nov 22, 2024
0670a66
add tune.plsda examples
evaham1 Nov 22, 2024
47ae900
update tune.spls to run perf if test.keepX and test.keepY are NULL, u…
evaham1 Nov 25, 2024
da13ece
add unit test for new tune.spls functionality
evaham1 Nov 25, 2024
fb825b0
add few more tests for different params to check tune.spls works
evaham1 Nov 25, 2024
c8f2d8c
add tune.spls examples to docs
evaham1 Nov 25, 2024
413de19
update tune.spls examples to include spls1 model
evaham1 Nov 25, 2024
c28de60
update tune.spls docs
evaham1 Nov 25, 2024
fb58267
init tune.pls
evaham1 Nov 25, 2024
da6ca90
add tune.pls examples
evaham1 Nov 25, 2024
dceeecd
update tune.block.splsda docs and exmples
evaham1 Nov 25, 2024
645d962
typos in tune.block.splsda
evaham1 Nov 25, 2024
cf96824
unit testing for new tune.block.splsda functionality
evaham1 Nov 25, 2024
6ad679e
init tune.block.plsda
evaham1 Nov 25, 2024
9c2cd77
add example for tune.block.plsda
evaham1 Nov 25, 2024
73c89c5
update tune.mint.splsda docs and example
evaham1 Nov 25, 2024
1075f64
add examples to docs
evaham1 Nov 25, 2024
c698b2e
add unit tests for tune.mint.splsda
evaham1 Nov 25, 2024
72b15f2
no CV params in mint
evaham1 Nov 25, 2024
5de7a1b
init tune.mint.plsda
evaham1 Nov 25, 2024
bddda87
init tune.mint.plsda
evaham1 Nov 25, 2024
b4a6e71
update examples of tune.mint.plsda
evaham1 Nov 25, 2024
4ed248f
update tune.rcc to remove plot arg to streamline
evaham1 Nov 26, 2024
71710b4
start streamlining tune wrapper function
evaham1 Nov 26, 2024
2204453
streamline tune wrapper with exisiting functions
evaham1 Nov 26, 2024
a9fd254
update unit test for removing plot from tune.rcc
evaham1 Nov 26, 2024
d446918
hardcode limQ2 param in tune.pls and tune.spls to streamline functions
evaham1 Nov 26, 2024
d0a31e2
clean up input params docs
evaham1 Nov 26, 2024
416d606
streamline tune.block.plsda, no measure arg
evaham1 Nov 26, 2024
9d706d5
update tune.block.splsda docs to reflect how to use 'dist' and 'measure'
evaham1 Nov 26, 2024
3e6c4d8
update dist default to 'all' for tune.block.plsda
evaham1 Nov 26, 2024
bf1ffc0
streamline tune.plsda - no 'measure' arg
evaham1 Nov 26, 2024
80961a7
update docs for tune.splsda
evaham1 Nov 26, 2024
005f952
make tune.spls example code lines less long
evaham1 Nov 26, 2024
b0f9ab9
fix tune.pls docs
evaham1 Nov 26, 2024
eee01cb
fix errors in tune.spls docs
evaham1 Nov 26, 2024
bd1610a
allow tune.mint functions to take extra args
evaham1 Nov 26, 2024
2832fdf
fixed docs warnings
evaham1 Nov 26, 2024
911d613
fix tune.rcc example
evaham1 Nov 26, 2024
3e27899
fix warnings in tune.pls
evaham1 Nov 26, 2024
b49d196
fix note in perf.assess.pls
evaham1 Nov 27, 2024
26e6e4a
fix notes and warnings in tune docs
evaham1 Nov 27, 2024
11262b8
fix unit test errors
evaham1 Nov 27, 2024
2380e3f
fix notes in docs
evaham1 Nov 27, 2024
9d3f7c9
rmove dist checking so can plot multiple dist metrics using internal …
evaham1 Nov 27, 2024
326518e
clean tune tune.plsda and tune.splsda input args
evaham1 Nov 27, 2024
5dcc777
reorg tune.mint input args
evaham1 Nov 27, 2024
0d70ff5
how to use 'measure' arg in tune mint functions
evaham1 Nov 27, 2024
217a2d1
fix unit test
evaham1 Nov 27, 2024
4ee868d
add unit tests for tune.pca and match default args
evaham1 Nov 27, 2024
768f9f9
add new functions to tune wrapper
evaham1 Nov 27, 2024
58b8fb1
update output docs for perf
evaham1 Nov 27, 2024
040a844
update perf.assess docs
evaham1 Nov 27, 2024
2f445ad
add examples to perf.assess
evaham1 Nov 27, 2024
5051a35
add unit tests for tune.plsda
evaham1 Nov 27, 2024
5822710
unit tests for tune.pls
evaham1 Nov 27, 2024
834f332
make sure tune.spls and tune wrapper match default args
evaham1 Nov 27, 2024
92a6457
add unit tests for tune.block.plsda
evaham1 Nov 27, 2024
045d1d8
add unit test for tune.mint.plsda
evaham1 Nov 27, 2024
7f255db
shortern example lines
evaham1 Nov 27, 2024
64af0ef
add testing to make sure tune outputs can plot without error
evaham1 Nov 27, 2024
4f9d359
fix unit tests checking plotting properly
evaham1 Nov 28, 2024
7fc80d0
add example for tune.pca multilevel
evaham1 Nov 28, 2024
36b1ca8
add multilevel examples to tune.pls and tune.spls
evaham1 Nov 28, 2024
da5fec5
doc
evaham1 Nov 28, 2024
9bd6753
update tune.plsda to work on multilevel and add example
evaham1 Nov 28, 2024
c9961b3
tune.splsda take multilevel and add exampel
evaham1 Nov 28, 2024
49e1b9d
install mixomics from github inside the vignette
evaham1 Nov 28, 2024
036c422
fixed tune.splsda multilevel error
evaham1 Nov 28, 2024
ce7f59a
revert back vignette change
evaham1 Nov 28, 2024
dcda5b5
typo in example
evaham1 Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ S3method(circosPlot,block.plsda)
S3method(circosPlot,block.spls)
S3method(circosPlot,block.splsda)
S3method(image,tune.rcc)
S3method(perf,assess.mint.plsda)
S3method(perf,assess.mint.splsda)
S3method(perf,assess.mixo_pls)
S3method(perf,assess.mixo_plsda)
S3method(perf,assess.mixo_spls)
S3method(perf,assess.mixo_splsda)
S3method(perf,mint.pls)
S3method(perf,mint.plsda)
S3method(perf,mint.spls)
Expand All @@ -31,6 +25,12 @@ S3method(perf,mixo_plsda)
S3method(perf,mixo_spls)
S3method(perf,mixo_splsda)
S3method(perf,sgccda)
S3method(perf.assess,mint.plsda)
S3method(perf.assess,mint.splsda)
S3method(perf.assess,mixo_pls)
S3method(perf.assess,mixo_plsda)
S3method(perf.assess,mixo_spls)
S3method(perf.assess,mixo_splsda)
S3method(perf.assess,sgccda)
S3method(plot,pca)
S3method(plot,perf.mint.plsda.mthd)
Expand Down Expand Up @@ -169,9 +169,13 @@ export(spls)
export(splsda)
export(study_split)
export(tune)
export(tune.block.plsda)
export(tune.block.splsda)
export(tune.mint.plsda)
export(tune.mint.splsda)
export(tune.pca)
export(tune.pls)
export(tune.plsda)
export(tune.rcc)
export(tune.spca)
export(tune.spls)
Expand Down
2 changes: 1 addition & 1 deletion R/image.tune.rcc.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' Y <- nutrimouse$gene
#'
#' ## this can take some seconds
#' cv.score <- tune.rcc(X, Y, validation = "Mfold", plot = FALSE)
#' cv.score <- tune.rcc(X, Y, validation = "Mfold")
#' plot(cv.score)
#'
#' # image(cv.score) # same result as plot()
Expand Down
29 changes: 19 additions & 10 deletions R/perf.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#' Not recommended during exploratory analysis. Note if RNGseed is set in 'BPPARAM', this will be overwritten by 'seed'.
#' Note 'seed' is not required or used in perf.mint.plsda as this method uses loo cross-validation
#' @param ... not used
#'
#' @return For PLS and sPLS models, \code{perf} produces a list with the
#' following components for every repeat:
#' \item{MSEP}{Mean Square Error Prediction for each \eqn{Y} variable, only
Expand Down Expand Up @@ -141,19 +142,25 @@
#' \item{cor.tpred, cor.upred}{Correlation between the
#' predicted and actual components for X (t) and Y (u)}
#' \item{RSS.tpred, RSS.upred}{Residual Sum of Squares between the
#' predicted and actual components for X (t) and Y (u)}
#' \item{error.rate}{ For
#' PLS-DA and sPLS-DA models, \code{perf} produces a matrix of classification
#' predicted and actual components for X (t) and Y (u)}
#'
#'
#'
#' For PLS-DA and sPLS-DA models, \code{perf} produces a matrix of classification
#' error rate estimation. The dimensions correspond to the components in the
#' model and to the prediction method used, respectively. Note that error rates
#' reported in any component include the performance of the model in earlier
#' components for the specified \code{keepX} parameters (e.g. error rate
#' reported for component 3 for \code{keepX = 20} already includes the fitted
#' model on components 1 and 2 for \code{keepX = 20}). For more advanced usage
#' of the \code{perf} function, see \url{www.mixomics.org/methods/spls-da/} and
#' consider using the \code{predict} function.}
#' \item{auc}{Averaged AUC values
#' over the \code{nrepeat}}
#' model on components 1 and 2 for \code{keepX = 20}).
#' \item{error.rate}{Prediction error rate for each dist and measure}
#' \item{auc}{AUC values per component averaged over the \code{nrepeat}}
#' \item{auc.all}{AUC values per component per repeat}
#' \item{predict}{A list of length ncomp that os predicted values of each sample for each class}
#' \item{features}{a list of features selected across the folds ($stable.X) for the keepX parameters from the input object.}
#' \item{choice.ncomp}{Otimal number of components for the model for each prediction distance using one-sided t-tests that test
#' for a significant difference in the mean error rate (gain in prediction) when components are added to the model.}
#' \item{class}{A list which gives the predicted class of each sample for each dist and each of the ncomp components}
#'
#' For mint.splsda models, \code{perf} produces the following outputs:
#' \item{study.specific.error}{A list that gives BER, overall error rate and
Expand All @@ -166,7 +173,7 @@
#' \item{auc}{AUC values} \item{auc.study}{AUC values for each study in mint
#' models}
#'
#' For sgccda models, \code{perf} produces the following outputs:
#' For sgccda models (i.e. block (s)PLS-DA models), \code{perf} produces the following outputs:
#' \item{error.rate}{Prediction error rate for each block of \code{object$X}
#' and each \code{dist}} \item{error.rate.per.class}{Prediction error rate for
#' each block of \code{object$X}, each \code{dist} and each class}
Expand Down Expand Up @@ -197,12 +204,14 @@
#' \item{WeightedVote.error.rate}{if more than one block, returns the error
#' rate of the \code{WeightedVote} output} \item{weights}{Returns the weights
#' of each block used for the weighted predictions, for each nrepeat and each
#' fold} \item{choice.ncomp}{For supervised models; returns the optimal number
#' fold}
#' \item{choice.ncomp}{For supervised models; returns the optimal number
#' of components for the model for each prediction distance using one-sided
#' t-tests that test for a significant difference in the mean error rate (gain
#' in prediction) when components are added to the model. See more details in
#' Rohart et al 2017 Suppl. For more than one block, an optimal ncomp is
#' returned for each prediction framework.}
#'
#' @author Ignacio González, Amrit Singh, Kim-Anh Lê Cao, Benoit Gautier,
#' Florian Rohart, Al J Abadi
#' @seealso \code{\link{predict}}, \code{\link{nipals}},
Expand Down
102 changes: 43 additions & 59 deletions R/perf.assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@
#' that for PLS and sPLS objects, perf is performed on the pre-processed data
#' after log ratio transform and multilevel analysis, if any.
#'
#' Sparse methods. The sPLS, sPLS-DA and sgccda functions are run on several
#' and different subsets of data (the cross-folds) and will certainly lead to
#' different subset of selected features. Those are summarised in the output
#' \code{features$stable} (see output Value below) to assess how often the
#' variables are selected across all folds. Note that for PLS-DA and sPLS-DA
#' objects, perf is performed on the original data, i.e. before the
#' pre-processing step of the log ratio transform and multilevel analysis, if
#' any. In addition for these methods, the classification error rate is
#' averaged across all folds.
#'
#' The mint.sPLS-DA function estimates errors based on Leave-one-group-out
#' cross validation (where each levels of object$study is left out (and
#' predicted) once) and provides study-specific outputs
Expand All @@ -63,8 +53,7 @@
#' threshold based on distances (see \code{predict}) that optimally determine
#' class membership of the samples tested. As such AUC and ROC are not needed
#' to estimate the performance of the model. We provide those outputs as
#' complementary performance measures. See more details in our mixOmics
#' article.
#' complementary performance measures.
#'
#' Prediction distances. See details from \code{?predict}, and also our
#' supplemental material in the mixOmics article.
Expand All @@ -87,20 +76,20 @@
#' More details about the PLS modes in \code{?pls}.
#'
#' @param object object of class inherited from \code{"pls"}, \code{"plsda"},
#' \code{"spls"}, \code{"splsda"} or \code{"mint.splsda"}. The function will
#' \code{"spls"}, \code{"splsda"}. \code{"sgccda"} or \code{"mint.splsda"}. The function will
#' retrieve some key parameters stored in that object.
#' @param validation a character string. What kind of (internal) validation to use,
#' matching one of \code{"Mfold"} or \code{"loo"} (see below). Default is
#' \code{"Mfold"}. For MINT methods only \code{"loo"} will be used.
#' @param folds numeric. Number of folds in the Mfold cross-validation. See Details.
#' @param nrepeat numierc. Number of times the Cross-Validation process is repeated.
#' This is an important argument to ensure the estimation of the performance to
#' be as accurate as possible. Default it 1.
#' @param dist only applies to an object inheriting from \code{"plsda"},
#' \code{"splsda"} or \code{"mint.splsda"} to evaluate the classification
#' performance of the model. Should be a subset of \code{"max.dist"},
#' \code{"centroids.dist"}, \code{"mahalanobis.dist"}. Default is \code{"all"}.
#' See \code{\link{predict}}.
#' @param validation character. What kind of (internal) validation to use,
#' matching one of \code{"Mfold"} or \code{"loo"} (see below). Default is
#' \code{"Mfold"}.
#' @param folds the folds in the Mfold cross-validation. See Details.
#' @param nrepeat Number of times the Cross-Validation process is repeated.
#' This is an important argument to ensure the estimation of the performance to
#' be as accurate as possible.
#' @param auc if \code{TRUE} calculate the Area Under the Curve (AUC)
#' performance of the model.
#' @param progressBar by default set to \code{FALSE} to output the progress bar
Expand All @@ -113,57 +102,61 @@
#' Not recommended during exploratory analysis. Note if RNGseed is set in 'BPPARAM', this will be overwritten by 'seed'.
#' Note 'seed' is not required or used in perf.mint.plsda as this method uses loo cross-validation
#' @param ... not used
#' @return For PLS and sPLS models, \code{perf} produces a list with the
#' following components for every repeat:

#' @return For PLS and sPLS models:
#' \item{MSEP}{Mean Square Error Prediction for each \eqn{Y} variable, only
#' applies to object inherited from \code{"pls"}, and \code{"spls"}. Only
#' available when in regression (s)PLS.}
#' \item{RMSEP}{Root Mean Square Error Prediction for each \eqn{Y} variable, only
#' applies to object inherited from \code{"pls"}, and \code{"spls"}. Only
#' available when in regression (s)PLS.}
#' \item{R2}{a matrix of \eqn{R^2} values of the \eqn{Y}-variables. Only applies to object
#' \item{R2}{a matrix of \eqn{R^2} values of the \eqn{Y}-variables for models
#' with \eqn{1, \ldots ,}\code{ncomp} components, only applies to object
#' inherited from \code{"pls"}, and \code{"spls"}. Only available when in
#' regression (s)PLS.}
#' \item{Q2}{if \eqn{Y} contains one variable, a vector of \eqn{Q^2} values
#' else a list with a matrix of \eqn{Q^2} values for each \eqn{Y}-variable.
#' Note that in the specific case of an sPLS model, it is better to have a look
#' at the Q2.total criterion, only applies to object inherited from
#' \code{"pls"}, and \code{"spls"}. Only available when in regression (s)PLS.}
#' \item{Q2.total}{a vector of \eqn{Q^2}-total values for model, only applies to object inherited from
#' \item{Q2.total}{a vector of \eqn{Q^2}-total values for models with \eqn{1,
#' \ldots ,}\code{ncomp} components, only applies to object inherited from
#' \code{"pls"}, and \code{"spls"}. Available in both (s)PLS modes.}
#' \item{RSS}{Residual Sum of Squares across all selected features.}
#' \item{RSS}{Residual Sum of Squares across all selected features}
#' \item{PRESS}{Predicted Residual Error Sum of Squares across all selected features}
#' \item{features}{a list of features selected across the
#' folds (\code{$stable.X} and \code{$stable.Y}) for the \code{keepX} and
#' \code{keepY} parameters from the input object. Note, this will be \code{NULL}
#' if using standard (non-sparse) PLS.}
#' \item{cor.tpred, cor.upred}{Correlation between the
#' predicted and actual components for X (t) and Y (u)}
#' \item{RSS.tpred, RSS.upred}{Residual Sum of Squares between the
#' predicted and actual components for X (t) and Y (u)}
#' \item{error.rate}{ For
#' PLS-DA and sPLS-DA models, \code{perf} produces a matrix of classification
#' error rate estimation using overall and BER error rates across different distance methods.
#' Although error rates are only reported for the number of components used in the final model,
#' Note that are calculated including the performance of the model in a smaller number of
#' components for the specified \code{keepX} parameters (e.g. error rate
#' reported for component 3 for \code{keepX = 20} already includes the fitted
#' model on components 1 and 2 for \code{keepX = 20}). For more advanced usage
#' of the \code{perf} function, see \url{www.mixomics.org/methods/spls-da/} and
#' consider using the \code{predict} function.}
#' \item{auc}{Averaged AUC values
#' over the \code{nrepeat}}
#'
#' #' For sgccda models, \code{perf} produces the following outputs:
#' predicted and actual components for X (t) and Y (u)}
#'
#'
#'
#' For PLS-DA and sPLS-DA models:
#' \item{error.rate}{Prediction error rate for each dist and measure}
#' \item{auc}{AUC value averaged over the \code{nrepeat}}
#' \item{auc.all}{AUC values per repeat}
#' \item{predict}{Predicted values of each sample for each class}
#' \item{class}{A list which gives the predicted class of each sample for each dist and each of the ncomp components}
#'
#' For mint.splsda models:
#' \item{study.specific.error}{A list that gives BER, overall error rate and
#' error rate per class, for each study}
#' \item{global.error}{A list that gives
#' BER, overall error rate and error rate per class for all samples}
#' \item{predict}{A list of length \code{ncomp} that produces the predicted
#' values of each sample for each class}
#' \item{class}{A list which gives the
#' predicted class of each sample for each \code{dist}.}
#' \item{auc}{AUC values} \item{auc.study}{AUC values for each study in mint models}
#'
#' For sgccda models (i.e. block (s)PLS-DA models):
#' \item{error.rate}{Prediction error rate for each block of \code{object$X}
#' and each \code{dist}}
#' \item{error.rate.per.class}{Prediction error rate for
#' each block of \code{object$X}, each \code{dist} and each class}
#' \item{predict}{Predicted values of each sample for each class and each block.}
#' \item{class}{Predicted class of each sample for each block, each \code{dist}, and each nrepeat}
#' \item{features}{a list of features selected across the folds (\code{$stable.X} and
#' \code{$stable.Y}) for the \code{keepX} and \code{keepY} parameters from the
#' input object.}
#' \item{predict}{Predicted values of each sample for each class and each block}
#' \item{class}{Predicted class of each sample for each
#' block, each \code{dist}, and each nrepeat}
#' \item{AveragedPredict.class}{if more than one block, returns
#' the average predicted class over the blocks (averaged of the \code{Predict}
#' output and prediction using the \code{max.dist} distance)}
Expand All @@ -187,15 +180,6 @@
#' rate of the \code{WeightedVote} output}
#' \item{weights}{Returns the weights of each block used for the weighted predictions, for each nrepeat and each
#' fold}
#'
#' For mint.splsda models, \code{perf} produces the following outputs:
#' \item{study.specific.error}{A list that gives BER, overall error rate and
#' error rate per class, for each study}
#' \item{global.error}{A list that gives BER, overall error rate and error rate per class for all samples}
#' \item{predict}{A list of the predicted values of each sample for each class}
#' \item{class}{A list which gives the predicted class of each sample for each \code{dist}. Directly obtained from the \code{predict} output.}
#' \item{auc}{AUC values} \item{auc.study}{AUC values for each study}
#'

#' @author Ignacio González, Amrit Singh, Kim-Anh Lê Cao, Benoit Gautier,
#' Florian Rohart, Al J Abadi
Expand Down Expand Up @@ -247,7 +231,7 @@
#' 4:e1845.
#' @keywords regression multivariate
#' @export
#' @example ./examples/perf-examples.R
#' @example ./examples/perf.assess-examples.R
## ------------------------------- Generic -------------------------------- ##
perf.assess <- function(object, ...)
UseMethod("perf.assess")
1 change: 0 additions & 1 deletion R/perf.assess.diablo.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
# folds - number of folds if validation = "Mfold"
# ----------------------------------------------------------------------------------------------------------
#' @rdname perf.assess
#' @importFrom utils relist
#' @method perf.assess sgccda
#' @export
perf.assess.sgccda <-
Expand Down
39 changes: 38 additions & 1 deletion R/perf.assess.mint.plsda.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
## -------------------------- perf.mint(s)plsda --------------------------- ##
#############################################################################################################
# Authors:
# Amrit Singh, University of British Columbia, Vancouver.
# Florian Rohart, The University of Queensland, The University of Queensland Diamantina Institute, Translational Research Institute, Brisbane, QLD
# Kim-Anh Le Cao, The University of Queensland, The University of Queensland Diamantina Institute, Translational Research Institute, Brisbane, QLD
#
# created: 01-04-2015
# last modified: 27-05-2016
#
# Copyright (C) 2015
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#############################################################################################################


# ----------------------------------------------------------------------------------------------------------
# perf.assess.mint.plsda - Function to evaluate the performance of the fitted PLS (cross-validation)
# inputs: object - object obtain from running mint.plsda
# dist - to evaluate the classification performance
# validation - type of validation
# folds - number of folds if validation = "Mfold"
# ----------------------------------------------------------------------------------------------------------
#' ## -------------------------- perf.mint(s)plsda --------------------------- ##

#' @rdname perf.assess
#' @method perf.assess mint.plsda
#' @export
perf.assess.mint.plsda <- function (object,
dist = c("all", "max.dist", "centroids.dist", "mahalanobis.dist"),
Expand Down Expand Up @@ -259,5 +295,6 @@ perf.assess.mint.plsda <- function (object,
}

#' @rdname perf.assess
#' @method perf.assess mint.splsda
#' @export
perf.assess.mint.splsda <- perf.assess.mint.plsda
9 changes: 8 additions & 1 deletion R/perf.assess.pls.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

## -------------------------------- (s)PLS -------------------------------- ##
#' @rdname perf.assess
#' @method perf.assess mixo_pls
#' @export
perf.assess.mixo_pls <- function(object,
validation = c("Mfold", "loo"),
Expand All @@ -41,6 +42,7 @@ perf.assess.mixo_pls <- function(object,
seed = NULL,
...)
{

# checking args and initialize params
ncomp = object$ncomp
spls.model <- is(object, 'mixo_spls')
Expand All @@ -65,7 +67,7 @@ perf.assess.mixo_pls <- function(object,
measures <- as.data.frame(measures)

# Add this line to remove rows with NAs that correspond to components < ncomp
measures <- dplyr::filter(measures, comp == ncomp)
measures <- dplyr::filter(measures, .data$comp == ncomp)

## R CMD check stuff
measure <- feature <- comp <- block <- stability <- value <- NULL
Expand Down Expand Up @@ -132,6 +134,7 @@ perf.assess.mixo_pls <- function(object,
}

#' @rdname perf.assess
#' @method perf.assess mixo_spls
#' @export
perf.assess.mixo_spls <- perf.assess.mixo_pls

Expand All @@ -145,6 +148,10 @@ perf.assess.mixo_spls <- perf.assess.mixo_pls

{
# changes to bypass the loop for the Q2

## R CMD check stuff
measure <- feature <- comp <- block <- stability <- value <- NULL
lower <- upper <- keepX <- keepY <- NULL

## -------- checks -------- ##
if (object$mode == 'invariant')
Expand Down
Loading
Loading