Skip to content

Commit 30eb281

Browse files
v 0.5.14
dev
2 parents 403fb64 + 4f315a6 commit 30eb281

12 files changed

Lines changed: 69 additions & 75 deletions

File tree

Manifest.toml

Lines changed: 19 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PosDefManifoldML"
22
uuid = "a07f4532-e2c9-11e9-2ea2-6d98fe4a1f21"
33
authors = ["Marco-Congedo <marco.congedo@gmail.com>"]
4-
version = "0.5.13"
4+
version = "0.5.14"
55

66
[deps]
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

docs/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
authors = ["Marco Congedo, Fahim Doumi, Saloni Jain, Anton Andreev"]
2-
version = "0.5.13"
1+
authors = ["Marco Congedo, Fahim Doumi"]
2+
version = "0.5.14"
33

44
[deps]
55
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

docs/src/cv.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ It also reports the documentation of the **fit** and **predict** functions, as t
88

99
| struct | description |
1010
|:-----------------|:----------------------------------|
11-
| [`CVres`](@ref) | Encapsulate the results of cross-validation procedures for estimating accuracy|
11+
| [`CVres`](@ref) | encapsulate the results of cross-validation procedures for estimating accuracy|
1212

1313
| function | description |
1414
|:-----------------------|:----------------------------------|
15-
| [`fit`](@ref) | Fit a machine learning model with training data |
16-
| [`predict`](@ref) | Given a fitted model, preidct labels, probabilities or scoring functions on test data |
17-
| [`crval`](@ref) | Perform a cross-validation and store accuracies, error losses, confusion matrices, the results of a statistical test and other informations|
18-
| [`cvSetup`](@ref) | Generate indexes for performing cross-validtions |
15+
| [`fit`](@ref) | fit a machine learning model with training data |
16+
| [`predict`](@ref) | given a fitted model, predict labels, probabilities or scoring functions on test data |
17+
| [`crval`](@ref) | perform a cross-validation and store accuracies, error losses, confusion matrices, the results of a statistical test and other informations|
18+
| [`cvSetup`](@ref) | generate indexes for performing cross-validtions |
1919

2020
```@docs
2121
CVres

docs/src/svm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This unit implements several **Suport-Vector Machine (SVM)**
44
machine learning models on the tangent space for symmetric positive definite
55
(SDP) matrices, *i.e.*, real PD matrices.
6-
Several models can be obtained with different combinations of the `svmType` and the `kernel` arguments when the model is fit.
6+
Several models can be obtained with different combinations of the `svmType` and the `kernel` arguments when the model is fitted.
77
Optimal hyperparameters for the given training data
88
are found using cross-validation.
99

docs/src/tools.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# tools.jl
22

33
This unit implements tools that are useful for building Riemannian
4-
and Euclidean machine learning classifiers.
4+
and Euclidean machine learning classifiers. For basic usage of the package
5+
you won't need these functions.
56

67
## Content
78

89
| function | description |
910
|:-----------------------|:----------------------------------|
1011
| [`tsMap`](@ref) | project data on a tangent space to apply Euclidean ML models therein |
11-
| [`tsWeights`](@ref)| generator of weights for tagent space mapping |
12+
| [`tsWeights`](@ref)| generate weights for tagent space mapping |
1213
| [`gen2ClassData`](@ref)| generate 2-class positive definite matrix data for testing Riemannian ML models |
13-
| [`rescale!`](@ref)| Rescale the rows or columns of a real matrix to be in range [a, b] |
14-
| [`demean!`](@ref)| Remove the mean of the rows or columns of a real matrix |
15-
| [`normalize!`](@ref)| Normalize the rows or columns of a real matrix |
16-
| [`standardize!`](@ref)| Standardize the rows or columns of a real matrix |
17-
| [`saveas`](@ref)| Save a whatever object to a file |
18-
| [`load`](@ref)| Load a whatever object from a file |
14+
| [`rescale!`](@ref)| rescale the rows or columns of a real matrix to be in range [a, b] |
15+
| [`demean!`](@ref)| remove the mean of the rows or columns of a real matrix |
16+
| [`normalize!`](@ref)| normalize the rows or columns of a real matrix |
17+
| [`standardize!`](@ref)| standardize the rows or columns of a real matrix |
18+
| [`saveas`](@ref)| save a whatever object to a file |
19+
| [`load`](@ref)| load a whatever object from a file |
1920

2021
```@docs
2122
tsMap

docs/src/tutorial.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ it does not matter if they act directly on the manifold of positive definite mat
1616
It also features
1717

1818
- **Pre-conditining pipelines**, which can drastically reduce the execution time
19-
- **Adaptation** techniques, which, besides being very useful in cross-session and cross-subject settings,
20-
are instrumental for implementing on-line modes of operation.
19+
- **Adaptation** techniques, which, besides being very useful in cross-session and cross-subject settings, are instrumental for implementing on-line modes of operation.
2120

2221
Note that models acting on the tangent space can take as input Euclidean feature vectors instead of positive definite matrices, thus they can be used in many more situations.
2322

@@ -138,12 +137,13 @@ See [`CVres`](@ref) for details on the fields of cross-validation objects.
138137

