Docs · Machine learning

aft: accelerated failure time survival regression.

A Weibull accelerated failure time model, the equivalent of Spark MLlib's AFTSurvivalRegression.

Module
ml_aft
Header
clio_ml/aft.h

What it does

A Weibull accelerated failure time model, the equivalent of Spark MLlib's AFTSurvivalRegression. It fits the coefficients, the intercept and log(sigma) by full-batch Adam on the mean negative log-likelihood, one paged pass per step.

Rows

Features, then time and event (1 observed, 0 censored). clio_ml.COLUMNS["aft"] is 2.

Python

python
import numpy as np, clio_ml as cm
r = cm.fit_aft(X, iters=500)                   # X: features | time | event
median = cm.predict("aft", r, X[0, :-2])        # exp(mu) * (ln 2)^sigma
  • fit_aft(X, **options) accepts an in-memory array or a paged Dataset from cm.dataset(X) or cm.assimilate(...).
  • Options: iters (500), learning_rate (0.02, Adam), threads (256).
  • Result AftResult: coef (n_features coefficients, the intercept, then log(sigma)), loss_history (mean negative log-likelihood per step), stats. Sigma() returns exp of the last coefficient.

C++

cpp
AftResult FitAft(Dataset &ds, const AftOptions &opt);
AftResult FitAftPlain(const float *data, u64 n_rows, u32 nf, u64 elems_per_page,
                      u32 nblocks, const AftOptions &opt);
float AftPredictMedian(const AftResult &r, const float *x);  // median survival time

The paged call needs the runtime; the Plain call runs the same kernel over a plain copy of the data without one.

Related: Poisson GLM, linear regression. Back to the machine learning overview.