autonlab / auton-survival

Auton Survival - an open source package for Regression, Counterfactual Estimation, Evaluation and Phenotyping with Censored Time-to-Events
http://autonlab.github.io/auton-survival
MIT License
315 stars 74 forks source link

Questions about DSM #142

Open WenxiongLiao opened 2 months ago

WenxiongLiao commented 2 months ago
def _weibull_loss(model, t, e, risk='1'):

  shape, scale = model.get_shape_scale(risk)

  k_ = shape.expand(t.shape[0], -1)
  b_ = scale.expand(t.shape[0], -1)

  ll = 0.
  for g in range(model.k):

    k = k_[:, g]
    b = b_[:, g]

    s = - (torch.pow(torch.exp(b)*t, torch.exp(k)))
    f = k + b + ((torch.exp(k)-1)*(b+torch.log(t)))
    f = f + s

    uncens = np.where(e.cpu().data.numpy() == int(risk))[0]
    cens = np.where(e.cpu().data.numpy() != int(risk))[0]
    ll += f[uncens].sum() + s[cens].sum()

  return -ll.mean()

s = - (torch.pow(torch.exp(b)t, torch.exp(k))) f = k + b + ((torch.exp(k)-1)(b+torch.log(t))) f = f + s How was this derived? Can you give a more detailed derivation process?