<jupyter_start><jupyter_text>Eval on the dev dataset<jupyter_code>from seqeval.metrics import classification_report, f1_score
dev_labels = [list(e['tags']) for e in dev_dataset]
predictor = CustomSentenceTaggerPredictor(model, reader)

dev_eval_loader = DataLoader(dataset=dev_dataset, batch_size=100, 
                             shuffle=False, collate_fn=lambda a: a)

all_preds = []
for batch in dev_eval_loader:
    all_preds += predictor.predict_batch_instance(batch)
    
pred_tags = [pred['tags'][:len(pred['words'])] for pred in all_preds]
from seqeval.metrics import classification_report, f1_score

print(f1_score(dev_labels, pred_tags))
print(classification_report(dev_labels, pred_tags))
sent_num = 47
list(zip(all_preds[sent_num]['words'], all_preds[sent_num]['tags']))<jupyter_output><empty_output><jupyter_text>Predict on the test set<jupyter_code>reader = ConllUniversalReader(token_indexers={'tokens': indexer}, tag_index=-1)
test_dataset_no_answers = reader.read('test_no_answers.tsv')
predictor = CustomSentenceTaggerPredictor(model, reader) 

predict_data_loader = DataLoader(dataset=test_dataset_no_answers, batch_size=100, 
                                 shuffle=False, collate_fn=lambda a: a)

all_preds = []
for batch in predict_data_loader:
    all_preds += predictor.predict_batch_instance(batch)
    
pred_tags = [pred['tags'][:len(pred['words'])] for pred in all_preds]<jupyter_output><empty_output><jupyter_text>Save the results<jupyter_code>with open('answers_test_triangular.tsv', 'w') as f:
    for pred in all_preds:
        f.write('\n'.join([f'{w}\t{t}' for w, t in zip(pred['words'], pred['tags'])]))
        
        if i < len(all_preds) - 1:
            f.write('\n\n')
with open('answers_test.tsv', 'w') as f:
    for i, pred in enumerate(all_preds):
        f.write('\n'.join([f'{w}\t{t}' for w, t in zip(pred['words'], pred['tags'])]))
        
        if i < len(all_preds) - 1:
            f.write('\n')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13737373737373737, 'fraction_numerical': 0.007070707070707071, 'mean_word_length': 4.809384164222874, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '197761', 'license': 'Apache-2.0', 'n_tokens_mistral': 717, 'n_tokens_neox': 696, 'n_words': 127, 'path': 'NLU/argument_mining_triangular.ipynb', 'repo_name': 'skoltech-nlp/coqas', 'size': '1980'}