feat: add inference for elo on new listings
This commit is contained in:
1
data_platform/assets/ml/sql/ensure_elo_schema.sql
Normal file
1
data_platform/assets/ml/sql/ensure_elo_schema.sql
Normal file
@@ -0,0 +1 @@
|
||||
create schema if not exists elo
|
||||
4
data_platform/assets/ml/sql/ensure_notified_table.sql
Normal file
4
data_platform/assets/ml/sql/ensure_notified_table.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
create table if not exists elo.notified (
|
||||
global_id text primary key,
|
||||
notified_at timestamp with time zone default now()
|
||||
)
|
||||
6
data_platform/assets/ml/sql/ensure_predictions_table.sql
Normal file
6
data_platform/assets/ml/sql/ensure_predictions_table.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
create table if not exists elo.predictions (
|
||||
global_id text primary key,
|
||||
predicted_elo double precision not null,
|
||||
mlflow_run_id text not null,
|
||||
scored_at timestamp with time zone default now()
|
||||
)
|
||||
3
data_platform/assets/ml/sql/insert_notified.sql
Normal file
3
data_platform/assets/ml/sql/insert_notified.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
insert into elo.notified (global_id)
|
||||
values (: global_id)
|
||||
on conflict (global_id) do nothing
|
||||
20
data_platform/assets/ml/sql/select_top_predictions.sql
Normal file
20
data_platform/assets/ml/sql/select_top_predictions.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
select
|
||||
ep.global_id,
|
||||
ep.predicted_elo,
|
||||
fl.title,
|
||||
fl.city,
|
||||
fl.url,
|
||||
fl.current_price,
|
||||
fl.living_area,
|
||||
fl.bedrooms,
|
||||
fl.rooms,
|
||||
fl.energy_label,
|
||||
fl.price_per_sqm,
|
||||
ep.scored_at
|
||||
from elo.predictions as ep
|
||||
inner join marts.funda_listings as fl on ep.global_id = fl.global_id
|
||||
left join elo.notified as en on ep.global_id = en.global_id
|
||||
where
|
||||
ep.predicted_elo >=: min_elo
|
||||
and en.global_id is null
|
||||
order by ep.predicted_elo desc
|
||||
28
data_platform/assets/ml/sql/select_unscored_listings.sql
Normal file
28
data_platform/assets/ml/sql/select_unscored_listings.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
select
|
||||
fl.global_id,
|
||||
fl.url,
|
||||
fl.title,
|
||||
fl.city,
|
||||
fl.current_price,
|
||||
fl.living_area,
|
||||
fl.plot_area,
|
||||
fl.bedrooms,
|
||||
fl.rooms,
|
||||
fl.construction_year,
|
||||
fl.latitude,
|
||||
fl.longitude,
|
||||
fl.energy_label,
|
||||
fl.has_garden,
|
||||
fl.has_balcony,
|
||||
fl.has_solar_panels,
|
||||
fl.has_heat_pump,
|
||||
fl.has_roof_terrace,
|
||||
fl.is_energy_efficient,
|
||||
fl.is_monument,
|
||||
fl.photo_count,
|
||||
fl.views,
|
||||
fl.saves,
|
||||
fl.price_per_sqm
|
||||
from marts.funda_listings as fl
|
||||
left join elo.predictions as ep on fl.global_id = ep.global_id
|
||||
where ep.global_id is null
|
||||
7
data_platform/assets/ml/sql/upsert_prediction.sql
Normal file
7
data_platform/assets/ml/sql/upsert_prediction.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
insert into elo.predictions (global_id, predicted_elo, mlflow_run_id)
|
||||
values (: global_id,: predicted_elo,: mlflow_run_id)
|
||||
on conflict (global_id) do update
|
||||
set
|
||||
predicted_elo = excluded.predicted_elo,
|
||||
mlflow_run_id = excluded.mlflow_run_id,
|
||||
scored_at = now()
|
||||
Reference in New Issue
Block a user