Procrustes Module
Procrustes-related functions.
|
A classifier that uses Procrustes analysis to classify 3D shapes based on their similarity to a set of medoids. |
Fit the classifier to a set of training shapes. |
|
Predict the class labels of a set of test shapes. |
|
|
Predict the class probabilities of a set of test shapes. |
Calculate the Procrustes disparity between two shapes. |
|
|
Predicts the class of a given shape by comparing it to a set of medoids using the Procrustes distance. |
- class procrustes.ShapeClassifier(medoids)[source]
A classifier that uses Procrustes analysis to classify 3D shapes based on their similarity to a set of medoids.
- Parameters:
medoids (List[np.ndarray]) – A list of medoid shapes to compare against.
- fit(X)[source]
Fit the classifier to a set of training shapes.
- Parameters:
X (List[np.ndarray]) – The set of training shapes to fit the classifier to.
- Returns:
The fitted classifier object.
- Return type:
- predict(X: List[ndarray]) ndarray[source]
Predict the class labels of a set of test shapes.
- Parameters:
X (List[np.ndarray]) – The set of test shapes to predict class labels for.
- Returns:
An array of predicted class labels.
- Return type:
np.ndarray
- predict_class(shape: ndarray, soft: bool = False, use_weighted: bool = False) ndarray[source]
Predicts the class of a given shape by comparing it to a set of medoids using the Procrustes distance.
- Parameters:
medoids (np.ndarray) – Array of shape medoids used to compare the input shape.
shape (np.ndarray) – Input shape to classify.
soft (bool, optional) – If True, returns a soft classification, where the output is an array of probabilities of belonging to each class. If False, returns a hard classification, where the output is the index of the closest medoid.
use_weighted (bool, optional) – If True and soft=True, uses weighted distances instead of the exponential function to calculate the probabilities.
- Returns:
If soft=True, returns an array of probabilities of belonging to each class. If soft=False, returns the index of the closest medoid.
- Return type:
np.ndarray
- predict_proba(X: List[ndarray], use_weighted: bool = False) ndarray[source]
Predict the class probabilities of a set of test shapes.
- Parameters:
X (List[np.ndarray]) – The set of test shapes to predict class probabilities for.
use_weighted (bool) – Whether to use weighted probabilities based on distance, defaults to False.
- Returns:
An array of predicted class probabilities.
- Return type:
np.ndarray
- static procrustes_disparity(shape_1: ndarray, shape_2: ndarray) float[source]
Calculate the Procrustes disparity between two shapes.
- Parameters:
shape_1 (np.ndarray) – The first shape.
shape_2 (np.ndarray) – The second shape.
- Returns:
The Procrustes disparity between the two shapes.
- Return type:
float
- set_predict_proba_request(*, use_weighted: bool | None | str = '$UNCHANGED$') ShapeClassifier
Request metadata passed to the
predict_probamethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredict_probaif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict_proba.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.Parameters
- use_weightedstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
use_weightedparameter inpredict_proba.
Returns
- selfobject
The updated object.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') ShapeClassifier
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.Parameters
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
Returns
- selfobject
The updated object.