139138
Let's see how to adapt a pre-conditioning pipeline. Suppose you have data from two
140139
sessions or two subjects, `s1` and `s2`.
141-
We want to use `s1` to train a machine learning model on the tanget space and `s2` to test it.
142-
A pipeline is fitted sor `s1` and we want this pipeline to adapt to `s2` for testing.
140+
We want to use `s1` to train a machine learning model on the tangent space and `s2` to test it.
141+
A pipeline is fitted on `s1` and we want this pipeline to adapt to `s2` for testing.
143142
If the pipeline includes a recentering pre-conditioner, we need to make sure that
144-
the dimensionality reduction determined on `s2` is that same as in `s1.
143+
the dimensionality reduction determined on `s2` is the same as in `s1`.
145144

146145
**Get data**
146+
147147
Let us get some simulated data.
148148
We generate random data and labels for session (or subject) 1 and 2.
149149

@@ -184,7 +184,7 @@ predict(m, Ps2, :l; pipeline=p)
184184

185185
## Examples using the ENLR model
186186

187-
The **elastic net logistic regression (ENLR)** classifier is an example of classifier acting on the tangent space. Besides the **metric** (see above) used to compute a base-point for projecting the data onto the tangent space, it has a parameter **alpha** and an hyperparameter **lambda**. The **alpha** parameter allows to trade off between a pure **ridge** LR model (``α=0``) and a pure **lasso** LR model (``α=1``), which is the default. Given an alpha value, the model is fitted with a number of values for the ``λ`` (regularization) hyperparameter. Thus, differently from the previous example, tuning the ``λ`` hyperparameter is necessary.
187+
The **elastic net logistic regression (ENLR)** classifier is an example of classifier acting on the tangent space. Besides the **metric** used to compute a base-point for projecting the data onto the tangent space, it has a parameter **alpha** and an hyperparameter **lambda**. The **alpha** parameter allows to trade off between a pure **ridge** LR model (``α=0``) and a pure **lasso** LR model (``α=1``), which is the default. Given an alpha value, the model is fitted with a number of values for the ``λ`` (regularization) hyperparameter. Thus, differently from the previous example, tuning the ``λ`` hyperparameter is necessary.
188188

189189
Also, keep in mind
190190
that the [`fit`](@ref) and [`predict`](@ref) methods for ENLR models accept optional keyword arguments that are specific to this model.
@@ -339,11 +339,12 @@ This last command can be invoked repeatedly.
339339

340340
First, let's see how to adapt the base point for projecting the data onto
341341
the tangent space. Suppose you have data from two sessions or two subjects, `s1` and `s2`.
342-
We want to use `s1` to train a machine learning model on the tanget space and `s2` to test it,
342+
We want to use `s1` to train a machine learning model on the tangent space and `s2` to test it,
343343
however, the barycenter `s1` cannot be assumed equal to the barycenter of `s2`.
344344
The barycenter determines the base point, therefore, we adapt it.
345345

346346
**Get data**
347+
347348
Let us get some simulated data.
348349
We generate random data and labels for session (or subject) 1 and 2.
349350

@@ -373,7 +374,7 @@ with dimensionality reduction. While adapting the pipeline to `s2`,
373374
we need to make sure that the matrices in `s2` are reduced to the same
374375
dimension as the matrices in `s1`, otherwise the
375376
machine learning model we fit on `s1` cannot operate
376-
on `s2`. For this, we need to set the `eVar` argmument of the [`Recenter`]
377+
on `s2`. For this, we need to set the `eVar` argmument of the [`Recenter`](@ref)
377378
pre-conditioner to a integer matching the reduced dimension of `s1`.
378379
Note that the adaptation may not work well if the class proportions
379380
is different in `s1` and `s2`.
@@ -435,7 +436,7 @@ By default, a C-Support Vector Classification model is fitted:
435436
m1 = fit(SVM(), PTr, yTr; w=:b)
436437
```
437438

438-
Notice that as for the example above with for ENLR model, we have requested to compute a balanced mean for projecting the matrices in `PTr` onto the tangent space.
439+
Notice that, as for the example above with for ENLR model, we have requested to compute a balanced mean for projecting the matrices in `PTr` onto the tangent space.
439440

440441
In order to fit a Nu-Support Vector Classification model:
441442

src/PosDefManifoldML.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Unit "simulations.jl" of the PosDefManifoldML Package for Julia language
2-
# v 0.5.11 - last update June 2025
2+
# v 0.5.14- last update July 2025
33
#
44
# MIT License
55
# Copyright (c) 2019-2025,

