def gen_WR_pilot_only(self, alpha_l1r = 0):
"""
yT_a and x_a was prepared already.
Now, W_a is calculated using alpha and then,
decode data.
For linear regression, alpha_l1r should not be specified except 0.
"""
yT_a = self.rx_p["yT_a"]
x_a = self.rx_p["x_a"]
# for alpha == 0, model is changed to linear regression.
if alpha_l1r == 0:
model = "LinearRegression"
else:
model = self.model
if model == "LinearRegression":
lm = linear_model.LinearRegression()
elif model == "ElasticNet":
lm = linear_model.ElasticNet( alpha_l1r[0], alpha_l1r[1])
else: # This is either Ridge or Lasso
lm = getattr( linear_model, model)(alpha_l1r)
lm.fit( yT_a, x_a)
self.W_a = lm.coef_
# print( "np.dot( W_a, H_a) =", np.dot( self.W_a, self.H_a))
self.gen_Decoding()
评论列表
文章目录