LeastSquares#

class skfda.preprocessing.registration.validation.LeastSquares[source]#

Cross-validated measure of the registration procedure.

Computes a cross-validated measure of the level of synchronization [James07]:

\[ls=1 - \frac{1}{N} \sum_{i=1}^{N} \frac{\int\left(\tilde{f}_{i}(t)- \frac{1}{N-1} \sum_{j \neq i} \tilde{f}_{j}(t)\right)^{2} dt}{\int \left(f_{i}(t)-\frac{1}{N-1} \sum_{j \neq i} f_{j}(t)\right)^{2} dt}\]

where \(f_i\) and \(\tilde f_i\) are the original and the registered data respectively.

The \(ls\) measures the total cross-sectional variance of the aligned functions, relative to the original value. A value of \(1\) would indicate an identical shape for all registered curves, while zero corresponds to no improvement in the synchronization. It can be negative because the model can be arbitrarily worse.

Attributes:

eval_points (array_like, optional) – Set of points where the functions are evaluated to obtain a discrete representation and perform the calculation.

Parameters:
  • estimator (RegistrationTransformer) – Registration transformer.

  • X (FData) – Original functional data.

  • y (FData) – Registered functional data.

Note

The original least square measure used in [S11-5-2-1] is defined as \(1 - ls\), but has been modified according to the scikit-learn scorers, where higher values correspond to better cross-validated measures.

References

[James07]

G. James. Curve alignments by moments. Annals of Applied Statistics, 1(2):480–501, 2007.

[S11-5-2-1]

Srivastava, Anuj et. al. Registration of Functional Data Using Fisher-Rao Metric (2011). In Comparisons with other Methods (p. 18). arXiv:1103.3817v2.

Examples

Calculate the score of the shift registration of a sinusoidal process synthetically generated.

>>> from skfda.preprocessing.registration.validation import \
...                                                        LeastSquares
>>> from skfda.preprocessing.registration import (
...     LeastSquaresShiftRegistration,
... )
>>> from skfda.datasets import make_sinusoidal_process
>>> X = make_sinusoidal_process(error_std=0, random_state=0)

Fit the registration procedure.

>>> shift_registration = LeastSquaresShiftRegistration()
>>> shift_registration.fit(X)
LeastSquaresShiftRegistration(...)

Compute the least squares score. >>> scorer = LeastSquares() >>> score = scorer(shift_registration, X) >>> round(score, 3) 0.953

Methods

score_function(X, y)

Compute the score of the transformation performed.

score_function(X, y)[source]#

Compute the score of the transformation performed.

Parameters:
  • X (FData) – Original functional data.

  • y (FData) – Functional data registered.

Returns:

Score of the transformation.

Return type:

float