AutoModel

Struct AutoModel 

Source
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

Source

pub fn from_build_result(result: BuildResult) -> Self

Create an AutoModel from a BuildResult

Source

pub fn train(df: &DataFrame, target_col: &str) -> Result<Self>

Train a model with default settings (the simplest API)

This is the recommended entry point for most users.

§Example
let model = AutoModel::train(&df, "price")?;
let predictions = model.predict(&test_df)?;
Source

pub fn train_quick(df: &DataFrame, target_col: &str) -> Result<Self>

Train with quick settings (minimal tuning, fast training)

Source

pub fn train_thorough(df: &DataFrame, target_col: &str) -> Result<Self>

Train with thorough settings (extensive tuning, best accuracy)

Source

pub fn train_with_mode( df: &DataFrame, target_col: &str, mode: BoostingMode, ) -> Result<Self>

Train with a specific mode (bypass auto-selection)

Source

pub fn train_with_config( df: &DataFrame, target_col: &str, config: AutoConfig, ) -> Result<Self>

Train with custom configuration

Source

pub fn predict(&self, df: &DataFrame) -> Result<Vec<f32>>

Predict on a DataFrame

Returns predictions as a Vec.

Source

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
Source

pub fn predict_binned(&self, dataset: &BinnedDataset) -> Vec<f32>

Predict on a BinnedDataset (for advanced users)

Source

pub fn mode(&self) -> BoostingMode

Get the boosting mode that was used

Source

pub fn mode_confidence(&self) -> Option<Confidence>

Get confidence in the mode selection

Source

pub fn build_time(&self) -> Duration

Get total training time

Source

pub fn phase_times(&self) -> &BuildPhaseTimes

Get time breakdown by phase

Source

pub fn preprocessing_plan(&self) -> Option<&PreprocessingPlan>

Get the preprocessing plan that was applied

Source

pub fn feature_plan(&self) -> Option<&FeaturePlan>

Get the feature engineering plan that was applied

Source

pub fn column_profile(&self) -> Option<&DataFrameProfile>

Get the column profile from analysis

Source

pub fn analysis(&self) -> Option<&DatasetAnalysis>

Get the dataset analysis result

Source

pub fn ltt_tuning(&self) -> Option<&LttTuningResult>

Get LTT tuning result (if LTT mode was used)

Source

pub fn tree_tuning(&self) -> Option<&TreeTuningResult>

Get tree tuning result (if PureTree/RandomForest mode was used)

Source

pub fn num_trees(&self) -> usize

Get number of trees in the model

Source

pub fn num_features(&self) -> usize

Get number of features

Source

pub fn inner(&self) -> &UniversalModel

Get the underlying UniversalModel

Source

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.

Source

pub fn summary(&self) -> String

Get a comprehensive summary of the training process

This shows the full “Smart Engineer” report explaining every decision

Source

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)?;
Source

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)?;
Source

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:

  1. Uses existing pipeline_state for consistent preprocessing
  2. Updates the underlying UniversalModel with new trees
  3. 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")?;
Source

pub fn save_trb(&self, path: impl AsRef<Path>, description: &str) -> Result<()>

Save model to TRB (TreeBoost) incremental format

TRB format supports incremental updates without rewriting the entire file. Use this format when you plan to update the model with new data.

§Example
model.save_trb("model.trb", "Initial training on January data")?;
Source

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 file
  • rows_trained - Number of rows used in this update
  • description - Description of this update
Source

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)?;
Source

pub fn is_compatible_for_update(&self, df: &DataFrame) -> bool

Check if model is compatible with dataset for incremental update

Source

pub fn model_mut(&mut self) -> &mut UniversalModel

Get mutable reference to the underlying UniversalModel

Trait Implementations§

Source§

impl Debug for AutoModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T