def update_sparse_predictions(Y,D,W,Psi,lda=0.0001):
X = np.zeros((Psi.shape[0],W.shape[1]))
for i in range(W.shape[1]):
used = (W[:,i] != 0)
if used.sum() > 0:
d = np.copy(D)
d = d[:,used]
model = Ridge(alpha=lda)
model.fit(d,Y[:,i])
X[:,i] = model.predict(Psi[:,used])
return X
评论列表
文章目录