def train(self, texts, solutions): try: Y = encode_one_hot(get_solution_vec(solutions, self.tags)) X = pipelines.get_embedding_indices(texts, maxlen=self.sequence_length) self.clf.train(X, Y) except RuntimeError: print("Training model failed") raise
def train(self, texts, solutions): X = pipelines.get_wv_vec(texts, self.sequence_length) solution_vec = get_solution_vec(solutions, tags=self.tags) stance_indices = np.where(solution_vec > 0) # NEUTRAL = 0 X_stance = X[stance_indices] stance_solution = solution_vec[stance_indices] stance_solution -= 1 Y_stance = encode_one_hot(stance_solution) np.place(solution_vec, solution_vec == 2, 1) Y_arg = encode_one_hot(solution_vec) self.clf_argumentative.train(X, Y_arg) self.clf_stance.train(X_stance, Y_stance)
def test(self, texts, solutions, avg_metrics=False): X = pipelines.get_wv_vec(texts, self.sequence_length) solution_vec = get_solution_vec(solutions, tags=self.tags) stance_indices = np.where(solution_vec > 0) # NEUTRAL = 0 X_stance = X[stance_indices] stance_solution = solution_vec[stance_indices] stance_solution -= 1 Y_stance = encode_one_hot(stance_solution) np.place(solution_vec, solution_vec == 2, 1) Y_arg = encode_one_hot(solution_vec) self.clf_argumentative.train(X, Y_arg) self.clf_stance.train(X_stance, Y_stance) X = pipelines.get_wv_vec(texts, self.sequence_length) arg_prediction_vec = self.clf_argumentative.predict(X) stance_prediction_vec = self.clf_stance.predict(X) return None
def test(self, texts, solutions, avg_metrics=False): Y = encode_one_hot(get_solution_vec(solutions, self.tags)) X = pipelines.get_wv_vec_sequence(texts) return super()._evaluate_metrics(X, Y, avg_metrics)
def train(self, texts, solutions): Y = encode_one_hot(get_solution_vec(solutions, tags=self.tags)) X = pipelines.get_wv_vec_sequence(texts) self.clf.train(X, Y)
def test(self, texts, solutions, avg_metrics=False): Y = encode_one_hot(get_solution_vec(solutions, self.tags)) X = pipelines.get_embedding_indices(texts, maxlen=self.sequence_length) return super()._evaluate_metrics(X, Y, avg_metrics)
def train(self, texts, solutions): Y = encode_one_hot(get_solution_vec(solutions, tags=self.tags)) X = pipelines.get_embedding_indices(texts, maxlen=self.sequence_length) self.clf.train(X, Y)
def test(self, texts, solutions, avg_metrics=False): Y = get_solution_vec(solutions, self.tags) X = pipelines.get_feature_vec(texts) return super()._evaluate_metrics(X, Y, avg_metrics)
def train(self, texts, solutions): Y = get_solution_vec(solutions, self.tags) X = pipelines.get_feature_vec(texts) self.clf.train(X, Y)
def train(self, texts, solutions): Y = encode_one_hot(get_solution_vec(solutions, self.tags)) X = pipelines.get_feature_vec(texts) self.clf.train(X, Y)