def find_coeffs_bin(self, budget):
k = len(self.classes) # number of classes
assert k == 2
n = self.num_features() # vector dimension
X_train = self.gen_query_set(n, budget)
y = logit(self.query_probas(X_train)[:, 1])
X = np.hstack((X_train, np.ones((budget, 1))))
if budget == n+1:
try:
w_opt = np.linalg.solve(X, y).T
except np.linalg.linalg.LinAlgError:
w_opt = np.linalg.lstsq(X, y)[0].T
else:
w_opt = np.linalg.lstsq(X, y)[0].T
int_opt = w_opt[-1]
w_opt = np.array([w_opt[:-1]])
self.X_train = X_train
return w_opt, int_opt
评论列表
文章目录