-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a996ce3
commit 6c267fe
Showing
3 changed files
with
57 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import pickle | ||
import json | ||
import db | ||
|
||
import pandas as pd | ||
|
||
|
||
# dict of {"name": name, {"model": model, "scaler": scaler, "results": results}} | ||
models = {} | ||
|
||
|
||
def load_models(): | ||
print("Loading models") | ||
for name in os.listdir("models"): | ||
print(f"Loading model {name}") | ||
model = pickle.load(open(f"models/{name}/model.pkl", "rb")) | ||
scaler = pickle.load(open(f"models/{name}/scaler.pkl", "rb")) | ||
results = pd.read_csv(f"models/{name}/results.csv", index_col=0) | ||
metadata = json.load(open(f"models/{name}/metadata.json", "r")) | ||
models[name] = { | ||
"name": name, | ||
"model": model, | ||
"scaler": scaler, | ||
"results": results, | ||
"metadata": metadata, | ||
} | ||
|
||
def choose_model(transformed_params): | ||
if "askingPrice" in transformed_params: | ||
return models["bostadspriser-with-askingPrice"] | ||
|
||
return models["bostadspriser-without-askingPrice"] | ||
|
||
|
||
def get_live_listings(page: int, page_size: int): | ||
return db.get_live_listings(page, page_size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters