Skip to main content
A Validation element takes the parameters produced earlier in the pipeline, simulates the experiments listed in objectives, and compares those simulations to the measured data. It is how you check whether a fit generalises beyond the data it was fit on.

A minimal validation

import ionworks_schema as iws
from ionworks import Ionworks

known = iws.direct_entries.DirectEntry(
    parameters={"Ambient temperature [K]": 298.15},
)

# Held-out experiment(s) to validate against
val = iws.Validation(
    objectives={
        "0.5C": iws.objectives.CurrentDriven(
            data_input="file:examples/data/chen_synthetic_0.5C/time_series.csv",
            options={"model": {"type": "SPMe"}},
        ),
    },
    summary_stats=[iws.costs.RMSE(), iws.costs.MAE(), iws.costs.Max()],
)

pipeline = iws.Pipeline({"known": known, "validate": val})

client = Ionworks()
submission = client.pipeline.create(pipeline)
client.pipeline.wait_for_completion(submission.id)
If summary_stats is omitted, sensible defaults are filled in so the report carries the same physical units as the measurements.

Retrieving validation output

element_results holds the per-objective summary statistics:
result = client.pipeline.result(submission.id)
print(result.element_results["validate"]["summary_stats"])
The full per-point comparison (time-series traces, plot configs) is persisted separately and fetched with get_element_metadata:
metadata = client.pipeline.get_element_metadata(submission.id, "validate")
The element name ("validate" above) is whatever key you used in the pipeline’s elements dict — a pipeline can run several validation elements under names like "validate_pristine" and "validate_aged".

Validating after a fit

The common pattern is to run the fit and the validation in the same pipeline so they share parameters automatically:
pipeline = iws.Pipeline(
    {
        "known": known,
        "fit": fit,           # iws.DataFit, see /pipelines/data-fitting/overview
        "validate": val,
    },
)
The validation step receives the best-fit parameters from fit and runs the held-out experiments against them.

Pipelines overview

How validation chains with direct entries, calculations, and data fits.

Data Fitting overview

Producing the parameters that validation then checks.