/
kuklindal
/
RealEstateAnalyzer
Обзор
Документация
Войти
/
kuklindal
/
RealEstateAnalyzer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
backend/evaluate.py
34 строки
961 B
Daniil Kuklin
fixes
20 май 2026, 13:17
20 май 2026, 13:17
51eb5cc
Код
Авторство
О чём код?
import spacy from backend.prepare_data import convert_dataset from sklearn.metrics import precision_score, recall_score, f1_score nlp = spacy.load("ner_model") test_data = convert_dataset( "data/annotations/test.json", "data/images/test" ) y_true = [] y_pred = [] for text, annotations in test_data: doc = nlp(text) true_entities = {(start, end, label) for start, end, label in annotations["entities"]} pred_entities = {(ent.start_char, ent.end_char, ent.label_) for ent in doc.ents} # сравниваем presence for ent in true_entities: y_true.append(1) y_pred.append(1 if ent in pred_entities else 0) # считаем метрики precision = precision_score(y_true, y_pred) recall = recall_score(y_true, y_pred) f1 = f1_score(y_true, y_pred) print("\n=== METRICS ===") print(f"Precision: {precision:.2f}") print(f"Recall: {recall:.2f}") print(f"F1-score: {f1:.2f}")