Shapes
All shapes inherit from BaseShape and implement the same callable interface:
calling an instance with an array of labels returns a pairwise distance matrix.
Base
smds.shapes.base_shape.BaseShape
Bases: BaseEstimator, ABC
Abstract base class for defining manifold shapes.
This class serves as a template for transforming input labels (y) into a pairwise distance matrix that represents the geometry of a specific shape (manifold). It handles input validation, optional normalization, and structural integrity checks on the output matrix.
Subclasses must implement:
- y_ndim: Property defining expected input dimensionality.
- normalize_labels: Property flag for normalization behavior.
- _compute_distances: The core logic for mapping labels to distances.
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int or tuple of int
|
Abstract property. The expected dimensionality of the input labels. |
normalize_labels |
bool
|
Abstract property. Whether to normalize inputs before computation. |
Source code in smds/shapes/base_shape.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
y_ndim
abstractmethod
property
y_ndim: int | tuple[int, ...]
Get the required dimensionality of the input labels y.
Returns:
| Type | Description |
|---|---|
int or tuple of int
|
The number of dimensions expected for the input array. - 1: 1D array (e.g., time series, clusters). - 2: 2D array (e.g., lat/lon coordinates, hierarchical levels). A tuple declares that several are accepted, e.g. |
normalize_labels
abstractmethod
property
normalize_labels: bool
Get the flag indicating whether input labels should be normalized.
Returns:
| Type | Description |
|---|---|
bool
|
True if |
__call__
__call__(y: NDArray[float64]) -> NDArray[np.float64]
Compute the pairwise distance matrix for the given labels.
This is the main entry point (Template Method). It performs the
following steps:
1. Validates the input y (dimensions and emptiness).
2. Normalizes y if self.normalize_labels is True.
3. Calls the subclass implementation of _compute_distances.
4. Validates that the output is a square matrix.
5. Enforces a zero diagonal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
NDArray[float64]
|
The input labels or coordinates used to position points on the
manifold. Must match |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
A square matrix of shape (n_samples, n_samples) containing pairwise Euclidean distances on the defined manifold. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in smds/shapes/base_shape.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
Continuous Shapes
CircularShape
smds.shapes.continuous_shapes.circular.CircularShape
Bases: BaseShape
Compute Euclidean (chord) distances for continuous data on a circular manifold.
This shape wraps continuous normalized values onto a circle and calculates the straight-line (chord) distance between them through the circle's interior. This differs from the arc length (geodesic) distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radious
|
float
|
The radius of the circle. Default is 1.0. (Note: The current implementation calculates distances for a unit circle regardless of this parameter). |
1.0
|
normalize_labels
|
bool
|
Whether to normalize labels to the range [0, 1]. Default is True. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (1). Expects scalar values. |
Source code in smds/shapes/continuous_shapes/circular.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
SemicircularShape
smds.shapes.continuous_shapes.semicircular.SemicircularShape
Bases: BaseShape
Compute Euclidean (chord) distances for points mapped to a semicircle.
This shape maps normalized 1D scalar values to angles on a unit semicircle (ranging from 0 to \(\pi\)) and computes the straight-line (chord) distance between them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize_labels
|
bool
|
Whether to normalize labels to the range [0, 1]. Default is True. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (1). Expects 1D scalar values. |
Source code in smds/shapes/continuous_shapes/semicircular.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
EuclideanShape
smds.shapes.continuous_shapes.euclidean.EuclideanShape
Bases: BaseShape
Compute Euclidean (linear) distances for continuous data in n dimensions.
This shape models data lying in a flat Euclidean space of arbitrary
dimensionality. Inputs of shape (n_samples,) are treated as points on a
line, inputs of shape (n_samples, n_features) as points in
:math:\mathbb{R}^{n\_features}.
Reference: Table 1 in "Shape Happens" paper (referred to as 'linear').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize_labels
|
bool
|
Whether to normalize labels to the range [0, 1]. Default is True. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
tuple of int
|
Accepted label dimensionalities, |
Notes
:class:~smds.SupervisedMDS defaults n_components to 1 for this shape,
since scalar labels are the common case. With (n_samples, n_features)
labels you almost always want to pass n_components=n_features
explicitly; otherwise the embedding is truncated to a single dimension.
Source code in smds/shapes/continuous_shapes/euclidean.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
LogLinearShape
smds.shapes.continuous_shapes.log_linear.LogLinearShape
Bases: BaseShape
Compute distances based on logarithmic scaling.
This shape models data where differences are more significant at smaller scales than at larger scales (e.g., sound intensity, earthquake magnitude). The distance is defined as the absolute difference between the logarithms of the values.
Reference: Table 1 in the "Shape Happens" paper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (1). Expects non-negative continuous values. |
Source code in smds/shapes/continuous_shapes/log_linear.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
SpiralShape
smds.shapes.continuous_shapes.spiral_shape.SpiralShape
Bases: BaseShape
Arrange points in an Archimedean spiral pattern.
This class generates a shape where points are arranged along a spiral trajectory defined by the equation \(r = a + b\theta\). The distance metric is computed based on the Euclidean distance between these points in Cartesian coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_radius
|
float
|
The starting radius of the spiral (offset from the origin), corresponding to \(a\) in the Archimedean spiral equation. Default is 0.5. |
0.5
|
growth_rate
|
float
|
The rate at which the spiral expands away from the center for every radian of rotation, corresponding to \(b\) in the Archimedean spiral equation. Default is 1.0. |
1.0
|
num_turns
|
float
|
The total number of complete rotations the spiral makes. This scales the input labels mapping them to the angle \(\theta\). Default is 2.0. |
2.0
|
normalize_labels
|
bool
|
Whether to normalize the input labels |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
The dimensionality of the label array expected by this shape (1). |
initial_radius |
float
|
The configured starting radius. |
growth_rate |
float
|
The configured growth rate. |
num_turns |
float
|
The configured number of turns. |
Source code in smds/shapes/continuous_shapes/spiral_shape.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized to [0, 1].
KleinBottleShape
smds.shapes.continuous_shapes.klein_bottle.KleinBottleShape
Bases: BaseShape
Manifold hypothesis representing a Klein Bottle topology.
This shape assumes the data lies on a 2D surface that is non-orientable. Requires exactly 2 dimensions as (u, v) parameters. If < 2 dimensions, zeros are padded. If > 2 dimensions, raises an error. Maps these 2 dimensions to the unit square [0, 1] x [0, 1]. Computes pairwise distances respecting the Klein bottle identifications: - Top/Bottom edges match (Cylinder): (u, 0) ~ (u, 1) - Left/Right edges match with a Twist (Möbius): (0, v) ~ (1, 1-v)
Reference: Wolfram MathWorld: https://mathworld.wolfram.com/KleinBottle.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize_labels
|
bool
|
Whether to normalize labels to the range [0, 1]. Default is True. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (2). Expects (u, v) parameters. |
Source code in smds/shapes/continuous_shapes/klein_bottle.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
y_ndim
property
y_ndim: int
int: Dimensionality of input labels (2). Expects (u, v) parameters.
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
TorusShape
smds.shapes.continuous_shapes.torus.TorusShape
Bases: BaseShape
Compute geodesic distances on a flat torus (T\ :sup:1 × T\ :sup:1) manifold.
Models data lying on the product of two circles. Input coordinates are mapped onto the unit square [0, 1] × [0, 1] with periodic boundary conditions in both directions:
- (u, 0) ~ (u, 1) — cylinder wrap in the v direction.
- (0, v) ~ (1, v) — cylinder wrap in the u direction.
If the input has more than 2 dimensions it is first reduced to 2 via PCA; if it has fewer than 2 dimensions zeros are padded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radii
|
tuple of (float, float)
|
Scaling weights (r1, r2) for the two cyclic dimensions.
Default is |
(1.0, 1.0)
|
normalize_labels
|
bool
|
Whether to normalize labels to the range [0, 1]. Default is True. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (2). Expects (u, v) parameters. |
Source code in smds/shapes/continuous_shapes/torus.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
y_ndim
property
y_ndim: int
int: Expected input dimensionality (2).
radii
property
radii: tuple[float, float]
Tuple of (float, float): Scaling weights for the two cyclic dimensions.
normalize_labels
property
normalize_labels: bool
bool: Whether labels are normalized to the unit square.
Discrete Shapes
ClusterShape
smds.shapes.discrete_shapes.cluster.ClusterShape
Bases: BaseShape
Compute ideal distances for categorical data (0 for same, 1 for different).
This shape models data where the only meaningful distinction is category membership. The ideal distance is defined as 0 for points within the same category and 1 for points in different categories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (1). Expects a 1D array of category labels. |
Source code in smds/shapes/discrete_shapes/cluster.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
ChainShape
smds.shapes.discrete_shapes.chain.ChainShape
Bases: BaseShape
Compute sparse cyclic distances where non-neighbors are disconnected.
This shape models a closed loop sequence. Unlike DiscreteCircularShape,
which computes the full distance matrix, this shape enforces locality:
points separated by a distance greater than or equal to threshold are
marked as disconnected (distance = -1.0).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
float
|
The distance cutoff for defining neighbors. Pairs with a cyclic distance less than this value are connected. Default is 2.0 (connects adjacent integers with distance 1). |
2.0
|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (1). Expects ordered sequential data. |
Source code in smds/shapes/discrete_shapes/chain.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
DiscreteCircularShape
smds.shapes.discrete_shapes.discrete_circular.DiscreteCircularShape
Bases: BaseShape
Compute distances for ordered, cyclical data (e.g., months, hours).
This shape models features with a fixed number of ordered steps that wrap around (periodic boundary conditions). The ideal geometry forms a ring or regular polygon where adjacent integer categories are equidistant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_points
|
int
|
The total cycle length (modulus). For example, 12 for months or 24 for hours.
If None, it is inferred as |
None
|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False, as discrete shapes usually rely on raw integer steps. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (1). Expects 1D array of discrete steps. |
Source code in smds/shapes/discrete_shapes/discrete_circular.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
HierarchicalShape
smds.shapes.discrete_shapes.hierarchical.HierarchicalShape
Bases: BaseShape
Compute distances based on hierarchical (tree-structured) categorical data.
This shape models data organized in levels (e.g., Country > State > City). The distance between two points is determined by the specific level at which they first diverge. Higher levels (earlier indices) typically represent larger conceptual distances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level_distances
|
NDArray[float64]
|
An array of distance penalties corresponding to each level of the hierarchy.
|
required |
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False, as hierarchical labels are typically discrete categories. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (2). Expects (n_samples, n_levels). |
level_distances |
NDArray[float64]
|
The array of distances converted from the input array. |
Source code in smds/shapes/discrete_shapes/hierarchical.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
GraphGeodesicShape
smds.shapes.discrete_shapes.graph_geodesic.GraphGeodesicShape
Bases: BaseShape
Approximate manifold distances via a k-nearest-neighbors geodesic graph.
Constructs a KNN graph over the input coordinates and computes the shortest path between all pairs (Isomap approach). This lets the model respect the intrinsic geometry of curved manifolds without knowing their equation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_neighbors
|
int
|
Number of nearest neighbors to connect each point to. Default is 5. Too small a value may leave the graph disconnected; too large a value may introduce shortcuts that distort the geodesic distances. |
5
|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is True. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (2). Expects (n_samples, n_features). |
Source code in smds/shapes/discrete_shapes/graph_geodesic.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
y_ndim
property
y_ndim: int
int: Dimensionality of the input labels (2).
normalize_labels
property
normalize_labels: bool
bool: Whether to normalize the input labels.
PolytopeShape
smds.shapes.discrete_shapes.polytope.PolytopeShape
Bases: BaseShape
Arrange cluster centroids at maximally separated vertices of a unit polytope.
Places n_clusters distinct points on the surface of an n_dim-dimensional
unit sphere using iterative repulsion, then maps each input point to its
cluster centroid and computes Euclidean distances between centroids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_dim
|
int
|
Number of dimensions of the embedding sphere. Default is 3. |
3
|
n_iter
|
int
|
Number of repulsion iterations. Default is 500. |
500
|
lr
|
float
|
Step size for the repulsion update. Default is 0.1. |
0.1
|
seed
|
int
|
Random seed for reproducibility. Default is None. |
None
|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (1). Expects a 1D array of cluster labels. |
Source code in smds/shapes/discrete_shapes/polytope.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
y_ndim
property
y_ndim: int
Dimensionality of the input labels.
normalize_labels
property
normalize_labels: bool
Whether to normalize the input labels.
Spatial Shapes
SphericalShape
smds.shapes.spatial_shapes.spherical.SphericalShape
Bases: BaseShape
Compute Euclidean (chord) distances between points projected onto a sphere.
Unlike GeodesicShape which measures distance along the surface, this shape measures the straight-line distance through the sphere's volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius of the sphere. Default is 1.0. |
1.0
|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (2). Expects (n_samples, 2) for lat/lon. |
Source code in smds/shapes/spatial_shapes/spherical.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
CylindricalShape
smds.shapes.spatial_shapes.cylindrical.CylindricalShape
Bases: BaseShape
Compute Euclidean distances between points mapped onto a cylinder.
This class maps input coordinates to a 3D cylindrical surface. One dimension is treated as the height (linear) and the other as the angle (circular) around a cylinder of fixed radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
The radius of the cylinder. Default is 1.0. |
1.0
|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (2). Expects (n_samples, 2). |
Source code in smds/shapes/spatial_shapes/cylindrical.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.
GeodesicShape
smds.shapes.spatial_shapes.geodesic.GeodesicShape
Bases: BaseShape
Compute geodesic distances on a spherical manifold (great-circle distance https://en.wikipedia.org/wiki/Great-circle_distance).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius of the sphere. Default is 1.0. |
1.0
|
normalize_labels
|
bool
|
Whether to normalize labels using the base class logic. Default is False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
y_ndim |
int
|
Dimensionality of input labels (2). Expects (n_samples, 2) for lat/lon. |
Source code in smds/shapes/spatial_shapes/geodesic.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
normalize_labels
property
normalize_labels: bool
bool: Whether input labels are normalized.