ktch.landmark
.GeneralizedProcrustesAnalysis#
- class ktch.landmark.GeneralizedProcrustesAnalysis(tol=1e-07, scaling=True, n_dim=2, n_jobs: int | None = None, debug=False)[source]#
Generalized Procrustes Analysis (GPA)
- Parameters:
- tol: float, default=10^-7
Torelance for convergence of Procrustes analysis.
- n_dim: int, default=2
Dimensions of the configurations.
- n_jobs: int, default=None
The number of parallel jobs to run for Procrustes analysis.
Notes
GPA for shape involves translating, rotating, and scaling the configurations to each other to minimize the sum of the squared distances with respect to positional, rotational, and size parameters, subject to a size constraint [Gower_1975], [Goodall_1991].
GPA for size-and-shape
References
[Gower_1975]Gower, J.C., 1975. Generalized procrustes analysis. Psychometrika 40, 33–51.
[Goodall_1991]Goodall, C., 1991. Procrustes Methods in the Statistical Analysis of Shape. J Royal Statistical Soc Ser B Methodol 53, 285–321.
- Attributes:
- mu_: ndarray, shape (n_landmarks, n_dim)
The mean shape of the aligned shapes.
- n_dim_: int, 2 or 3
Dimensions of the configurations.
Methods
fit
(X)Fit GPA.
GPA for shapes/size-and-shapes.
get_feature_names_out
([input_features])Get output feature names for transformation.
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
set_output
(*[, transform])Set output container.
set_params
(**params)Set the parameters of this estimator.
transform
(X)GPA for shapes/size-and-shapes.
- fit(X)[source]#
Fit GPA.
- Parameters:
- Xarray-like, shape (n_specimens, n_landmarks, n_dim)
/DataFrame, shape (n_specimens, n_landmarks * n_dim) Configurations to be aligned.
- Returns:
- selfobject
Returns the instance itself.
- fit_transform(X)[source]#
GPA for shapes/size-and-shapes.
- Parameters:
- Xarray-like, shape (n_specimens, n_landmarks * n_dim)
/DataFrame, shape (n_specimens, n_landmarks * n_dim) Configurations to be aligned.
- Returns:
- X_ndarray, shape (n_specimens, n_landmarks, n_dim)
Shapes/Size-and-Shape (aligned configurations)
- get_feature_names_out(input_features=None)#
Get output feature names for transformation.
- Parameters:
- input_featuresarray-like of str or None, default=None
Input features.
If input_features is None, then feature_names_in_ is used as feature names in. If feature_names_in_ is not defined, then the following input feature names are generated: [“x0”, “x1”, …, “x(n_features_in_ - 1)”].
If input_features is an array-like, then input_features must match feature_names_in_ if feature_names_in_ is defined.
- Returns:
- feature_names_outndarray of str objects
Same as input features.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequest
encapsulating routing information.
- get_params(deep=True)#
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- set_output(*, transform=None)#
Set output container.
See Introducing the set_output API for an example on how to use the API.
- Parameters:
- transform{“default”, “pandas”}, default=None
Configure output of transform and fit_transform.
“default”: Default output format of a transformer
“pandas”: DataFrame output
“polars”: Polars output
None: Transform configuration is unchanged
Added in version 1.4: “polars” option was added.
- Returns:
- selfestimator instance
Estimator instance.
- set_params(**params)#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.
- transform(X: npt.ArrayLike) npt.ArrayLike [source]#
GPA for shapes/size-and-shapes.
- Parameters:
- Xarray-like, shape (n_specimens, n_landmarks*n_dim)
Configurations to be aligned.
- scaling: bool, default=True
If True, the configurations are aligned by translation, rotation, and scaling. If False, the configurations are aligned by translation and rotation.
- Returns:
- X_ndarray, shape (n_specimens, n_landmarks, n_dim)
Shapes/Size-and-Shape (aligned configurations)