Skip to main content

Regressor

Trait Regressor 

Source
pub trait Regressor: Send + Sync {
    // Required methods
    fn fit(
        &mut self,
        x: ArrayView2<'_, f64>,
        y: ArrayView1<'_, f64>,
    ) -> Result<()>;
    fn predict(&self, x: ArrayView2<'_, f64>) -> Result<Array1<f64>>;
    fn fresh(&self) -> Box<dyn Regressor>;

    // Provided method
    fn fit_weighted(
        &mut self,
        _x: ArrayView2<'_, f64>,
        _y: ArrayView1<'_, f64>,
        _w: ArrayView1<'_, f64>,
    ) -> Result<()> { ... }
}
Expand description

A regression learner for nuisance functions such as E[Y | X] or E[D | X].

fresh returns an unfitted copy with the same hyperparameters, so cross-fitting can train an independent model on each fold.

Send + Sync lets folds be fitted on parallel threads.

Required Methods§

Source

fn fit(&mut self, x: ArrayView2<'_, f64>, y: ArrayView1<'_, f64>) -> Result<()>

Source

fn predict(&self, x: ArrayView2<'_, f64>) -> Result<Array1<f64>>

Source

fn fresh(&self) -> Box<dyn Regressor>

Provided Methods§

Source

fn fit_weighted( &mut self, _x: ArrayView2<'_, f64>, _y: ArrayView1<'_, f64>, _w: ArrayView1<'_, f64>, ) -> Result<()>

Fit minimising a w-weighted loss (needed by the RLearner). The default reports that weights are unsupported.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§