Merge pull request #10 from SDSRV-IDP/feature/accuracy_calculation

Enhancement: exclude bad images from accuracy calculation
This commit is contained in:
Đào Việt Anh 2024-02-01 15:37:13 +07:00 committed by GitHub Enterprise
commit c7e6c3599b
4 changed files with 27 additions and 3 deletions

View File

@ -116,7 +116,7 @@ def make_a_report(report_id, query_set):
report.average_OCR_time = {"invoice": time_cost["invoice"](), "imei": time_cost["imei"](),
"invoice_count": time_cost["invoice"].count, "imei_count": time_cost["imei"].count}
report.average_OCR_time["avg"] = (report.average_OCR_time["invoice"]*report.average_OCR_time["invoice_count"] + report.average_OCR_time["imei"]*report.average_OCR_time["imei_count"])/(report.average_OCR_time["imei_count"] + report.average_OCR_time["invoice_count"])
report.average_OCR_time["avg"] = (report.average_OCR_time["invoice"]*report.average_OCR_time["invoice_count"] + report.average_OCR_time["imei"]*report.average_OCR_time["imei_count"])/(report.average_OCR_time["imei_count"] + report.average_OCR_time["invoice_count"]) if (report.average_OCR_time["imei_count"] + report.average_OCR_time["invoice_count"]) > 0 else None
report.number_imei_transaction = transaction_att.get("imei", 0)
report.number_invoice_transaction = transaction_att.get("invoice", 0)

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.3 on 2024-02-01 08:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('fwd_api', '0177_alter_report_subsidiary'),
]
operations = [
migrations.AlterField(
model_name='reportfile',
name='acc',
field=models.FloatField(default=0, null=True),
),
]

View File

@ -23,7 +23,7 @@ class ReportFile(models.Model):
feedback_accuracy = models.JSONField(null=True)
reviewed_accuracy = models.JSONField(null=True)
acc = models.FloatField(default=0)
acc = models.FloatField(default=0, null=True)
time_cost = models.FloatField(default=0)
is_reviewed = models.CharField(default="NA", max_length=5) # NA, No, Yes

View File

@ -419,6 +419,12 @@ def calculate_subcription_file(subcription_request_file):
avg_acc = max([x for x in [avg_feedback, avg_reviewed] if x is not None])
if avg_acc < BAD_THRESHOLD:
att["is_bad_image"] = True
# exclude bad images
for key_name in valid_keys:
att["acc"]["feedback"][key_name] = []
att["acc"]["reviewed"][key_name] = []
att["avg_acc"] = None
else:
att["avg_acc"] = avg_acc
return 200, att