@@ -44,6 +44,10 @@ Currently *accuracy* and *balanced accuracy* are supported.
4444`.modelType` is the type of the machine learning model used for performing the
4545cross-validation, given as a string.
4646
47+ `.nTrials` is the total number of trials entering the cross-validation
48+
49+ `.matSize` is the size of the input matrices (trials)
50+
4751`.predLabels` is an `f`-vector of `z` integer vectors holding the vectors of
4852predicted labels. There is one vector for each fold (`f`) and each containes
4953as many vector as classes (`z`), in turn each one containing the predicted labels
@@ -86,6 +90,8 @@ struct CVres <: CVresult
8690 cvType :: String
8791 scoring :: Union{String, Nothing}
8892 modelType :: Union{String, Nothing}
93+ nTrials :: Union{Int, Nothing}
94+ matSize :: Union{Int, Nothing}
8995 predLabels :: Union {Vector{Vector{Vector{I}}}, Nothing} where I<: Int
9096 losses :: Union{Vector{BitVector}, Nothing}
9197 cnfs :: Union{Vector{Matrix{I}}, Nothing} where I<: Int
@@ -101,16 +107,16 @@ end
101107"""
102108```julia
103109CVres(s::String) =
104- CVres(s, nothing, nothing, nothing, nothing, nothing, nothing,
105- nothing, nothing, nothing, nothing, nothing, nothing)
110+ CVres(s, nothing, nothing, nothing, nothing, nothing, nothing, nothing,
111+ nothing, nothing, nothing, nothing, nothing, nothing, nothing )
106112```
107113
108114Construct an instance of the CVres structure giving only the `.cvtype`
109115field. All other fields are filled with `nothing`. This is useful to construct
110116manually crval objects.
111117"""
112- CVres (s:: String )= CVres (s, nothing , nothing , nothing , nothing , nothing , nothing ,
113- nothing , nothing , nothing , nothing , nothing , nothing )
118+ CVres (s:: String )= CVres (s, nothing , nothing , nothing , nothing , nothing , nothing , nothing ,
119+ nothing , nothing , nothing , nothing , nothing , nothing , nothing )
114120
115121
116122
@@ -231,17 +237,21 @@ using PosDefManifoldML, PosDefManifold
231237P, _dummyP, y, _dummyy = gen2ClassData(10, 60, 80, 30, 40, 0.2)
232238
233239# Perform 10-fold cross-validation using the minimum distance to mean classifier
234- cv = crval(MDM(Fisher), P, y)
240+ # adopting the Fisher-Rao (affine-invariant) metric (default)
241+ cv = crval(MDM(), P, y)
242+
243+ # Adopting the log-Euclidean metric
244+ cv = crval(MDM(logEuclidean), P, y)
235245
236- # Do the same applying a pre-conditioning pipeline
246+ # Apply a pre-conditioning pipeline to adopt the pseudo affine-invariant metric
237247p = @→ Recenter(; eVar=0.999) Compress Shrink(Fisher; radius=0.02)
238- cv = crval(MDM(Fisher ), P, y; pipeline = p)
248+ cv = crval(MDM(Euclidean ), P, y; pipeline = p)
239249
240250# Apply a pre-conditioning pipeline and project the data
241251# onto the tangent space at I without recentering the matrices.
242252# Note that this makes sense only for tangent space ML models.
243253p = @→ Recenter(; eVar=0.999) Compress Shrink(Fisher; radius=0.02)
244- cv = crval(ENLR(Fisher ), P, y; pipeline = p, meanISR=I)
254+ cv = crval(ENLR(), P, y; pipeline = p, meanISR=I)
245255
246256# Perform 10-fold cross-validation using the lasso logistic regression classifier
247257cv = crval(ENLR(Fisher), P, y)
@@ -253,7 +263,6 @@ cv = crval(SVM(Fisher), P, y)
253263cv = crval(SVM(Fisher), P, y; kernel=kernel.Polynomial)
254264
255265# Perform 8-fold cross-validation instead
256- # (and see that you can go pretty fast if your PC has 8 threads)
257266cv = crval(SVM(Fisher), P, y; nFolds=8)
258267
259268# ...balance the weights for tangent space projection
@@ -414,7 +423,8 @@ function crval(model :: MLmodel,
414423 end
415424
416425 # create cv struct
417- cv = CVres (" $nFolds -fold" , sStr, _model2Str (model), predLab, errls, CM, mCM, as, avg, std, zstat, pvalue, Dates. value (exetime))
426+ cv = CVres (" $nFolds -fold" , sStr, _model2Str (model), length (𝐏), size (𝐏, 1 ), predLab, errls,
427+ CM, mCM, as, avg, std, zstat, pvalue, Dates. value (exetime))
418428
419429 # restore the number of threads for BLAS as the user had before invoking this function
420430 ⏩ && (BLAS. set_num_threads (blasThreads))
@@ -563,6 +573,8 @@ function Base.show(io::IO, ::MIME{Symbol("text/plain")}, cv::CVres)
563573 println (io, separatorFont, " .cvType :" , defaultFont," $(cv. cvType) " )
564574 cv. scoring ≠ nothing && println (io, separatorFont, " .scoring :" , defaultFont," $(cv. scoring) " )
565575 cv. modelType ≠ nothing && println (io, separatorFont, " .modelType:" , defaultFont," $(cv. modelType) " )
576+ cv. nTrials ≠ nothing && println (io, separatorFont, " .nTrials :" , defaultFont," $(cv. nTrials) " )
577+ cv. matSize ≠ nothing && println (io, separatorFont, " .matSize :" , defaultFont," $(cv. matSize) " )
566578 cv. predLabels ≠ nothing && println (io, separatorFont, " .predLabels " , defaultFont," a vector of #classes vectors of predicted labels per fold" )
567579 cv. losses ≠ nothing && println (io, separatorFont, " .losses " , defaultFont," a vector of binary loss per fold" )
568580 cv. cnfs ≠ nothing && println (io, separatorFont, " .cnfs " , defaultFont," a confusion matrix per fold (frequencies)" )
0 commit comments