Пример #1
0
 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
Пример #2
0
    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)
Пример #3
0
    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
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 def train(self, texts, solutions):
     Y = get_solution_vec(solutions, self.tags)
     X = pipelines.get_feature_vec(texts)
     self.clf.train(X, Y)
Пример #10
0
 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)