resolve-core 1.2.0__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {resolve_core-1.2.0 → resolve_core-1.3.0}/PKG-INFO +1 -1
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/gap_fitting.cpp +28 -6
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/resolve_capi.cpp +1 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/suite.cpp +35 -1
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/gap_fitting.hpp +19 -6
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/suite.hpp +19 -4
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/types.hpp +1 -1
- {resolve_core-1.2.0 → resolve_core-1.3.0}/pyproject.toml +1 -1
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_suite.cpp +4 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/resolve_core/_suite.py +5 -2
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/adapter.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/categorical.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/checkpoint.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/continuous_block.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/dataset.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/encoder_common.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/excelformer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/fine_tune.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/ft_transformer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/fuzzy_automaton.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/fuzzy_index.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/fuzzy_internal.h +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/fuzzy_search.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/geo.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/gnn.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/gpu.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/hetero_gnn.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/json.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/loss.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/lr_schedule.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/model.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/name_resolution.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/plot_columns.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/plot_encoder_embed.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/plot_encoder_hash.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/plot_encoder_rank_pool.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/plot_encoder_sparse.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/plot_encoder_transformer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/plot_neighbours.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/predictor.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/pretraining.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/process.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/retrieval.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/saint.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/selection_metric.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/sha256.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/sparse_rows.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/species_encoder.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/species_encoding.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/species_graph.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/species_pool.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/suite_derive.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/tabm.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/tabnet.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/target_labels.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/task_head.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/tensor_pack.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/terrain_codec.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/terrain_correction.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/terrain_field.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/terrain_source.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/trainer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/trainer_checkpoint.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/traitnet.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cpp_src/vae.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cuda/feature_hash.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cuda/kernels.cu +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/cuda/launch_common.cuh +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/adapter.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/aggregate_arity.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/architectures.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/aux_loss.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/categorical.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/checkpoint.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/checkpoint_schema_keys.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/config_json.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/config_registry.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/continuous_block.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/csv_reader.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/csv_utils.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/cuda/feature_hash.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/cuda/hash_kernels.h +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/dataset.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/encoder.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/enum_names.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/env.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/excelformer.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/experts.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/fine_tune.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/ft_transformer.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/fuzzy.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/geo.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/gnn.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/gpu.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/grad_clip.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/hash_core.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/hetero_gnn.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/io_retry.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/json.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/ln_mlp.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/loss.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/lr_schedule.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/lru_cache.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/mlp_block.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/model.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/name_pool.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/name_resolution.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/number_text.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/plot_columns.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/plot_encoder_embed.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/plot_encoder_hash.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/plot_encoder_rank_pool.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/plot_encoder_sparse.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/plot_encoder_transformer.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/plot_inputs.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/plot_neighbours.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/predictor.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/pretraining.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/process.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/resolve.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/resolve_capi.h +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/resolve_capi_symbols.inc +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/retrieval.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/role_mapping.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/row_cells.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/row_source.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/saint.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/scalers.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/selection_metric.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/sha256.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/sparse_rows.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/species_encoder.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/species_encoding.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/species_graph.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/species_pool.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/string_list_archive.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/tabm.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/tabnet.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/target_labels.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/target_transform.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/task_head.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/tensor_pack.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/terrain_codec.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/terrain_correction.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/terrain_field.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/terrain_source.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/trainer.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/traitnet.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/utils.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/include/resolve/vae.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/CMakeLists.txt +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/README.md +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_common.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_dataset.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_enums.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_fine_tune.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_fuzzy.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_gap_fitting.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_metrics.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_model.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_names.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_plot_inputs.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_pretraining.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_retrieval.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_terrain.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_trainer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/bindings_types.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/resolve_core/__init__.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/resolve_core/_checkpoint.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/resolve_core/_from_pandas.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/resolve_core/_gap_fitting.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/python/src/resolve_core/_names.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/resolve_core_sources.cmake +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/resolve_cuda_kernels.cmake +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/resolve_openmp.cmake +0 -0
- {resolve_core-1.2.0 → resolve_core-1.3.0}/resolve_warnings.cmake +0 -0
|
@@ -1338,6 +1338,7 @@ torch::Tensor recorded_plots(const torch::Tensor& recorded) {
|
|
|
1338
1338
|
|
|
1339
1339
|
std::string gap_method_label(int64_t code) {
|
|
1340
1340
|
if (code == kGapRecorded) return "recorded";
|
|
1341
|
+
if (code == kGapNotImputed) return "not_imputed";
|
|
1341
1342
|
return enum_to_name(static_cast<GapMethod>(code));
|
|
1342
1343
|
}
|
|
1343
1344
|
|
|
@@ -1347,6 +1348,7 @@ json::Value gap_fit_report_to_json(const GapFitReport& report) {
|
|
|
1347
1348
|
out.set("scale", enum_to_name(report.scale));
|
|
1348
1349
|
out.set("n_complete", report.n_complete);
|
|
1349
1350
|
out.set("n_gaps", report.n_gaps);
|
|
1351
|
+
out.set("n_not_imputed", report.n_not_imputed);
|
|
1350
1352
|
if (!report.skipped.empty()) out.set("skipped", report.skipped);
|
|
1351
1353
|
json::Value axes = json::Value::object();
|
|
1352
1354
|
for (const auto& axis : report.axes) {
|
|
@@ -1452,10 +1454,24 @@ void validate_inputs(const GapTarget& target, const torch::Tensor& raw, const to
|
|
|
1452
1454
|
}
|
|
1453
1455
|
}
|
|
1454
1456
|
|
|
1455
|
-
// The
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1457
|
+
// The plots of a fit, as rows: the complete plots (every recorded value
|
|
1458
|
+
// finite), the gaps, and the plots lacking the value that were not imputed
|
|
1459
|
+
// (a raw value not finite). With `raw_values` undefined every plot counts as
|
|
1460
|
+
// imputed. A plot recording the value without a raw prediction is in none.
|
|
1461
|
+
struct Division {
|
|
1462
|
+
torch::Tensor complete;
|
|
1463
|
+
torch::Tensor gaps;
|
|
1464
|
+
torch::Tensor not_imputed;
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
Division divide_plots(const torch::Tensor& recorded_values, const torch::Tensor& raw_values) {
|
|
1468
|
+
const torch::Tensor recorded = recorded_plots(recorded_values);
|
|
1469
|
+
const torch::Tensor imputed = raw_values.defined() ? recorded_plots(raw_values)
|
|
1470
|
+
: torch::ones_like(recorded);
|
|
1471
|
+
const torch::Tensor lacking = recorded.logical_not();
|
|
1472
|
+
auto rows = [](const torch::Tensor& mask) { return mask.nonzero().select(1, 0); };
|
|
1473
|
+
return {rows(recorded.logical_and(imputed)), rows(lacking.logical_and(imputed)),
|
|
1474
|
+
rows(lacking.logical_and(imputed.logical_not()))};
|
|
1459
1475
|
}
|
|
1460
1476
|
|
|
1461
1477
|
// One target's plots in the plane, its searches, the gaps' distances and the
|
|
@@ -1520,7 +1536,9 @@ GapFolds gap_folds(const GapTarget& target, const torch::Tensor& recorded, const
|
|
|
1520
1536
|
config.validate();
|
|
1521
1537
|
validate_inputs(target, torch::Tensor(), recorded, plots);
|
|
1522
1538
|
const torch::Tensor recorded_values = as_double(recorded);
|
|
1523
|
-
const
|
|
1539
|
+
const Division division = divide_plots(recorded_values, torch::Tensor());
|
|
1540
|
+
const torch::Tensor& cal_index = division.complete;
|
|
1541
|
+
const torch::Tensor& test_index = division.gaps;
|
|
1524
1542
|
if (cal_index.size(0) < 2 || test_index.size(0) == 0) {
|
|
1525
1543
|
throw std::invalid_argument("gap fitting: a fold layout needs at least two complete plots and one gap");
|
|
1526
1544
|
}
|
|
@@ -1542,15 +1560,19 @@ GapFit fit_gaps(const GapTarget& target, const torch::Tensor& raw, const torch::
|
|
|
1542
1560
|
const int64_t n = plots.species.size(0);
|
|
1543
1561
|
const torch::Tensor raw_values = as_double(raw);
|
|
1544
1562
|
const torch::Tensor recorded_values = as_double(recorded);
|
|
1545
|
-
const
|
|
1563
|
+
const Division division = divide_plots(recorded_values, raw_values);
|
|
1564
|
+
const torch::Tensor& cal_index = division.complete;
|
|
1565
|
+
const torch::Tensor& test_index = division.gaps;
|
|
1546
1566
|
|
|
1547
1567
|
GapFit out;
|
|
1548
1568
|
out.report.target = target.name;
|
|
1549
1569
|
out.report.scale = target.scale;
|
|
1550
1570
|
out.report.n_complete = cal_index.size(0);
|
|
1551
1571
|
out.report.n_gaps = test_index.size(0);
|
|
1572
|
+
out.report.n_not_imputed = division.not_imputed.size(0);
|
|
1552
1573
|
out.fitted = recorded_values.clone();
|
|
1553
1574
|
out.method = torch::full({n}, kGapRecorded, kLong);
|
|
1575
|
+
out.method.index_put_({division.not_imputed}, kGapNotImputed);
|
|
1554
1576
|
if (out.report.n_gaps == 0) return out;
|
|
1555
1577
|
if (out.report.n_complete < 2) {
|
|
1556
1578
|
out.report.skipped = "fewer than two complete plots";
|
|
@@ -2616,6 +2616,7 @@ resolve_value* suite_predictions_to_value(const SuitePredictions& p) {
|
|
|
2616
2616
|
v_put(m, "recognised_share", defined_or_null(t.recognition.count_share, RESOLVE_VALUE_DOUBLE_ARRAY));
|
|
2617
2617
|
v_put(m, "recognised_abundance_share",
|
|
2618
2618
|
defined_or_null(t.recognition.abundance_share, RESOLVE_VALUE_DOUBLE_ARRAY));
|
|
2619
|
+
v_put(m, "imputed", t.imputed.defined() ? tensor_to_ivec(t.imputed) : v_null());
|
|
2619
2620
|
v_put(m, "recorded", t.recorded.defined() ? tensor_to_ivec(t.recorded) : v_null());
|
|
2620
2621
|
v_put(m, "gap_fit", t.gap_fit ? gap_fit_to_value(*t.gap_fit) : v_null());
|
|
2621
2622
|
if (t.terrain) {
|
|
@@ -1058,7 +1058,9 @@ SuiteColumn label_column(std::string name, const torch::Tensor& codes,
|
|
|
1058
1058
|
const auto c = codes.to(torch::kCPU).to(torch::kLong).contiguous();
|
|
1059
1059
|
const int64_t* data = c.numel() > 0 ? c.data_ptr<int64_t>() : nullptr;
|
|
1060
1060
|
column.text.reserve(static_cast<size_t>(c.numel()));
|
|
1061
|
-
for (int64_t i = 0; i < c.numel(); ++i)
|
|
1061
|
+
for (int64_t i = 0; i < c.numel(); ++i) {
|
|
1062
|
+
column.text.push_back(data[i] == kUnlabelledClass ? std::string() : class_label(class_names, data[i]));
|
|
1063
|
+
}
|
|
1062
1064
|
return column;
|
|
1063
1065
|
}
|
|
1064
1066
|
|
|
@@ -1146,6 +1148,7 @@ std::vector<SuiteColumn> suite_prediction_columns(const SuitePredictions& predic
|
|
|
1146
1148
|
columns.push_back(number_column(name + "_dem", t.terrain->dem, n));
|
|
1147
1149
|
columns.push_back(number_column(name + "_dem_1km", t.terrain->dem_1km, n));
|
|
1148
1150
|
}
|
|
1151
|
+
if (t.imputed.defined()) columns.push_back(logical_column(name + "_imputed", t.imputed));
|
|
1149
1152
|
columns.push_back(number_column(name + "_n_species", t.recognition.n_species, n));
|
|
1150
1153
|
columns.push_back(number_column(name + "_n_recognised", t.recognition.n_recognised, n));
|
|
1151
1154
|
columns.push_back(number_column(name + "_recognised_share", t.recognition.count_share, n));
|
|
@@ -1399,6 +1402,36 @@ torch::Tensor reorder(const torch::Tensor& t, const torch::Tensor& perm, int64_t
|
|
|
1399
1402
|
return t.index_select(dim, perm);
|
|
1400
1403
|
}
|
|
1401
1404
|
|
|
1405
|
+
// `values` with every plot that is not imputed blanked: NaN for a number,
|
|
1406
|
+
// kUnlabelledClass for a class code. `plot_dim` is the dimension running over
|
|
1407
|
+
// plots. Undefined tensors pass through.
|
|
1408
|
+
torch::Tensor withhold(const torch::Tensor& values, const torch::Tensor& imputed, int64_t plot_dim) {
|
|
1409
|
+
if (!values.defined()) return values;
|
|
1410
|
+
std::vector<int64_t> shape(static_cast<std::size_t>(values.dim()), 1);
|
|
1411
|
+
shape[static_cast<std::size_t>(plot_dim)] = imputed.size(0);
|
|
1412
|
+
const torch::Tensor keep = imputed.to(values.device()).view(shape);
|
|
1413
|
+
const torch::Tensor blank =
|
|
1414
|
+
values.is_floating_point()
|
|
1415
|
+
? torch::full({}, std::numeric_limits<double>::quiet_NaN(), values.options())
|
|
1416
|
+
: torch::full({}, kUnlabelledClass, values.options());
|
|
1417
|
+
return torch::where(keep, values, blank);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
// A target's imputed mask from its recognition, and every per-plot output it
|
|
1421
|
+
// has so far blanked where the plot is not imputed.
|
|
1422
|
+
void withhold_unimputed(SuiteTargetPrediction& out) {
|
|
1423
|
+
const auto n = out.value.size(0);
|
|
1424
|
+
out.imputed = out.recognition.n_recognised.defined()
|
|
1425
|
+
? (out.recognition.n_recognised.to(torch::kCPU) > 0)
|
|
1426
|
+
: torch::ones({n}, torch::kBool);
|
|
1427
|
+
if (out.imputed.all().item<bool>()) return;
|
|
1428
|
+
out.value = withhold(out.value, out.imputed, 0);
|
|
1429
|
+
out.agreement = withhold(out.agreement, out.imputed, 0);
|
|
1430
|
+
out.probabilities = withhold(out.probabilities, out.imputed, 0);
|
|
1431
|
+
out.dispersion = withhold(out.dispersion, out.imputed, 0);
|
|
1432
|
+
out.members = withhold(out.members, out.imputed, 1);
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1402
1435
|
} // namespace
|
|
1403
1436
|
|
|
1404
1437
|
SuitePredictor SuitePredictor::load(const std::string& dir, const SuiteLoadOptions& options) {
|
|
@@ -1672,6 +1705,7 @@ SuitePredictions SuitePredictor::predict(const SuiteInput& input,
|
|
|
1672
1705
|
reorder(r.n_species, perm, 0), reorder(r.n_recognised, perm, 0),
|
|
1673
1706
|
reorder(r.count_share, perm, 0), reorder(r.abundance_share, perm, 0)};
|
|
1674
1707
|
out.species_names = dataset.species_names();
|
|
1708
|
+
withhold_unimputed(out);
|
|
1675
1709
|
}
|
|
1676
1710
|
}
|
|
1677
1711
|
if (options.gap_fitting) {
|
|
@@ -243,6 +243,9 @@ struct GapFitReport {
|
|
|
243
243
|
GapScale scale = GapScale::Linear;
|
|
244
244
|
int64_t n_complete = 0;
|
|
245
245
|
int64_t n_gaps = 0;
|
|
246
|
+
// Plots lacking the value whose raw prediction is not finite (a plot the
|
|
247
|
+
// model did not impute): neither a gap nor a complete plot.
|
|
248
|
+
int64_t n_not_imputed = 0;
|
|
246
249
|
// Why nothing was chosen (fewer than two complete plots), empty otherwise.
|
|
247
250
|
std::string skipped;
|
|
248
251
|
std::vector<GapAxisSummary> axes;
|
|
@@ -254,6 +257,9 @@ struct GapFitReport {
|
|
|
254
257
|
// The method code a complete plot carries in GapFit::method: it keeps its
|
|
255
258
|
// recorded value.
|
|
256
259
|
inline constexpr int64_t kGapRecorded = -1;
|
|
260
|
+
// The method code of a plot lacking the value whose raw prediction is not
|
|
261
|
+
// finite: it has no fitted value.
|
|
262
|
+
inline constexpr int64_t kGapNotImputed = -2;
|
|
257
263
|
|
|
258
264
|
// The plots that record a value: (n,) bool, true where every value of the
|
|
259
265
|
// plot's row of `recorded` ((n,), or (n, 2) latitude / longitude) is finite.
|
|
@@ -262,16 +268,19 @@ inline constexpr int64_t kGapRecorded = -1;
|
|
|
262
268
|
|
|
263
269
|
struct GapFit {
|
|
264
270
|
// Per plot in the target's units, like the raw prediction: (n,) float64,
|
|
265
|
-
// or (n, 2) latitude / longitude for a position. A
|
|
266
|
-
//
|
|
271
|
+
// or (n, 2) latitude / longitude for a position. A plot recording the
|
|
272
|
+
// value carries it, a gap the chosen method's value, a plot that is not
|
|
273
|
+
// imputed NaN.
|
|
267
274
|
torch::Tensor fitted;
|
|
268
|
-
// (n,) int64: kGapRecorded for a
|
|
275
|
+
// (n,) int64: kGapRecorded for a plot recording the value, kGapNotImputed
|
|
276
|
+
// for one lacking it without a raw prediction, the GapMethod (as its
|
|
269
277
|
// integer) that predicted each gap otherwise.
|
|
270
278
|
torch::Tensor method;
|
|
271
279
|
GapFitReport report;
|
|
272
280
|
};
|
|
273
281
|
|
|
274
|
-
// "recorded" for kGapRecorded,
|
|
282
|
+
// "recorded" for kGapRecorded, "not_imputed" for kGapNotImputed, the
|
|
283
|
+
// GapMethod's name otherwise.
|
|
275
284
|
[[nodiscard]] std::string gap_method_label(int64_t code);
|
|
276
285
|
|
|
277
286
|
// The report as JSON, every number locale-free (number_text.hpp).
|
|
@@ -281,10 +290,14 @@ struct GapFit {
|
|
|
281
290
|
// the dataset's value per plot, both in the target's units: (n,) for a linear,
|
|
282
291
|
// log or circular scale, (n, 2) latitude / longitude in degrees for a
|
|
283
292
|
// geographic one. A plot whose recorded value is NaN (either coordinate of a
|
|
284
|
-
// position) is a gap, every other plot a complete one.
|
|
293
|
+
// position) is a gap, every other plot a complete one. A plot whose raw
|
|
294
|
+
// prediction is not finite (either coordinate of a position) was not imputed:
|
|
295
|
+
// it is neither a gap nor a complete plot, so no method reads it and it keeps
|
|
296
|
+
// its recorded value, or NaN with kGapNotImputed.
|
|
285
297
|
//
|
|
286
298
|
// `folds`, when given, replaces the matched layout: (n_complete,) int64, the
|
|
287
|
-
// fold of each complete plot
|
|
299
|
+
// fold of each complete plot (recorded value and raw prediction finite) in
|
|
300
|
+
// plot order, numbered from 0 with every fold
|
|
288
301
|
// from 0 to its largest number holding a plot, so a run reproduces another
|
|
289
302
|
// implementation's layout.
|
|
290
303
|
//
|
|
@@ -54,6 +54,12 @@
|
|
|
54
54
|
// no spread, so every dispersion of a one-member target is NaN; the share of
|
|
55
55
|
// members naming the winning class is then 1.
|
|
56
56
|
//
|
|
57
|
+
// A plot none of whose species the target's vocabulary recognises (or with no
|
|
58
|
+
// species at all) is not imputed: every member was trained on plots holding
|
|
59
|
+
// species it knows, so its output for such a plot reads an input it never saw.
|
|
60
|
+
// The target reports the plot as not imputed (SuiteTargetPrediction::imputed)
|
|
61
|
+
// and leaves every per-plot output undefined there.
|
|
62
|
+
//
|
|
57
63
|
// Each combine rule is one SuiteCombineRule (combine_rule): what it reads,
|
|
58
64
|
// how it combines, and the columns its prediction is written as. The manifest
|
|
59
65
|
// validation, the predictor, suite_prediction_columns and the CLI usage text
|
|
@@ -65,6 +71,7 @@
|
|
|
65
71
|
#include "resolve/json.hpp"
|
|
66
72
|
#include "resolve/predictor.hpp"
|
|
67
73
|
#include "resolve/row_source.hpp"
|
|
74
|
+
#include "resolve/target_labels.hpp"
|
|
68
75
|
#include "resolve/terrain_correction.hpp"
|
|
69
76
|
#include "resolve/terrain_source.hpp"
|
|
70
77
|
#include "resolve/types.hpp"
|
|
@@ -425,6 +432,12 @@ struct SuiteTargetPrediction {
|
|
|
425
432
|
// Recognition of each plot by the target's vocabulary, after the names
|
|
426
433
|
// were resolved.
|
|
427
434
|
SpeciesRecognition recognition;
|
|
435
|
+
// (n_plots,) bool: true where the target's vocabulary recognises at least
|
|
436
|
+
// one of the plot's species. Where it is false the plot is not imputed:
|
|
437
|
+
// `value`, `agreement`, `probabilities`, `dispersion`, `members`, the gap
|
|
438
|
+
// fit's value and the terrain-corrected value are NaN there, a class code
|
|
439
|
+
// kUnlabelledClass (-1) and its label empty.
|
|
440
|
+
torch::Tensor imputed;
|
|
428
441
|
// With SuitePredictOptions::names: the names the target's vocabulary read
|
|
429
442
|
// as another token or left unresolved.
|
|
430
443
|
SpeciesNameReport species_names;
|
|
@@ -563,8 +576,9 @@ struct SuiteColumn {
|
|
|
563
576
|
// the prediction (for a classification rule `<t>` the class label, `<t>_code`
|
|
564
577
|
// and `<t>_agreement`, with `probabilities` `<t>_prob_<label>` per class; for
|
|
565
578
|
// a spherical mean `<t>_latitude` and `<t>_longitude`), its dispersion
|
|
566
|
-
// (`<t>_sd`, `<t>_circular_sd`, `<t>_spread_km`), `<t>
|
|
567
|
-
// `<t>
|
|
579
|
+
// (`<t>_sd`, `<t>_circular_sd`, `<t>_spread_km`), `<t>_imputed`,
|
|
580
|
+
// `<t>_n_species`, `<t>_n_recognised`, `<t>_recognised_share`,
|
|
581
|
+
// `<t>_recognised_abundance_share`,
|
|
568
582
|
// and with kept members `<t>_seed<N>` per member (a label for a vote,
|
|
569
583
|
// `_latitude` / `_longitude` for a spherical mean). A gap-fitted target adds
|
|
570
584
|
// `<t>_fitted` (`<t>_fitted_latitude` / `<t>_fitted_longitude`) and
|
|
@@ -574,8 +588,9 @@ struct SuiteColumn {
|
|
|
574
588
|
// terrain-corrected target
|
|
575
589
|
// `<t>_terrain`, `<t>_terrain_w_resolve`, `<t>_terrain_w_dem`,
|
|
576
590
|
// `<t>_terrain_w_dem_1km`, `<t>_dem` and `<t>_dem_1km` after those. A class code is labelled
|
|
577
|
-
// by class_label
|
|
578
|
-
//
|
|
591
|
+
// by class_label, and kUnlabelledClass (a plot not imputed) by an empty text
|
|
592
|
+
// cell, which every binding reads as missing. The CLI writes this table, and
|
|
593
|
+
// the Python and R data frames are built from it.
|
|
579
594
|
[[nodiscard]] std::vector<SuiteColumn> suite_prediction_columns(const SuitePredictions& predictions,
|
|
580
595
|
bool probabilities);
|
|
581
596
|
|
|
@@ -16,7 +16,7 @@ namespace resolve {
|
|
|
16
16
|
// Version and constants
|
|
17
17
|
// =============================================================================
|
|
18
18
|
|
|
19
|
-
inline constexpr const char* VERSION = "1.
|
|
19
|
+
inline constexpr const char* VERSION = "1.3.0";
|
|
20
20
|
|
|
21
21
|
// Training defaults
|
|
22
22
|
constexpr int kDefaultBatchSize = 4096;
|
|
@@ -6,7 +6,7 @@ build-backend = "scikit_build_core.build"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "resolve-core"
|
|
9
|
-
version = "1.
|
|
9
|
+
version = "1.3.0"
|
|
10
10
|
description = "RESOLVE C++ engine: predict sample outcomes from compositional data via learned representations"
|
|
11
11
|
readme = "python/README.md"
|
|
12
12
|
license = {text = "MIT"}
|
|
@@ -397,6 +397,10 @@ void register_suite(nb::module_& m) {
|
|
|
397
397
|
.def_prop_ro("dispersion", [](const SuiteTargetPrediction& t) { return tensor_or_none(t.dispersion); })
|
|
398
398
|
.def_prop_ro("members", [](const SuiteTargetPrediction& t) { return tensor_or_none(t.members); })
|
|
399
399
|
.def_ro("recognition", &SuiteTargetPrediction::recognition)
|
|
400
|
+
.def_prop_ro("imputed", [](const SuiteTargetPrediction& t) { return tensor_or_none(t.imputed); },
|
|
401
|
+
"(n_plots,) bool, True where the target's vocabulary recognises at least one of "
|
|
402
|
+
"the plot's species. Where it is False the plot is not imputed: every value is "
|
|
403
|
+
"NaN there, a class code -1.")
|
|
400
404
|
.def_prop_ro("recorded", [](const SuiteTargetPrediction& t) { return tensor_or_none(t.recorded); },
|
|
401
405
|
"For a target columns['recorded'] names: (n_plots,) bool, True where the plot "
|
|
402
406
|
"records a value, so `value` is imputed where it is False; None otherwise.")
|
|
@@ -252,7 +252,9 @@ def to_pandas(self, probabilities=False):
|
|
|
252
252
|
``<target>_prob_<class>``; for a spherical mean ``<target>_latitude`` and
|
|
253
253
|
``<target>_longitude``), its dispersion (``<target>_sd`` for a mean,
|
|
254
254
|
``<target>_circular_sd`` for a bearing, ``<target>_spread_km`` for a
|
|
255
|
-
spherical mean),
|
|
255
|
+
spherical mean), ``<target>_imputed`` (bool, False where none of the
|
|
256
|
+
plot's species is recognised, so every value of the plot is missing), the
|
|
257
|
+
four recognition columns, and ``<target>_seed<N>``
|
|
256
258
|
per member when the members were kept (``<target>_seed<N>_latitude`` and
|
|
257
259
|
``_longitude`` for a spherical mean); a gap-fitted target adds
|
|
258
260
|
``<target>_fitted`` (``_fitted_latitude`` / ``_fitted_longitude``) and
|
|
@@ -265,9 +267,10 @@ def to_pandas(self, probabilities=False):
|
|
|
265
267
|
"""
|
|
266
268
|
import pandas as pd
|
|
267
269
|
|
|
270
|
+
# An empty text cell is a class label of a plot that was not imputed.
|
|
268
271
|
return pd.DataFrame(
|
|
269
272
|
{
|
|
270
|
-
name: values if isinstance(values, list) else values.numpy()
|
|
273
|
+
name: [v if v != "" else None for v in values] if isinstance(values, list) else values.numpy()
|
|
271
274
|
for name, values in _core.suite_prediction_columns(self, probabilities)
|
|
272
275
|
}
|
|
273
276
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|