コード例 #1
0
ファイル: models.py プロジェクト: INTER-ACT/ilai
    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)
コード例 #2
0
ファイル: models.py プロジェクト: INTER-ACT/ilai
 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
コード例 #3
0
ファイル: models.py プロジェクト: INTER-ACT/ilai
    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
ファイル: models.py プロジェクト: INTER-ACT/ilai
 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
ファイル: models.py プロジェクト: INTER-ACT/ilai
 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
ファイル: models.py プロジェクト: INTER-ACT/ilai
 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
ファイル: models.py プロジェクト: INTER-ACT/ilai
 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
ファイル: models.py プロジェクト: INTER-ACT/ilai
 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)