DeepHit<T>

Models & Types · AiDotNet.Regression

DeepHit: A deep learning approach to survival analysis with competing risks.

Inheritance: AsyncDecisionTreeRegressionBase<T> → DeepHit<T>

For Beginners

Unlike DeepSurv (which assumes factors affect risk proportionally at all times), DeepHit learns the actual probability of an event at each specific time point. This is useful when:

  • Risk factors affect survival differently at different times
  • You want to predict exact probabilities at specific time horizons
  • You have competing risks (multiple ways an event can happen)

Example: “What’s the probability a patient experiences disease recurrence (risk 1) vs side effects (risk 2) within 1 year, 2 years, or 5 years?”

Key concepts:

  • Time bins: The time axis is divided into discrete bins (e.g., months 0-12, 12-24, 24-36…)
  • PMF: Probability Mass Function - probability of event at each time bin
  • CIF: Cumulative Incidence Function - probability of event by time t
  • Survival: Probability of no event by time t

How It Works

DeepHit directly learns the distribution of survival times without making the proportional hazards assumption. It outputs the probability mass function (PMF) of event times across discrete time bins and can handle multiple competing risks.

Reference: Lee, C. et al. (2018). “DeepHit: A Deep Learning Approach to Survival Analysis with Competing Risks”. AAAI Conference on Artificial Intelligence.

Example

using AiDotNet;
using AiDotNet.Data.Loaders;
using AiDotNet.Regression;
using AiDotNet.Tensors.LinearAlgebra;

double[][] features =
{
    new[] { 1.0, 2.0 }, new[] { 2.0, 3.0 }, new[] { 3.0, 4.0 },
    new[] { 4.0, 5.0 }, new[] { 5.0, 6.0 }, new[] { 6.0, 7.0 }
};
double[] targets = { 3.0, 5.0, 7.0, 9.0, 11.0, 13.0 };

var result = await new AiModelBuilder<double, Matrix<double>, Vector<double>>()
    .ConfigureModel(new DeepHit<double>())
    .ConfigureDataLoader(DataLoaders.FromArrays(features, targets))
    .BuildAsync();

Console.WriteLine("Trained DeepHit.");

Constructors

Constructor Summary
DeepHit(DeepHitOptions<T> options, IRegularization<T, Matrix<T>, Vector<T>> regularization) Initializes a new instance of DeepHit.

Properties

Property Summary
int NumberOfTrees { get; }

Methods

Method Summary
Matrix<T> PredictCIF(Matrix<T> input, Vector<T> times, int riskIndex) Predicts cumulative incidence function (CIF) for a specific risk.
Matrix<T> PredictSurvival(Matrix<T> input, Vector<T> times) Predicts survival probability S(t) = P(T > t) at specified times.
ModelMetadata<T> GetModelMetadata()
Task TrainAsync(Matrix<T> x, Vector<T> times, Vector<T> events) Trains the network on right-censored, possibly competing-risks survival data.
Task TrainAsync(Matrix<T> x, Vector<T> y)
Task<Vector<T>> PredictAsync(Matrix<T> input) Predicts the expected event time for each subject.
Tensor<T> PredictPMF(Matrix<T> input) Predicts the probability mass function (PMF) of event time for each sample.
Vector<T> PredictExpectedTime(Matrix<T> input) Predicts expected time to event.
Vector<T> PredictMedianSurvivalTime(Matrix<T> input) Predicts median survival time for each sample.
double ComputeCIndex(Matrix<T> x, Vector<T> times, Vector<T> events) Computes the concordance index (C-index) for model evaluation.
double ComputeTimeDependentAUC(Matrix<T> x, Vector<T> times, Vector<T> events, T horizon) Computes the time-dependent AUC at specific time horizons.