geolatent.utils#
Utility sub-package for geolatent.
Submodules#
Functions#
|
Validate an optional class-name mapping. |
|
Assert that y is suitable for classification. |
|
Validate an (embeddings, labels) pair for latent-space visualisation. |
|
Validate and coerce a feature matrix. |
|
Validate and coerce a label / target vector. |
|
Validate that model exposes a scikit-learn-compatible interface. |
Package Contents#
- geolatent.utils.validate_class_names(class_names: Dict | None, unique_classes: numpy.ndarray) Dict | None[source]#
Validate an optional class-name mapping.
- geolatent.utils.validate_classification_labels(y: numpy.ndarray, *, name: str = 'y') numpy.ndarray[source]#
Assert that y is suitable for classification.
- Parameters:
y (np.ndarray) – Label vector (already validated by
validate_label_vector()).name (str)
- Returns:
y – The input unchanged.
- Return type:
np.ndarray
- Raises:
ValueError – If y contains only one unique class (degenerate problem).
- geolatent.utils.validate_embeddings(embeddings: Any, labels: Any) Tuple[numpy.ndarray, numpy.ndarray][source]#
Validate an (embeddings, labels) pair for latent-space visualisation.
- Parameters:
embeddings (array-like of shape (n_samples, n_dims)) – High-dimensional embedding vectors.
labels (array-like of shape (n_samples,)) – Integer or string class labels.
- Returns:
embeddings (np.ndarray of shape (n_samples, n_dims))
labels (np.ndarray of shape (n_samples,))
- geolatent.utils.validate_feature_matrix(X: Any, *, min_samples: int = 4, min_features: int = 2, name: str = 'X') numpy.ndarray[source]#
Validate and coerce a feature matrix.
- Parameters:
- Returns:
X
- Return type:
np.ndarray of shape (n_samples, n_features), dtype float64
- Raises:
TypeError – If X cannot be converted to a NumPy array.
ValueError – If X is not 2-D, contains fewer than min_samples rows, fewer than min_features columns, or contains non-finite values.
- geolatent.utils.validate_label_vector(y: Any, *, n_samples: int, name: str = 'y') numpy.ndarray[source]#
Validate and coerce a label / target vector.
- Parameters:
- Returns:
y
- Return type:
np.ndarray of shape (n_samples,)
- Raises:
TypeError – If y cannot be converted to a NumPy array.
ValueError – If y is not 1-D or its length does not match n_samples.
- geolatent.utils.validate_sklearn_model(model: Any, *, require_predict_proba: bool = False) None[source]#
Validate that model exposes a scikit-learn-compatible interface.
- Parameters:
model (Any) – The model to validate.
require_predict_proba (bool) – If
True, also assert thatpredict_probais present.
- Raises:
TypeError – If model does not expose
predict.AttributeError – If require_predict_proba is
Trueandpredict_probais absent.