instancespace.model
Data about the output of running InstanceSpace.
A Model file's signature could not be verified, or its presence is invalid.
Covers a mismatched signature, a missing signature when secret_key was
given, and a present signature when secret_key was not given (the
downgrade-attack case - see Model.load()).
The output of running InstanceSpace.
Initialize a Model object from the output of an InstanceSpace StageRunner.
Parameters
- cls (type[T]): The class.
- stage_runner_output (dict[str, Any]): The output of the StageRunner for an InstanceSpace.
- options (InstanceSpaceOptions): The options that built the instance space.
Returns
- Model: The Model object.
Serialise this Model to path via joblib, mirroring MATLAB's persistence.
Trained scikit-learn/shapely objects (PYTHIA's classifiers, TRACE's footprint polygons) round-trip natively - no flattening step.
If secret_key is given, an HMAC-SHA256 signature of the serialised
bytes is written alongside the model at <path>.sig, and load()
will refuse to deserialise unless the same key verifies it. If
secret_key is None (the default - the local/desktop-development
case with no server-managed secret), no signature is written and
load() performs no verification, the same trust caveat any other
unsigned pickle/joblib file already carries.
On the production web platform, every server code path that calls
load() must always supply secret_key and must never accept a
user-supplied path - that invariant lives in the deployment, not
in this method.
Deserialise a Model previously written by save().
Four cases, matching save()'s two modes:
secret_keygiven, signature present: verified before deserialising - raisesModelSignatureErroron mismatch.secret_keygiven, signature absent: raises - a caller expecting a verified load must never silently fall through to an unverified one.secret_keyisNone, signature absent: deserialises directly (the desktop/dev path).secret_keyisNone, signature present: raises. This is the downgrade-attack guard - a signed file must not become loadable-unverified just because the caller omitted the key.
Save csv outputs to a directory.
Save csv outputs used for the web frontend to a directory.
Save instance-space plots as PNG files in the output directory.
Save the algorithm-label-only MAT compatibility file for the dashboard.
Use save() for complete model persistence, including PILOT's
numeric projection and optimized viewpoint.