def fit(self, x, y):
# Convert non-binary features to binary
bin_x = tfidf_to_counts(x)
# Calculating the log-count ratio
X_pos = bin_x[np.where(y == 1)]
X_neg = bin_x[np.where(y == 0)]
self.r = log_count_ratio(X_pos, X_neg)
X = np.multiply(self.r, bin_x)
# Training linear SVM with NB features but no interpolation
svm = LinearSVC(C=self.C)
svm.fit(X, y)
self.coef_ = svm.coef_
self.int_coef_ = interpolate(self.coef_, self.beta)
self.bias = svm.intercept_
# Scores the interpolated model
评论列表
文章目录