#768 steps 1+2: normalized image_prediction table (read cutover) #92
@@ -51,6 +51,10 @@ def upgrade() -> None:
|
|||||||
# Backfill from the JSON blob. json_each expands {name: {category,
|
# Backfill from the JSON blob. json_each expands {name: {category,
|
||||||
# confidence}} into one row per prediction. category defaults to 'general'
|
# confidence}} into one row per prediction. category defaults to 'general'
|
||||||
# to mirror the suggestion read path; rows with no confidence are skipped.
|
# to mirror the suggestion read path; rows with no confidence are skipped.
|
||||||
|
# Filter to >= the store floor (ml_settings.tagger_store_floor, default
|
||||||
|
# 0.70) right here so this is self-sufficient — it does NOT depend on the
|
||||||
|
# #764 prune having run, and extracting only the >=floor tail keeps
|
||||||
|
# image_prediction small (~tens of rows/image) even from the full JSON.
|
||||||
op.execute(
|
op.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO image_prediction (image_record_id, raw_name, category, score)
|
INSERT INTO image_prediction (image_record_id, raw_name, category, score)
|
||||||
@@ -62,6 +66,11 @@ def upgrade() -> None:
|
|||||||
json_each(ir.tagger_predictions) je
|
json_each(ir.tagger_predictions) je
|
||||||
WHERE ir.tagger_predictions IS NOT NULL
|
WHERE ir.tagger_predictions IS NOT NULL
|
||||||
AND je.value ->> 'confidence' IS NOT NULL
|
AND je.value ->> 'confidence' IS NOT NULL
|
||||||
|
AND (je.value ->> 'confidence')::double precision
|
||||||
|
>= COALESCE(
|
||||||
|
(SELECT tagger_store_floor FROM ml_settings WHERE id = 1),
|
||||||
|
0.70
|
||||||
|
)
|
||||||
ON CONFLICT (image_record_id, raw_name) DO NOTHING
|
ON CONFLICT (image_record_id, raw_name) DO NOTHING
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user