pub trait ModelLoad: Sized {
// Required methods
fn load(path: &str) -> Result<Self, Error>;
fn from_serialized(model: SerializedModel) -> Result<Self, Error>;
fn model_type() -> ModelType;
}Expand description
Trait for loading models from disk.
This trait is implemented by all regression result types that support deserialization. Loading validates the format version and model type.
§Example
ⓘ
let model: RegressionOutput = RegressionOutput::load("my_model.json").unwrap();
println!("R²: {}", model.r_squared);Required Methods§
Sourcefn from_serialized(model: SerializedModel) -> Result<Self, Error>
fn from_serialized(model: SerializedModel) -> Result<Self, Error>
Sourcefn model_type() -> ModelType
fn model_type() -> ModelType
Get the model type identifier.
This is used to validate that the loaded file contains the correct model type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.