def MasseyVector(self):
"""This function produces X'Wy
"""
idx = self.itemlist
table = self.table
pair = self.pair
j = np.ravel(pair)
i = np.repeat(np.arange(table.shape[0], dtype=np.int32), 2, axis=0)
data = np.array([[1,-1]],dtype=np.float32)
data = np.ravel(np.repeat(data, table.shape[0], axis=0))
X = coo_matrix((data, (i, j)), shape=(table.shape[0], len(idx)))
X = X.tocsr()
W = np.require(table.iloc[:,4].values, np.float32)
y = table.iloc[:, 2].values - table.iloc[:, 3].values;
Wy=np.multiply(W, y)
return X.T*Wy
评论列表
文章目录