Implement core ML bridging utilities - #14
Open
ysims wants to merge 1 commit into
Open
Conversation
Replace the NotImplementedError placeholders in earthrs.ml.core with real, optional-dependency-guarded implementations: - to_numpy: converts Samples, row-mapping lists, or column-oriented mappings to (array, column_names); plain array-likes convert to a bare array. Falls back to dtype=object when values aren't numeric so nothing is lost. - prepare_training_data: splits a Samples table into aligned (X, y) via to_numpy, accepting either a label column name or a separate aligned label sequence, with optional NA-row dropping (None/NaN, matching the None-for-missing convention already used in earthrs.processing.core). - to_torch_dataset / to_tensorflow_dataset: wrap features/labels in a TensorDataset / tf.data.Dataset via numpy. - tile_scene: splits a Scene's band grids into tile_size x tile_size windows (stride defaults to tile_size), cropping partial edge tiles, offsetting scene.transform per tile, and preserving crs/sensor/ acquisition_time/history plus a tile_offset in metadata. - raster_predict: tiles a scene, stacks each tile's bands into a numpy array, batches tiles, and calls model.predict/model(), returning (tile, prediction) pairs so callers can reconstruct the full raster. Add ml / ml-torch / ml-tensorflow optional-dependency extras to pyproject.toml, and tests/test_ml.py covering all six functions (numpy/ torch/tensorflow paths use pytest.importorskip so the suite stays green without those installed). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the NotImplementedError placeholders in earthrs.ml.core with real, optional-dependency-guarded implementations:
Add ml / ml-torch / ml-tensorflow optional-dependency extras to pyproject.toml, and tests/test_ml.py covering all six functions (numpy/ torch/tensorflow paths use pytest.importorskip so the suite stays green without those installed).