API Reference
- Base URL
- Authentication
- Endpoint Index
- Correlations
- Feature Importance
- Spatial HITL
- Common Concepts
- GET /api/spatial-hitl/task/{data_collection_name}/dataset-columns
- POST /api/spatial-hitl/task/{data_collection_name}/audit
- POST /api/spatial-hitl/task/{data_collection_name}/mitigate/relabel
- POST /api/spatial-hitl/task/{data_collection_name}/mitigate/threshold
- POST /api/spatial-hitl/task/{data_collection_name}/mitigate/writeback
- Dave Tasks
- See Also
This page documents the REST API exposed by the Data Valuation Engine backend.
Base URL
The frontend calls the backend using VITE_API_BASE_URL (see Configuration).
For local development this is typically:
Authentication
Authentication depends on your deployment:
-
If
VITE_USE_KEYCLOAK=false, the API is typically used without Keycloak authentication in local/demo setups. -
If
VITE_USE_KEYCLOAK=true, the frontend obtains a Keycloak access token and calls the API with a Bearer token.
Endpoint Index
| Endpoint | Description |
|---|---|
POST |
Analyze feature correlations (Pearson / Spearman / Kendall) |
POST |
Analyze feature importance (model ranking + SHAP) |
GET |
HITL: inspect dataset columns for a saved task |
POST |
HITL: run audit for a task |
POST |
HITL: run relabeling mitigation for a task |
POST |
HITL: run threshold mitigation for a task |
POST |
HITL: write back mitigated predictions |
GET |
List configuration documents (tasks) |
GET |
Get a configuration document by id |
PATCH |
Update a configuration document (e.g., status) |
DELETE |
Delete a configuration document |
Correlations
POST /api/correlations/analyze?dataset-id="<dataset-id>"
Analyzes feature correlations for the specified dataset and returns the data required to plot correlation matrix(es).
Request body
Use the following JSON fields to select which correlation methods to compute. You may enable either one or both.
{
"include_pearson": true,
"include_spearman": true,
"include_kendall": true
}
Example
Perform a POST request to the endpoint below with the following JSON body.
POST /api/correlations/analyze?dataset-id="abc123"
Content-Type: application/json
{
"include_pearson": true,
"include_spearman": true
}
Response (200)
The response includes the dataset shape and feature count, plus one or both correlation matrices depending on the request.
dataset_shape is a two-element array [rows, columns].
feature_count is the number of features (columns) included in the correlation computation.
pearson and spearman contain square matrices represented as nested JSON objects:
each top-level key is a column name, and its value maps every column name to a correlation coefficient.
{
"dataset_shape": [569, 31],
"feature_count": 31,
"pearson": {
"column-name-1": {
"column-name-1": 1.0,
"column-name-2": 0.3,
...
"column-name-n": 0.5
}
},
"spearman": {
"column-name-1": {
"column-name-1": 1.0,
"column-name-2": 0.1,
...
"column-name-n": 0.35
}
}
}
Feature Importance
POST /api/feature-importance/analyze?dataset-id="<dataset-id>"
Computes feature importance for the specified dataset and returns a ranked list of features, along with the evaluated models and their accuracy scores.
Request body
This endpoint accepts an optional list of model names to restrict which models are evaluated. If omitted or empty, the service evaluates the default set of supported models. The available models are: "Extra Trees Classifier", "Light Gradient Boosting Machine", "Random Forest Classifier", and "Decision Tree Classifier".
{
"model_names": [
"Extra Trees Classifier",
"Light Gradient Boosting Machine",
"Random Forest Classifier",
"Decision Tree Classifier"
]
}
Example
Perform a POST request to the endpoint below.
POST /api/feature-importance/analyze?dataset-id="abc123"
Content-Type: application/json
Response (200)
The response includes the dataset shape, the best-performing model, the list of evaluated models with their accuracy scores, and the ranked feature importance output.
dataset_shape is a two-element array [rows, columns].
model_names contains the names of the evaluated models, in the same order as accuracy_scores.
accuracy_scores contains the accuracy score for each model, aligned by index with model_names.
best_model is the name of the model selected as best for the run.
feature_importance is an ordered list of objects where:
Feature is the feature name and Importance is its importance score. Higher values indicate more influential features.
{
"feature_importance": [
{ "Feature": "worst radius", "Importance": 0.0581 },
{ "Feature": "worst perimeter", "Importance": 0.0536 },
{ "Feature": "worst concave points", "Importance": 0.0466 }
],
"model_names": [
"Extra Trees Classifier",
"Light Gradient Boosting Machine",
"Random Forest Classifier",
"Decision Tree Classifier"
],
"accuracy_scores": [0.9698, 0.968, 0.9627, 0.9254],
"best_model": "Extra Trees Classifier",
"dataset_shape": [569, 31]
}
Spatial HITL
The HITL endpoints operate on a persisted configuration/task identified by data_collection_name.
These endpoints load data from the configured MongoDB collection, build the required payload internally, and then apply the requested module.
Common Concepts
-
data_collection_name: A string referring to a stored collection name.
-
Field Mapping: Allows the user to map expected field names (lat/lon/y_pred/etc.) to the actual column names in the dataset collection. If not provided, defaults are used:
{
"lat": "lat",
"lon": "lon",
"y_true": "y_true",
"y_pred": "y_pred",
"region_ids": "region_ids",
"y_pred_prob": "y_pred_prob"
}
-
Region Polygons (optional): Can be provided to support visualization and/or region-based computation.
[
{
"polygon": [
[23.70, 37.99],
[23.70, 37.97],
[23.74, 37.97],
[23.74, 37.99]
]
}
]
Polygons are validated as a list of points with bounds checking. Each point is treated as [lon, lat].
|
GET /api/spatial-hitl/task/{data_collection_name}/dataset-columns
Returns the dataset columns available for mapping. The service samples up to ~200 documents to infer available fields.
POST /api/spatial-hitl/task/{data_collection_name}/audit
Runs a spatial bias audit using dataset columns and optional field mapping.
Request body
| Field | Meaning |
|---|---|
n_worlds |
Monte Carlo samples ("alternate worlds"). Default: |
signif_level |
Significance level (0,1). Default: |
equal_opp |
If |
full_distribution |
If 'true', displays all instances in maps, else up to 10000 sample, Default: 'false'. |
region |
Optional region polygons (see above). |
mapping |
Optional field mapping (see above). |
Example
POST /api/spatial-hitl/task/example_collection_name/audit
Content-Type: application/json
{
"n_worlds": 1000,
"signif_level": 0.005,
"equal_opp": true,
"full_distribution": false,
"region": [
{ "polygon": [[23.70, 37.99], [23.70, 37.97], [23.74, 37.97], [23.74, 37.99]] }
],
"mapping": {
"lat": "lat",
"lon": "lon",
"y_true": "y_true",
"y_pred": "y_pred",
"region_ids": "region_ids"
}
}
POST /api/spatial-hitl/task/{data_collection_name}/mitigate/relabel
Runs mitigation via relabeling (prediction flips) on the task dataset.
Request body
Includes audit parameters plus mitigation controls:
| Field | Meaning |
|---|---|
n_worlds |
Monte Carlo samples ("alternate worlds"). Default: |
signif_level |
Significance level (0,1). Default: |
equal_opp |
If |
full_distribution |
If 'true', displays all instances in maps, else up to 10000 sample, Default: 'false'. |
region |
Optional region polygons (see above). |
mapping |
Optional field mapping (see above). |
approx |
Whether to use an approximate solver. Default: |
budget_constr |
Maximum flip budget in |
pr_constr |
Allowed positive-rate change tolerance in |
work_limit |
Work limit (approx runtime control). Default: |
Example
POST /api/spatial-hitl/task/example_collection_name/mitigate/relabel
Content-Type: application/json
{
"n_worlds": 1000,
"signif_level": 0.005,
"equal_opp": true,
"full_distribution": false,
"region": [
{ "polygon": [[23.70, 37.99], [23.70, 37.97], [23.74, 37.97], [23.74, 37.99]] }
],
"mapping": {
"lat": "lat",
"lon": "lon",
"y_true": "y_true",
"y_pred": "y_pred",
"region_ids": "region_ids"
},
"approx": true,
"budget_constr": 0.2,
"pr_constr": 0.1,
"work_limit": 30
}
Response (200)
-
metrics_before,metrics_after: performance + fairness metrics -
audit_before_mitigation,audit_after_mitigation: audit payloads (maps + stats) -
mitigated_preds: final predictions -
flips_map_html/flips_map_image: visualization of flips -
solver_status_code,solver_status_message: optimization status
POST /api/spatial-hitl/task/{data_collection_name}/mitigate/threshold
Runs mitigation via per-region decision thresholds.
This endpoint:
1. loads the task dataset,
2. validates required columns (including probabilities),
3. performs an internal train/test split using train_ratio (+ optional stratification),
4. fits thresholds on the train subset and applies them to the test subset.
Request body
| Field | Meaning |
|---|---|
n_worlds |
Monte Carlo samples ("alternate worlds"). Default: |
signif_level |
Significance level (0,1). Default: |
equal_opp |
If |
full_distribution |
If 'true', displays all instances in maps, else up to 10000 sample, Default: 'false'. |
region |
Optional polygons for visualization / region-based computations (used as |
mapping |
Optional field mapping. |
approx |
Whether to use an approximate solver. Default: |
budget_constr |
Maximum flip budget in |
pr_constr |
Allowed positive-rate change tolerance in |
default_boundary |
Base model threshold (e.g., |
train_ratio |
Fraction of rows used for training thresholds. Default: |
stratified |
If |
random_state |
Seed for reproducible split. Default: |
Example
POST /api/spatial-hitl/task/example_collection_name/mitigate/threshold
Content-Type: application/json
{
"n_worlds": 1000,
"signif_level": 0.005,
"equal_opp": true,
"full_distribution": false,
"region": [
{ "polygon": [[23.70, 37.99], [23.70, 37.97], [23.74, 37.97], [23.74, 37.99]] }
],
"mapping": {
"lat": "lat",
"lon": "lon",
"y_true": "y_true",
"y_pred": "y_pred",
"region_ids": "region_ids",
"y_pred_prob": "y_pred_prob"
},
"approx": true,
"budget_constr": 0.2,
"pr_constr": 0.1,
"work_limit": 30,
"default_boundary": 0.5,
"train_ratio": 0.7,
"stratified": true,
"random_state": 42
}
Response (200)
-
metrics_before,metrics_after: performance + fairness metrics -
audit_before_mitigation,audit_after_mitigation: audit payloads (maps + stats) -
mitigated_preds: final predictions -
flips_map_html/flips_map_image: visualization of flips -
solver_status_code,solver_status_message: optimization status -
threshold_chart_before,threshold_chart_after: threshold plots (encoded) -
new_thresholds: per-region thresholds (and tie-breaking values if applicable)
POST /api/spatial-hitl/task/{data_collection_name}/mitigate/writeback
Writes mitigated predictions back to the dataset collection by setting a new field for each record.
Field name must match the pattern: ^[A-Za-z_][A-Za-z0-9_]*$.
Request body
{
"new_field": "mitigated_prediction",
"preds": [
{ "doc_id": "abc123", "y_pred": 0 },
{ "doc_id": "def456", "y_pred": 1 }
]
}
Example
POST /api/spatial-hitl/task/example_collection_name/mitigate/writeback
Content-Type: application/json
{
"new_field": "mitigated_prediction",
"preds": [
{ "doc_id": "65a1b2c3d4e5f67890123456", "y_pred": 0 },
{ "doc_id": "65a1b2c3d4e5f67890123457", "y_pred": 1 }
]
}
Dave Tasks
Dave task endpoints manage configuration documents that represent pipeline/task executions and their metadata.
These endpoints require MongoDB to be enabled (USE_MONGO=true).
|
GET /api/dave/documents
List configuration documents, optionally filtering by status and/or component.
Query parameters
| Parameter | Meaning |
|---|---|
status |
Optional status filter. |
component |
Optional component filter. |
Response (200)
Returns a list of configuration documents:
| Field | Meaning |
|---|---|
pipeline_name |
Pipeline name |
database_name |
Mongo database storing the collection |
data_collection_name |
Mongo collection containing the dataset |
status |
Human-in-the-loop status (e.g., |
component |
Component id |
started_at, ended_at |
Execution timestamps (ISO8601) |
PATCH /api/dave/document/{collection_name}
Update a configuration document (currently supports updating status).
If status is set to done, the service also sets ended_at to the current UTC time.