Spaces:
Runtime error
Runtime error
Commit
•
b0fd391
1
Parent(s):
851c63a
Update functions.py
Browse files- functions.py +0 -22
functions.py
CHANGED
@@ -37,28 +37,6 @@ def decode_features(df, feature_view):
|
|
37 |
return df_res
|
38 |
|
39 |
|
40 |
-
def get_model(project, model_name, evaluation_metric, sort_metrics_by):
|
41 |
-
"""Retrieve desired model or download it from the Hopsworks Model Registry.
|
42 |
-
In second case, it will be physically downloaded to this directory"""
|
43 |
-
TARGET_FILE = "model.pkl"
|
44 |
-
list_of_files = [os.path.join(dirpath,filename) for dirpath, _, filenames \
|
45 |
-
in os.walk('.') for filename in filenames if filename == TARGET_FILE]
|
46 |
-
|
47 |
-
if list_of_files:
|
48 |
-
model_path = list_of_files[0]
|
49 |
-
model = joblib.load(model_path)
|
50 |
-
else:
|
51 |
-
if not os.path.exists(TARGET_FILE):
|
52 |
-
mr = project.get_model_registry()
|
53 |
-
# get best model based on custom metrics
|
54 |
-
model = mr.get_best_model(model_name,
|
55 |
-
evaluation_metric,
|
56 |
-
sort_metrics_by)
|
57 |
-
model_dir = model.download()
|
58 |
-
model = joblib.load(model_dir + "/model.pkl")
|
59 |
-
|
60 |
-
return model
|
61 |
-
|
62 |
|
63 |
def get_air_json(AIR_QUALITY_API_KEY):
|
64 |
return requests.get(f'https://api.waqi.info/feed/Helsinki/?token={AIR_QUALITY_API_KEY}').json()['data']
|
|
|
37 |
return df_res
|
38 |
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
def get_air_json(AIR_QUALITY_API_KEY):
|
42 |
return requests.get(f'https://api.waqi.info/feed/Helsinki/?token={AIR_QUALITY_API_KEY}').json()['data']
|