Enhancement: exclude bad images from accuracy calculation
This commit is contained in:
parent
3f86cd10fe
commit
d075efda67
@ -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)
|
||||
|
18
cope2n-api/fwd_api/migrations/0178_alter_reportfile_acc.py
Normal file
18
cope2n-api/fwd_api/migrations/0178_alter_reportfile_acc.py
Normal 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),
|
||||
),
|
||||
]
|
@ -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
|
||||
|
@ -419,7 +419,13 @@ 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
|
||||
att["avg_acc"] = avg_acc
|
||||
# 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
|
||||
|
||||
def calculate_attributions(request): # for one request, return in order
|
||||
|
Loading…
Reference in New Issue
Block a user