pub struct Trial {
pub id: String,
pub params: HashMap<String, Value>,
pub state: TrialState,
pub metrics: Vec<MetricRecord>,
pub duration_ms: Option<u64>,
pub started_at: Option<DateTime<Utc>>,
pub finished_at: Option<DateTime<Utc>>,
}Expand description
A single hyperparameter evaluation.
Fields§
§id: StringIdentifier unique within the study (the runner uses
trial_NNNN).
params: HashMap<String, Value>The full configuration this trial ran with: sampled dimension
values (prefixed names like "SVM.C"), plus the study’s frozen
params and a "seed" entry when Study::seeds is non-empty.
state: TrialStateLifecycle state; see TrialState.
metrics: Vec<MetricRecord>Every metric recorded during the trial, in recording order — multiple values per name across steps are expected.
duration_ms: Option<u64>Wall-clock duration, set when the trial reaches a terminal state.
started_at: Option<DateTime<Utc>>When execution started. serde(default): absent in trials
serialized before timestamps existed.
finished_at: Option<DateTime<Utc>>When the trial reached a terminal state. serde(default) for
the same pre-timestamp JSON.
Implementations§
Source§impl Trial
impl Trial
Sourcepub fn new(id: impl Into<String>, params: HashMap<String, Value>) -> Self
pub fn new(id: impl Into<String>, params: HashMap<String, Value>) -> Self
A fresh TrialState::Pending trial for a sampled
configuration: no metrics, no timestamps. The runner flips it
to Running and stamps started_at when execution begins.
Sourcepub fn last_metric(&self, name: &str) -> Option<f64>
pub fn last_metric(&self, name: &str) -> Option<f64>
Last recorded value for a metric (its final value).
Sourcepub fn best_metric(&self, name: &str, direction: Direction) -> Option<f64>
pub fn best_metric(&self, name: &str, direction: Direction) -> Option<f64>
Get the best recorded value for a specific metric.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
true only for TrialState::Completed — pruned and failed
trials are finished but not complete. This is the filter
Study::completed_trials and pruner histories use.
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
true once the trial can no longer change state: Completed,
Pruned, or Failed. This is what Study::progress counts,
so pruned and failed trials still advance the progress bar.