pub struct PredictorNetwork<T: Float + Debug + ScalarOperand + Send + Sync + 'static> { /* private fields */ }Expand description
Performance prediction network: fixed random feature map + ridge-fitted heads.
Implementations§
Source§impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> PredictorNetwork<T>
impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> PredictorNetwork<T>
Sourcepub fn new(architecture: Vec<usize>, ridge_lambda: T) -> Result<Self>
pub fn new(architecture: Vec<usize>, ridge_lambda: T) -> Result<Self>
Build the network.
architecture lists the widths of the input layer and every hidden
layer; the last entry is the width of the feature map the linear heads
read. ridge_lambda must be positive so the normal equations stay
positive-definite (and hence Cholesky-solvable) even with fewer samples
than features.
§Errors
Returns Err when the architecture has fewer than two layers, any width
is zero, the input width disagrees with PREDICTION_FEATURE_COUNT, or
ridge_lambda <= 0.
Sourcepub fn is_trained(&self) -> bool
pub fn is_trained(&self) -> bool
Whether the heads have been fitted.
Sourcepub fn architecture(&self) -> &[usize]
pub fn architecture(&self) -> &[usize]
Layer widths.
Sourcepub fn feature_width(&self) -> usize
pub fn feature_width(&self) -> usize
Width of the feature map the heads read.
Sourcepub fn parameter_count(&self) -> usize
pub fn parameter_count(&self) -> usize
Total parameter count (fixed map + learned heads).
Sourcepub fn fit(&mut self, samples: &[PredictorSample]) -> Result<PredictorFitReport>
pub fn fit(&mut self, samples: &[PredictorSample]) -> Result<PredictorFitReport>
Fit both heads by ridge regression on samples.
Solves (ΦᵗΦ + λI) w = Φᵗ y exactly via Cholesky. Returns the training
RMSE of each head.
§Errors
Returns Err when samples is empty or the normal-equation matrix is
not positive-definite (which cannot happen for λ > 0, but is checked
rather than assumed).
Sourcepub fn predict(&self, features: &PredictionFeatures) -> Result<PredictorOutput>
pub fn predict(&self, features: &PredictionFeatures) -> Result<PredictorOutput>
Predict from a feature vector.
While untrained the means are 0 and the uncertainty is 1 with
confidence 0 — an explicit “no information” answer rather than a
fabricated constant.
Trait Implementations§
Source§impl<T: Clone + Float + Debug + ScalarOperand + Send + Sync + 'static> Clone for PredictorNetwork<T>
impl<T: Clone + Float + Debug + ScalarOperand + Send + Sync + 'static> Clone for PredictorNetwork<T>
Auto Trait Implementations§
impl<T> Freeze for PredictorNetwork<T>
impl<T> RefUnwindSafe for PredictorNetwork<T>
impl<T> Send for PredictorNetwork<T>
impl<T> Sync for PredictorNetwork<T>
impl<T> Unpin for PredictorNetwork<T>
impl<T> UnsafeUnpin for PredictorNetwork<T>
impl<T> UnwindSafe for PredictorNetwork<T>
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.