resolve-core 1.2.0__tar.gz → 1.4.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.4.0}/PKG-INFO +1 -1
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/gap_fitting.cpp +28 -6
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/resolve_capi.cpp +7 -1
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/suite.cpp +37 -8
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/gap_fitting.hpp +19 -6
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/resolve_capi.h +3 -1
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/suite.hpp +27 -6
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/types.hpp +1 -1
- {resolve_core-1.2.0 → resolve_core-1.4.0}/pyproject.toml +1 -1
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings.cpp +1 -1
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_suite.cpp +6 -2
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/resolve_core/_suite.py +15 -10
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/adapter.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/categorical.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/checkpoint.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/continuous_block.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/dataset.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/encoder_common.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/excelformer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/fine_tune.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/ft_transformer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/fuzzy_automaton.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/fuzzy_index.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/fuzzy_internal.h +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/fuzzy_search.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/geo.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/gnn.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/gpu.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/hetero_gnn.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/json.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/loss.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/lr_schedule.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/model.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/name_resolution.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/plot_columns.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/plot_encoder_embed.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/plot_encoder_hash.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/plot_encoder_rank_pool.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/plot_encoder_sparse.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/plot_encoder_transformer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/plot_neighbours.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/predictor.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/pretraining.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/process.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/retrieval.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/saint.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/selection_metric.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/sha256.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/sparse_rows.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/species_encoder.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/species_encoding.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/species_graph.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/species_pool.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/suite_derive.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/tabm.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/tabnet.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/target_labels.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/task_head.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/tensor_pack.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/terrain_codec.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/terrain_correction.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/terrain_field.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/terrain_source.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/trainer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/trainer_checkpoint.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/traitnet.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cpp_src/vae.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cuda/feature_hash.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cuda/kernels.cu +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/cuda/launch_common.cuh +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/adapter.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/aggregate_arity.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/architectures.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/aux_loss.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/categorical.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/checkpoint.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/checkpoint_schema_keys.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/config_json.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/config_registry.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/continuous_block.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/csv_reader.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/csv_utils.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/cuda/feature_hash.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/cuda/hash_kernels.h +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/dataset.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/encoder.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/enum_names.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/env.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/excelformer.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/experts.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/fine_tune.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/ft_transformer.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/fuzzy.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/geo.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/gnn.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/gpu.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/grad_clip.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/hash_core.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/hetero_gnn.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/io_retry.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/json.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/ln_mlp.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/loss.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/lr_schedule.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/lru_cache.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/mlp_block.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/model.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/name_pool.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/name_resolution.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/number_text.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/plot_columns.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/plot_encoder_embed.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/plot_encoder_hash.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/plot_encoder_rank_pool.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/plot_encoder_sparse.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/plot_encoder_transformer.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/plot_inputs.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/plot_neighbours.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/predictor.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/pretraining.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/process.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/resolve.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/resolve_capi_symbols.inc +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/retrieval.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/role_mapping.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/row_cells.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/row_source.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/saint.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/scalers.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/selection_metric.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/sha256.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/sparse_rows.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/species_encoder.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/species_encoding.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/species_graph.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/species_pool.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/string_list_archive.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/tabm.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/tabnet.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/target_labels.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/target_transform.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/task_head.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/tensor_pack.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/terrain_codec.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/terrain_correction.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/terrain_field.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/terrain_source.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/trainer.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/traitnet.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/utils.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/include/resolve/vae.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/CMakeLists.txt +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/README.md +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_common.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_dataset.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_enums.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_fine_tune.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_fuzzy.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_gap_fitting.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_metrics.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_model.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_names.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_plot_inputs.hpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_pretraining.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_retrieval.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_terrain.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_trainer.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/bindings_types.cpp +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/resolve_core/__init__.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/resolve_core/_checkpoint.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/resolve_core/_from_pandas.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/resolve_core/_gap_fitting.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/python/src/resolve_core/_names.py +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/resolve_core_sources.cmake +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/resolve_cuda_kernels.cmake +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.0}/resolve_openmp.cmake +0 -0
- {resolve_core-1.2.0 → resolve_core-1.4.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";
|
|
@@ -2537,7 +2537,12 @@ SuitePredictOptions parse_suite_predict_options(const resolve_value* o) {
|
|
|
2537
2537
|
if (vhas(o, "batch_size")) out.batch_size = vnum<int64_t>(o, "batch_size");
|
|
2538
2538
|
if (vhas(o, "keep_members")) out.keep_members = vbool(o, "keep_members");
|
|
2539
2539
|
if (vhas(o, "gap_fitting")) {
|
|
2540
|
-
|
|
2540
|
+
const resolve_value* gaps = vget(o, "gap_fitting");
|
|
2541
|
+
if (gaps->kind == RESOLVE_VALUE_BOOL) {
|
|
2542
|
+
if (!gaps->b) out.gap_fitting.reset();
|
|
2543
|
+
} else {
|
|
2544
|
+
out.gap_fitting = parse_config<GapFittingConfig>(gaps, "gap_fitting");
|
|
2545
|
+
}
|
|
2541
2546
|
}
|
|
2542
2547
|
if (vhas(o, "terrain")) out.terrain = parse_terrain_options(vget(o, "terrain"));
|
|
2543
2548
|
const resolve_value* c = vget(o, "columns");
|
|
@@ -2616,6 +2621,7 @@ resolve_value* suite_predictions_to_value(const SuitePredictions& p) {
|
|
|
2616
2621
|
v_put(m, "recognised_share", defined_or_null(t.recognition.count_share, RESOLVE_VALUE_DOUBLE_ARRAY));
|
|
2617
2622
|
v_put(m, "recognised_abundance_share",
|
|
2618
2623
|
defined_or_null(t.recognition.abundance_share, RESOLVE_VALUE_DOUBLE_ARRAY));
|
|
2624
|
+
v_put(m, "imputed", t.imputed.defined() ? tensor_to_ivec(t.imputed) : v_null());
|
|
2619
2625
|
v_put(m, "recorded", t.recorded.defined() ? tensor_to_ivec(t.recorded) : v_null());
|
|
2620
2626
|
v_put(m, "gap_fit", t.gap_fit ? gap_fit_to_value(*t.gap_fit) : v_null());
|
|
2621
2627
|
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) {
|
|
@@ -1595,7 +1628,7 @@ SuitePredictions SuitePredictor::predict(const SuiteInput& input,
|
|
|
1595
1628
|
"suite '" + manifest_.name + "' reads plot-level columns (coordinates or "
|
|
1596
1629
|
"covariates), so a header table is required");
|
|
1597
1630
|
}
|
|
1598
|
-
const RoleMapping roles = roles_for(options.columns, options.
|
|
1631
|
+
const RoleMapping roles = roles_for(options.columns, options.fits_gaps());
|
|
1599
1632
|
|
|
1600
1633
|
SuitePredictions result;
|
|
1601
1634
|
result.targets.resize(targets_.size());
|
|
@@ -1672,9 +1705,10 @@ 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
|
-
if (options.
|
|
1711
|
+
if (options.fits_gaps()) {
|
|
1678
1712
|
fit_gaps(input, options.columns, *options.gap_fitting, result);
|
|
1679
1713
|
} else if (!options.columns.recorded.empty()) {
|
|
1680
1714
|
mark_recorded(input, options.columns, result);
|
|
@@ -1732,11 +1766,6 @@ void SuitePredictor::mark_recorded(const SuiteInput& input, const SuiteColumns&
|
|
|
1732
1766
|
void SuitePredictor::fit_gaps(const SuiteInput& input, const SuiteColumns& columns,
|
|
1733
1767
|
const GapFittingConfig& config, SuitePredictions& result) const {
|
|
1734
1768
|
config.validate();
|
|
1735
|
-
if (columns.recorded.empty()) {
|
|
1736
|
-
throw std::invalid_argument(
|
|
1737
|
-
"gap fitting: name the column holding each fitted target's recorded value "
|
|
1738
|
-
"(SuiteColumns::recorded)");
|
|
1739
|
-
}
|
|
1740
1769
|
const std::vector<std::size_t> indices = recorded_targets(columns);
|
|
1741
1770
|
const SuiteInputContract& in = manifest_.inputs;
|
|
1742
1771
|
GapColumns gap_columns;
|
|
@@ -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
|
//
|
|
@@ -603,7 +603,9 @@ RESOLVE_CAPI resolve_value_t* resolve_suite_get(const resolve_suite_t* s, const
|
|
|
603
603
|
* gap_fitting MAP a GapFittingConfig (candidates, k_grid, spatial,
|
|
604
604
|
* matching_seed, n_folds, max_fold_share,
|
|
605
605
|
* matching_sample; an empty MAP for the defaults): fit
|
|
606
|
-
* every target columns.recorded names
|
|
606
|
+
* every target columns.recorded names. Fitted with
|
|
607
|
+
* the defaults when the key is absent; BOOL false
|
|
608
|
+
* fits nothing and only marks the recorded plots
|
|
607
609
|
* names MAP resolve the species names against each target's
|
|
608
610
|
* vocabulary first, as resolve_dataset_load's names
|
|
609
611
|
* terrain MAP correct every target the manifest gives a terrain
|
|
@@ -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"
|
|
@@ -377,8 +384,14 @@ struct SuitePredictOptions {
|
|
|
377
384
|
// Keep every member's own prediction in SuiteTargetPrediction::members.
|
|
378
385
|
bool keep_members = false;
|
|
379
386
|
// Gap fitting (gap_fitting.hpp) after combining, for every target
|
|
380
|
-
// columns.recorded names
|
|
381
|
-
|
|
387
|
+
// columns.recorded names: the default wherever a recorded column is
|
|
388
|
+
// named. Unset fits nothing, and the named targets are only marked
|
|
389
|
+
// (SuiteTargetPrediction::recorded).
|
|
390
|
+
std::optional<GapFittingConfig> gap_fitting = GapFittingConfig{};
|
|
391
|
+
|
|
392
|
+
// Whether this call fits gaps: gap fitting is set and a target names its
|
|
393
|
+
// recorded column.
|
|
394
|
+
[[nodiscard]] bool fits_gaps() const { return gap_fitting.has_value() && !columns.recorded.empty(); }
|
|
382
395
|
// Resolve the species names against each target's vocabulary before
|
|
383
396
|
// encoding (name_resolution.hpp): the release's name table and the edits
|
|
384
397
|
// a misspelling may be away. Unset reads every name as written. Gap
|
|
@@ -425,6 +438,12 @@ struct SuiteTargetPrediction {
|
|
|
425
438
|
// Recognition of each plot by the target's vocabulary, after the names
|
|
426
439
|
// were resolved.
|
|
427
440
|
SpeciesRecognition recognition;
|
|
441
|
+
// (n_plots,) bool: true where the target's vocabulary recognises at least
|
|
442
|
+
// one of the plot's species. Where it is false the plot is not imputed:
|
|
443
|
+
// `value`, `agreement`, `probabilities`, `dispersion`, `members`, the gap
|
|
444
|
+
// fit's value and the terrain-corrected value are NaN there, a class code
|
|
445
|
+
// kUnlabelledClass (-1) and its label empty.
|
|
446
|
+
torch::Tensor imputed;
|
|
428
447
|
// With SuitePredictOptions::names: the names the target's vocabulary read
|
|
429
448
|
// as another token or left unresolved.
|
|
430
449
|
SpeciesNameReport species_names;
|
|
@@ -563,8 +582,9 @@ struct SuiteColumn {
|
|
|
563
582
|
// the prediction (for a classification rule `<t>` the class label, `<t>_code`
|
|
564
583
|
// and `<t>_agreement`, with `probabilities` `<t>_prob_<label>` per class; for
|
|
565
584
|
// a spherical mean `<t>_latitude` and `<t>_longitude`), its dispersion
|
|
566
|
-
// (`<t>_sd`, `<t>_circular_sd`, `<t>_spread_km`), `<t>
|
|
567
|
-
// `<t>
|
|
585
|
+
// (`<t>_sd`, `<t>_circular_sd`, `<t>_spread_km`), `<t>_imputed`,
|
|
586
|
+
// `<t>_n_species`, `<t>_n_recognised`, `<t>_recognised_share`,
|
|
587
|
+
// `<t>_recognised_abundance_share`,
|
|
568
588
|
// and with kept members `<t>_seed<N>` per member (a label for a vote,
|
|
569
589
|
// `_latitude` / `_longitude` for a spherical mean). A gap-fitted target adds
|
|
570
590
|
// `<t>_fitted` (`<t>_fitted_latitude` / `<t>_fitted_longitude`) and
|
|
@@ -574,8 +594,9 @@ struct SuiteColumn {
|
|
|
574
594
|
// terrain-corrected target
|
|
575
595
|
// `<t>_terrain`, `<t>_terrain_w_resolve`, `<t>_terrain_w_dem`,
|
|
576
596
|
// `<t>_terrain_w_dem_1km`, `<t>_dem` and `<t>_dem_1km` after those. A class code is labelled
|
|
577
|
-
// by class_label
|
|
578
|
-
//
|
|
597
|
+
// by class_label, and kUnlabelledClass (a plot not imputed) by an empty text
|
|
598
|
+
// cell, which every binding reads as missing. The CLI writes this table, and
|
|
599
|
+
// the Python and R data frames are built from it.
|
|
579
600
|
[[nodiscard]] std::vector<SuiteColumn> suite_prediction_columns(const SuitePredictions& predictions,
|
|
580
601
|
bool probabilities);
|
|
581
602
|
|
|
@@ -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.4.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.4.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"}
|
|
@@ -38,9 +38,9 @@ NB_MODULE(_resolve_core, m) {
|
|
|
38
38
|
register_metrics(m);
|
|
39
39
|
register_pretraining(m);
|
|
40
40
|
register_fuzzy(m);
|
|
41
|
+
register_gap_fitting(m);
|
|
41
42
|
register_suite(m);
|
|
42
43
|
register_retrieval(m);
|
|
43
|
-
register_gap_fitting(m);
|
|
44
44
|
register_names(m);
|
|
45
45
|
register_terrain(m);
|
|
46
46
|
register_fine_tune(m);
|
|
@@ -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.")
|
|
@@ -493,7 +497,7 @@ void register_suite(nb::module_& m) {
|
|
|
493
497
|
},
|
|
494
498
|
nb::arg("species_path"), nb::arg("header_path") = "",
|
|
495
499
|
nb::arg("columns") = SuiteColumns{}, nb::arg("batch_size") = 4096,
|
|
496
|
-
nb::arg("keep_members") = false, nb::arg("gap_fitting") =
|
|
500
|
+
nb::arg("keep_members") = false, nb::arg("gap_fitting").none() = GapFittingConfig{},
|
|
497
501
|
nb::arg("names") = nb::none(), nb::arg("terrain") = nb::none())
|
|
498
502
|
.def("predict_columns",
|
|
499
503
|
[](SuitePredictor& s, std::vector<std::string> species_names,
|
|
@@ -522,7 +526,7 @@ void register_suite(nb::module_& m) {
|
|
|
522
526
|
nb::arg("species_names"), nb::arg("species_columns"),
|
|
523
527
|
nb::arg("header_names") = nb::none(), nb::arg("header_columns") = nb::none(),
|
|
524
528
|
nb::arg("columns") = SuiteColumns{}, nb::arg("batch_size") = 4096,
|
|
525
|
-
nb::arg("keep_members") = false, nb::arg("gap_fitting") =
|
|
529
|
+
nb::arg("keep_members") = false, nb::arg("gap_fitting").none() = GapFittingConfig{},
|
|
526
530
|
nb::arg("names") = nb::none(), nb::arg("terrain") = nb::none(),
|
|
527
531
|
"Low-level entry point over string columns; SuitePredictor.predict wraps it "
|
|
528
532
|
"for pandas DataFrames.");
|
|
@@ -97,8 +97,8 @@ def _recorded(value):
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
def _gap_fitting(gap_fitting):
|
|
100
|
-
"""A GapFittingConfig from
|
|
101
|
-
fields; None and False fit nothing."""
|
|
100
|
+
"""A GapFittingConfig from True (the defaults), a GapFittingConfig or a
|
|
101
|
+
dict of its fields; None and False fit nothing."""
|
|
102
102
|
if gap_fitting is None or gap_fitting is False:
|
|
103
103
|
return None
|
|
104
104
|
if gap_fitting is True:
|
|
@@ -138,7 +138,7 @@ def predict(
|
|
|
138
138
|
columns=None,
|
|
139
139
|
batch_size=4096,
|
|
140
140
|
keep_members=False,
|
|
141
|
-
gap_fitting=
|
|
141
|
+
gap_fitting=True,
|
|
142
142
|
names=None,
|
|
143
143
|
max_edit_distance=1,
|
|
144
144
|
terrain=None,
|
|
@@ -158,8 +158,9 @@ def predict(
|
|
|
158
158
|
``abundance``, ``genus``, ``family``, ``latitude``, ``longitude``,
|
|
159
159
|
``covariates``, ``categoricals``), ``recorded`` (``{target: column}``,
|
|
160
160
|
``{"location": [lat, lon]}``: the column holding each regression
|
|
161
|
-
target's recorded value,
|
|
162
|
-
|
|
161
|
+
target's recorded value, whose gaps are fitted, or which adds
|
|
162
|
+
``<target>_recorded`` with ``gap_fitting=False``), for gap fitting
|
|
163
|
+
``survey_year``, and for
|
|
163
164
|
terrain correction ``terrain``
|
|
164
165
|
(``{"elevation": col, "elevation_1km": col, "slope": col,
|
|
165
166
|
"slope_1km": col, "uncertainty": col}``).
|
|
@@ -169,9 +170,10 @@ def predict(
|
|
|
169
170
|
Keep every member's own prediction in ``members``.
|
|
170
171
|
gap_fitting : GapFittingConfig or dict or bool, optional
|
|
171
172
|
Fit each target ``columns["recorded"]`` names from the dataset's own
|
|
172
|
-
complete plots (``True
|
|
173
|
-
``candidates``, ``k_grid``, ``spatial``, ``matching_seed``,
|
|
174
|
-
``n_folds``, ``max_fold_share``, ``matching_sample``
|
|
173
|
+
complete plots (``True``, the default, for the default settings; a
|
|
174
|
+
dict sets ``candidates``, ``k_grid``, ``spatial``, ``matching_seed``,
|
|
175
|
+
``n_folds``, ``max_fold_share``, ``matching_sample``; ``False`` or
|
|
176
|
+
``None`` fits nothing). Adds
|
|
175
177
|
``<target>_fitted`` and ``<target>_fit_method`` to ``to_pandas`` and
|
|
176
178
|
a ``gap_fit`` (with its ``report``) to each fitted target.
|
|
177
179
|
names : str or os.PathLike or NameTable or SpeciesNames or bool, optional
|
|
@@ -252,7 +254,9 @@ def to_pandas(self, probabilities=False):
|
|
|
252
254
|
``<target>_prob_<class>``; for a spherical mean ``<target>_latitude`` and
|
|
253
255
|
``<target>_longitude``), its dispersion (``<target>_sd`` for a mean,
|
|
254
256
|
``<target>_circular_sd`` for a bearing, ``<target>_spread_km`` for a
|
|
255
|
-
spherical mean),
|
|
257
|
+
spherical mean), ``<target>_imputed`` (bool, False where none of the
|
|
258
|
+
plot's species is recognised, so every value of the plot is missing), the
|
|
259
|
+
four recognition columns, and ``<target>_seed<N>``
|
|
256
260
|
per member when the members were kept (``<target>_seed<N>_latitude`` and
|
|
257
261
|
``_longitude`` for a spherical mean); a gap-fitted target adds
|
|
258
262
|
``<target>_fitted`` (``_fitted_latitude`` / ``_fitted_longitude``) and
|
|
@@ -265,9 +269,10 @@ def to_pandas(self, probabilities=False):
|
|
|
265
269
|
"""
|
|
266
270
|
import pandas as pd
|
|
267
271
|
|
|
272
|
+
# An empty text cell is a class label of a plot that was not imputed.
|
|
268
273
|
return pd.DataFrame(
|
|
269
274
|
{
|
|
270
|
-
name: values if isinstance(values, list) else values.numpy()
|
|
275
|
+
name: [v if v != "" else None for v in values] if isinstance(values, list) else values.numpy()
|
|
271
276
|
for name, values in _core.suite_prediction_columns(self, probabilities)
|
|
272
277
|
}
|
|
273
278
|
)
|
|
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
|