src/cv.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ A call to [`crval`](@ref) results in an instance of this structure.
3939
4040
`.scoring` is the type of accuracy that is computed, given as a string.
4141
This is controlled when calling [`crval`](@ref).
42-
Currently *accuracy* and *balanced accuracy* are supported.
42+
Currently, *accuracy* and *balanced accuracy* are supported.
4343
4444
`.modelType` is the type of the machine learning model used for performing the
4545
cross-validation, given as a string.
4646
47-
`.nTrials` is the total number of trials entering the cross-validation
47+
`.nTrials` is the total number of trials entering the cross-validation.
4848
49-
`.matSize` is the size of the input matrices (trials)
49+
`.matSize` is the size of the input matrices (trials).
5050
5151
`.predLabels` is an `f`-vector of `z` integer vectors holding the vectors of
5252
predicted labels. There is one vector for each fold (`f`) and each containes
@@ -84,7 +84,7 @@ If function [`crval`](@ref) has not been compiled yet, the time includes the com
8484
In any case the provided estimate is subjected to high variability. To get a better estimate use the median or minimum
8585
across several runs or call the function using the [BenchmarkTools.jl](https://github.com/JuliaCI/BenchmarkTools.jl) package.
8686
87-
See [`crval`](@ref) for more informations
87+
See [`crval`](@ref) for more informations.
8888
"""
8989
struct CVres <: CVresult
9090
cvType :: String
@@ -162,7 +162,7 @@ Any other value will make the function returning the regular **accuracy**.
162162
Balanced accuracy is to be preferred for unbalanced classes.
163163
For balanced classes the balanced accuracy reduces to the
164164
regular accuracy, therefore there is no point in using regular accuracy,
165-
if not to avoid a few unnecessary computations when the class are balanced.
165+
if not to avoid a few unnecessary computations when the classes are balanced.
166166
167167
`hypTest` can be `nothing` or a symbol specifying the kind of statistical test to be carried out.
168168
At the moment, only `:Bayle` is a possible symbol and this test is performed by default.
@@ -189,7 +189,7 @@ If `outModels` is true, return a 2-tuple holding a [`CVres`](@ref) structure
189189
and a `nFolds`-vector of the model fitted for each fold,
190190
otherwise (default), return only a [`CVres`](@ref) structure.
191191
192-
If `⏩` the computations are multi-threaded across folds.
192+
If `⏩`, the computations are multi-threaded across folds.
193193
It is true by default. Set it to false if there are problems in running
194194
this function and for debugging.
195195
@@ -198,7 +198,8 @@ this function and for debugging.
198198
the [`fit!`](@ref) and [`predict`](@ref) function that will be called within each fold will
199199
we run in single-threaded mode. Vice versa, if you pass `⏩=false`, these two functions
200200
will be run in multi-threaded mode. This is done to avoid
201-
overshooting the number of threads to be activated.
201+
overshooting the number of threads to be activated. Because of this behavior,
202+
do not call this function in a multi-threaded loop.
202203
203204
`fitArgs` are optional keyword arguments that are passed to the
204205
[`fit`](@ref) function called for each fold of the cross-validation.
@@ -218,7 +219,7 @@ Note that if they are passed, they will be disabled:
218219
| | `folds` |
219220
220221
If you pass the `meanISR` argument, this must be nothing (default)
221-
or I (the identity matrix). If you pass `meanISR=I` for a tangent space model,
222+
or *I* (the identity matrix). If you pass `meanISR=I` for a tangent space model,
222223
parallel transport of the points to the identity before projecting
223224
the points onto the tangent space will not be carried out.
224225
This can be used if a recentering conditioner is passed in the `pipeline`
@@ -459,12 +460,12 @@ across calls of this function.
459460
This function is used in [`crval`](@ref). It constitutes the fundamental
460461
basis to implement customized cross-validation procedures.
461462
462-
Return the 2-tuple (indTr, indTe) where:
463+
Return the 2-tuple (`indTr`, `indTe`) where:
463464
464-
- indTr is an array of arrays where indTr[i][f] contains the training indices
465-
for class i in fold f
466-
- indTe is an array of arrays where indTe[i][f] contains the test indices
465+
- `indTr` is an array of arrays where `indTr[i][f]` contains the training indices
467466
for class i in fold f
467+
- `indTe` is an array of arrays where `indTe[i][f]` contains the test indices
468+
for class i in fold f.
468469
469470
Each array is organized by class and then by fold, ensuring stratified sampling
470471
across the cross-validation sets.

src/enlr.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ m2 = fit(ENLR(logEuclidean; alpha=0), PTr, yTr)
155155
# which is equivalent to
156156
m2 = fit(ENLR(logEuclidean), PTr, yTr; alpha=0)
157157
158-
# Note that, albeit model `m` has been created as a ridge model,
159-
# you have passed `m` and overwritten the `alpha` hyperparameter.
160-
# The metric, instead, cannot be overwritten.
161158
```
162159
"""
163160
mutable struct ENLR <: ENLRmodel
@@ -305,7 +302,7 @@ as argument `meanISR` and in this case this matrix will be used as the ISR of th
305302
Passed or computed, it will be written in the `.meanISR` field of the
306303
model structure created by this function. Notice that passing `I`, the matrices
307304
will be projected onto the tangent space at the identity without recentering them.
308-
This is possible if the matrices have been recentered bt a pre-conditioning pipeline
305+
This is possible if the matrices have been recentered by a pre-conditioning pipeline
309306
(see [`Pipeline`](@ref)).
310307
311308
If `meanISR` is not provided and the `.metric` field of the `model`

0 commit comments

Comments
 (0)