theano で cox 回帰を実装しようとしています。
フレームワークとしてロジスティック回帰チュートリアル ( http://deeplearning.net/tutorial/logreg.html ) を使用し、ロジスティック対数尤度 (LL) 関数を cox 回帰 LL 関数 ( https://en.wikipedia .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) を合計する必要があります。しかし、これを行う方法がわかりません。スキャン機能を使用する必要がありますか?