| dbcsp-class {dbcsp} | R Documentation |
S4 class for representing DB-CSP (Distance-Based Common Spatial Patterns)
Description
An object of class dbcsp. 'dbcsp' stands for Distance-Based Common Spatial Patterns. The object includes the Common Spatial Patterns filter obtained with the input lists and using the distance method indicated.
Details
If the lists of matrices X1 or X2 contain NA values, these are automatically interpolated by a linear interpolation
using na.approx function. These new interpolated matrices are saved in the X1 and X2 slots of the object.
The supported distances for type are these ones:
Included in
TSdist: infnorm, ccor, sts, lb.keogh, edr, erp, lcss, fourier, tquest, dissim, acf, pacf, ar.lpc.ceps, ar.mah, ar.mah.statistic, ar.mah.pvalue, ar.pic, cdm, cid, cor, cort, int.per, per, mindist.sax, ncd, pred, spec.glk, spec.isd, spec.llr, pdc, frechet, tam.Included in
parallelDist: bhjattacharyya, bray, canberra, chord, divergence, dtw, euclidean, fJaccard, geodesic, hellinger, kullback, mahalanobis, manhattan, maximum, minkowski, podani, soergel, wave, whittaker.It is possible to use a custom distance. The name of the custom distance function is passed as character to the
typeparameter. In order to use theparallelDistcustom distance option, the custom function must be defined as explained in "Details: User-defined distance functions" part ofparallelDistdocumentation. See Examples section below.
The additional parameters for the selected distance (see TSdist, parallelDist) can be passed
as parameters when creating the object, which will be saved in more slot. See Examples section below.
The output is a list containing this information (object@out):
-
vectorsThe projection vectors obtained after applying CSP. -
eigThe eigenvalues obtained after applying CSP. -
proyThe variance values of the projected signals obtained after applying CSP.
And if training=TRUE the following values are also saved:
-
accThe mean accuracy value obtained for training data applying cross validation. -
used_foldsList of the folds used in the cross validation. -
folds_accAccuracy values for each of the folds of the cross validation. -
modelThe trained LDA classifier. -
selected_qThe number of vectors used when training.
Slots
X1list of matrices for data class 1.
X2list of matrices for data class 2.
qinteger value indicating the number of vectors used in the projection, by default
q=15.labelsvector of two strings indicating labels names, by default names of variables X1 and X2.
typestring which sets the type of distance to be considered, by default
type='EUCL'. See details section.wweight for the distances mixture D_mixture = w*D_euclidean + (1-w)*D_type, by default
w=0.5.mixturelogical value indicating whether to use distances mixture or not (EUCL + other), by default
mixture=FALSE.traininglogical value indicating whether to perform the training or not.
foldinteger value, by default
fold=10. It controls the number of partitions when training. Iffold==1a train/test split is performed, with p=0.2 for test indices.seednumeric value, by default
seed=NULL. Set a seed to ensure reproducible results.eig.tolnumeric value, by default
eig.tol=1e-06, tolerance to convert distance matrix to be definite positive.verboselogical
morelist, additional parameters to be passed to the distance methods. See details section.
outlist containing the output.
See Also
dbcsp, print, summary, train, selectQ, predict, plot, boxplot
Examples
# To create an instance of a class dbcsp given data from 2 classes
x <- AR.data$come[1:20]
y <- AR.data$five[1:20]
mydbcsp <- new("dbcsp", X1 = x, X2 = y)
# CUSTOM DISTANCE
x <- AR.data$come[1:10]
y <- AR.data$five[1:10]
fn <- function(x, y, eps=1) mean(1 - cos(x - y))*eps
mydbcsp <- new("dbcsp", X1 = x, X2 = y, type="fn", eps=0.9)