pub struct AutoModel { /* private fields */ }Expand description
AutoModel: Trained model with full metadata
This is the main user-facing type for trained models. It wraps the
UniversalModel along with all the metadata from the training process.
Implementations§
Source§impl AutoModel
impl AutoModel
Sourcepub fn from_build_result(result: BuildResult) -> Self
pub fn from_build_result(result: BuildResult) -> Self
Create an AutoModel from a BuildResult
Sourcepub fn train_quick(df: &DataFrame, target_col: &str) -> Result<Self>
pub fn train_quick(df: &DataFrame, target_col: &str) -> Result<Self>
Train with quick settings (minimal tuning, fast training)
Sourcepub fn train_thorough(df: &DataFrame, target_col: &str) -> Result<Self>
pub fn train_thorough(df: &DataFrame, target_col: &str) -> Result<Self>
Train with thorough settings (extensive tuning, best accuracy)
Sourcepub fn train_with_mode(
df: &DataFrame,
target_col: &str,
mode: BoostingMode,
) -> Result<Self>
pub fn train_with_mode( df: &DataFrame, target_col: &str, mode: BoostingMode, ) -> Result<Self>
Train with a specific mode (bypass auto-selection)
Sourcepub fn train_with_config(
df: &DataFrame,
target_col: &str,
config: AutoConfig,
) -> Result<Self>
pub fn train_with_config( df: &DataFrame, target_col: &str, config: AutoConfig, ) -> Result<Self>
Train with custom configuration
Sourcepub fn predict(&self, df: &DataFrame) -> Result<Vec<f32>>
pub fn predict(&self, df: &DataFrame) -> Result<Vec<f32>>
Predict on a DataFrame
Returns predictions as a Vec
Sourcepub fn predict_linear_only(&self, df: &DataFrame) -> Result<Vec<f32>>
pub fn predict_linear_only(&self, df: &DataFrame) -> Result<Vec<f32>>
Predict using only the linear component (LinearThenTree mode only)
For fair comparison between linear-only and full LinearThenTree. Uses the same preprocessing pipeline as the full model.
§Returns
Ok(Vec<f32>): Linear-only predictions (base + linear model)Err: If model is not LinearThenTree mode
Sourcepub fn predict_binned(&self, dataset: &BinnedDataset) -> Vec<f32>
pub fn predict_binned(&self, dataset: &BinnedDataset) -> Vec<f32>
Predict on a BinnedDataset (for advanced users)
Sourcepub fn mode(&self) -> BoostingMode
pub fn mode(&self) -> BoostingMode
Get the boosting mode that was used
Sourcepub fn mode_confidence(&self) -> Option<Confidence>
pub fn mode_confidence(&self) -> Option<Confidence>
Get confidence in the mode selection
Sourcepub fn build_time(&self) -> Duration
pub fn build_time(&self) -> Duration
Get total training time
Sourcepub fn phase_times(&self) -> &BuildPhaseTimes
pub fn phase_times(&self) -> &BuildPhaseTimes
Get time breakdown by phase
Sourcepub fn preprocessing_plan(&self) -> Option<&PreprocessingPlan>
pub fn preprocessing_plan(&self) -> Option<&PreprocessingPlan>
Get the preprocessing plan that was applied
Sourcepub fn feature_plan(&self) -> Option<&FeaturePlan>
pub fn feature_plan(&self) -> Option<&FeaturePlan>
Get the feature engineering plan that was applied
Sourcepub fn column_profile(&self) -> Option<&DataFrameProfile>
pub fn column_profile(&self) -> Option<&DataFrameProfile>
Get the column profile from analysis
Sourcepub fn analysis(&self) -> Option<&DatasetAnalysis>
pub fn analysis(&self) -> Option<&DatasetAnalysis>
Get the dataset analysis result
Sourcepub fn ltt_tuning(&self) -> Option<&LttTuningResult>
pub fn ltt_tuning(&self) -> Option<&LttTuningResult>
Get LTT tuning result (if LTT mode was used)
Sourcepub fn tree_tuning(&self) -> Option<&TreeTuningResult>
pub fn tree_tuning(&self) -> Option<&TreeTuningResult>
Get tree tuning result (if PureTree/RandomForest mode was used)
Sourcepub fn num_features(&self) -> usize
pub fn num_features(&self) -> usize
Get number of features
Sourcepub fn inner(&self) -> &UniversalModel
pub fn inner(&self) -> &UniversalModel
Get the underlying UniversalModel
Sourcepub fn config(&self) -> &UniversalConfig
pub fn config(&self) -> &UniversalConfig
Get the discovered UniversalConfig
This returns the config that AutoModel discovered through analysis and tuning. You can export this config to JSON and use it to retrain with UniversalModel directly.
Sourcepub fn summary(&self) -> String
pub fn summary(&self) -> String
Get a comprehensive summary of the training process
This shows the full “Smart Engineer” report explaining every decision
Sourcepub fn save_config(&self, path: impl AsRef<Path>) -> Result<()>
pub fn save_config(&self, path: impl AsRef<Path>) -> Result<()>
Export the discovered config to JSON
This saves the UniversalConfig that AutoModel discovered through analysis and tuning. You can load this config and use it to retrain with UniversalModel directly.
§Example
// Train with AutoModel
let model = AutoModel::train(&df, "target")?;
// Export the discovered config
model.save_config("optimal_config.json")?;
// Later: Load and tweak the config
let config = UniversalConfig::load_json("optimal_config.json")?;
let tweaked = config.with_learning_rate(0.05); // Adjust as needed
// Retrain with the tweaked config
let new_model = UniversalModel::train(&dataset, tweaked, &loss_fn)?;Sourcepub fn save(&self, path: impl AsRef<Path>) -> Result<()>
pub fn save(&self, path: impl AsRef<Path>) -> Result<()>
Save the trained model to a file
This saves the underlying UniversalModel (weights, trees, ensembles, etc.) for inference.
The model can be loaded later using UniversalModel::load().
§Example
// Train and save both config and model
let model = AutoModel::train(&df, "target")?;
model.save_config("config.json")?; // For retraining with AutoML
model.save("model.rkyv")?; // For inference
// Later: Load for inference only (not AutoML)
let loaded = UniversalModel::load("model.rkyv")?;
let preds = loaded.predict(&dataset)?;Sourcepub fn update(
&mut self,
df: &DataFrame,
additional_rounds: usize,
) -> Result<AutoModelUpdateReport>
pub fn update( &mut self, df: &DataFrame, additional_rounds: usize, ) -> Result<AutoModelUpdateReport>
Update the model with new training data (incremental learning)
This method continues training from the current model state:
- Uses existing pipeline_state for consistent preprocessing
- Updates the underlying UniversalModel with new trees
- Preserves all configuration from original training
§Arguments
df- New data to train on (must have same columns as original)additional_rounds- Number of new boosting rounds (trees) to add
§Example
// Train on January data
let mut model = AutoModel::train(&jan_df, "target")?;
// Update with February data (10 more trees)
let report = model.update(&feb_df, 10)?;
println!("{}", report);
// Save the updated model
model.save_trb("model.trb")?;Sourcepub fn save_trb_update(
&self,
path: impl AsRef<Path>,
rows_trained: usize,
description: &str,
) -> Result<()>
pub fn save_trb_update( &self, path: impl AsRef<Path>, rows_trained: usize, description: &str, ) -> Result<()>
Append an update to an existing TRB file
This appends a new segment without rewriting the base model.
§Arguments
path- Path to existing .trb filerows_trained- Number of rows used in this updatedescription- Description of this update
Sourcepub fn load_trb(path: impl AsRef<Path>, target_column: &str) -> Result<Self>
pub fn load_trb(path: impl AsRef<Path>, target_column: &str) -> Result<Self>
Load model from TRB format for continued training
This loads the base model and all updates, ready for further training. The returned AutoModel will have minimal metadata (no tuning results, etc.) but the underlying model and pipeline state are preserved.
§Example
let mut model = AutoModel::load_trb("model.trb", "target")?;
model.update(&new_data, 10)?;Sourcepub fn is_compatible_for_update(&self, df: &DataFrame) -> bool
pub fn is_compatible_for_update(&self, df: &DataFrame) -> bool
Check if model is compatible with dataset for incremental update
Sourcepub fn model_mut(&mut self) -> &mut UniversalModel
pub fn model_mut(&mut self) -> &mut UniversalModel
Get mutable reference to the underlying UniversalModel
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AutoModel
impl RefUnwindSafe for AutoModel
impl Send for AutoModel
impl Sync for AutoModel
impl Unpin for AutoModel
impl UnwindSafe for AutoModel
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.