我正在尝试在 theano 中实现 cox 回归。
我正在使用逻辑回归教程(http://deeplearning.net/tutorial/logreg.html)作为框架,并用 cox 回归 LL 函数(https://en.wikipedia )替换逻辑对数似然(LL)函数.org/wiki/Proportional_hazards_model#The_partial_likelihood)。
这是我到目前为止所拥有的:
class CoxRegression(object):
def __init__(self, x, n_in):
self.W = theano.shared(value=numpy.zeros(n_in,dtype=theano.config.floatX), name='W',borrow=True)
self.b = theano.shared(numpy.cast['float64'](0), borrow=True)
self.theta = T.dot(x, self.W) + self.b
self.exp_theta = T.exp(self.theta)
self.params = [self.W, self.b]
self.x = x
def negative_log_likelihood(self, ytime, ystatus):
LL_i = T.switch(T.eq(ystatus[i],1), self.theta - T.log(T.sum(self.exp_theta * T.gt(ytime, ytime[i]))),0)
基本上,我需要对 LL_i 求和(其中 i 是 0 到 ytime.shape - 1)。但我不知道该怎么做。我应该使用扫描功能吗?