def test(test_file, model_file):
    textarr, labelarr = list(), list()
    with open(test_file) as testfp:
        lines = testfp.readlines()[:20]
    for line in lines:
        label, text = line.strip().split(' ', 1)
        textarr.append(text)
        labelarr.append(label)
    # for idx, line in enumerate(testlines):
    #     if pu.is_empty_string(line):
    #         continue
    #     label, text = line.split(' ', 1)
    #     print(label, model.predict(text, threshold=0.5), text)
    pred_value_arr = predict(textarr, ftu.load_model(model_file))
    label = [label2value[label] for label in labelarr]
    print(au.score(label, pred_value_arr, 'auc'))
 def load_fasttext_model(self, ft_model_file):
     self.ft_model = ftu.load_model(ft_model_file)
Example #3
0
 def load_ft_model(self, ft_model_file): self.ft_model = ftu.load_model(ft_model_file)
 
 def save_clf_model(self, clf_model_file): joblib.dump(self.clf_model, clf_model_file)