pub struct CoxModel { /* private fields */ }
Expand description
cox model w/ elastic net regularization
Implementations§
Source§impl CoxModel
impl CoxModel
Sourcepub fn with_l1_penalty(self, penalty: f64) -> Self
pub fn with_l1_penalty(self, penalty: f64) -> Self
add lasso penalty (L1) - encourages sparsity
Sourcepub fn with_l2_penalty(self, penalty: f64) -> Self
pub fn with_l2_penalty(self, penalty: f64) -> Self
add ridge penalty (L2) - shrinks coefficients
Sourcepub fn with_elastic_net(self, alpha: f64, penalty: f64) -> Self
pub fn with_elastic_net(self, alpha: f64, penalty: f64) -> Self
elastic net mixing: alpha=0 -> pure ridge, alpha=1 -> pure lasso
Sourcepub fn with_max_iterations(self, max_iter: usize) -> Self
pub fn with_max_iterations(self, max_iter: usize) -> Self
max iterations before giving up
Sourcepub fn with_tolerance(self, tol: f64) -> Self
pub fn with_tolerance(self, tol: f64) -> Self
how close is close enough for convergence
Sourcepub fn with_feature_names(self, names: Vec<String>) -> Self
pub fn with_feature_names(self, names: Vec<String>) -> Self
give names to your features for nicer output
Sourcepub fn with_optimizer(self, optimizer: OptimizerType) -> Self
pub fn with_optimizer(self, optimizer: OptimizerType) -> Self
choose which optimizer to use
Sourcepub fn with_learning_rate(self, lr: f64) -> Self
pub fn with_learning_rate(self, lr: f64) -> Self
set learning rate for Adam/RMSprop optimizers
Sourcepub fn with_adam_params(self, beta1: f64, beta2: f64) -> Self
pub fn with_adam_params(self, beta1: f64, beta2: f64) -> Self
set Adam/RMSprop parameters (beta1 for Adam momentum, beta2 for decay rate)
Sourcepub fn with_epsilon(self, eps: f64) -> Self
pub fn with_epsilon(self, eps: f64) -> Self
set Adam/RMSprop numerical stability parameter
Sourcepub fn fit(&mut self, data: &SurvivalData) -> Result<&mut Self>
pub fn fit(&mut self, data: &SurvivalData) -> Result<&mut Self>
fit the model to data - this does the actual work
Sourcepub fn coefficients(&self) -> Result<ArrayView1<'_, f64>>
pub fn coefficients(&self) -> Result<ArrayView1<'_, f64>>
get the fitted coefficients (betas)
Sourcepub fn predict(&self, covariates: ArrayView2<'_, f64>) -> Result<Array1<f64>>
pub fn predict(&self, covariates: ArrayView2<'_, f64>) -> Result<Array1<f64>>
predict risk scores for new patients
Sourcepub fn predict_hazard_ratios(
&self,
covariates: ArrayView2<'_, f64>,
) -> Result<Array1<f64>>
pub fn predict_hazard_ratios( &self, covariates: ArrayView2<'_, f64>, ) -> Result<Array1<f64>>
predict hazard ratios (exp of risk scores)
Sourcepub fn predict_survival(
&self,
covariates: ArrayView2<'_, f64>,
times: ArrayView1<'_, f64>,
) -> Result<Array2<f64>>
pub fn predict_survival( &self, covariates: ArrayView2<'_, f64>, times: ArrayView1<'_, f64>, ) -> Result<Array2<f64>>
predict survival probs at specific time points
Sourcepub fn feature_importance(&self) -> Result<Array1<f64>>
pub fn feature_importance(&self) -> Result<Array1<f64>>
feature importance = abs value of coefficients
Sourcepub fn summary(&self) -> Result<CoxModelSummary>
pub fn summary(&self) -> Result<CoxModelSummary>
get a nice summary of the fitted model
Sourcepub fn regularization_params(&self) -> (f64, f64)
pub fn regularization_params(&self) -> (f64, f64)
what regularization penalties are we using?