🌐 AI搜索 & 代理 主页
Skip to content

Commit 28545c9

Browse files
committed
more fixes
1 parent 85010b3 commit 28545c9

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pgml/pgml/model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ def data(self):
208208

209209
# Sanity check the data
210210
if len(data) == 0:
211-
PgMLException(
211+
raise PgMLException(
212212
f"Relation `{self.relation_name}` contains no rows. Did you pass the correct `relation_name`?"
213213
)
214214
if self.y_column_name not in data[0]:
215-
PgMLException(
215+
raise PgMLException(
216216
f"Column `{self.y_column_name}` not found. Did you pass the correct `y_column_name`?"
217217
)
218218

@@ -428,6 +428,10 @@ def train(
428428
algorithms = ["linear", "random_forest"]
429429
elif objective == "classification":
430430
algorithms = ["random_forest"]
431+
else:
432+
raise PgMLException(
433+
f"Unknown objective '{objective}', available options are: regression, classification"
434+
)
431435

432436
for algorithm_name in algorithms:
433437
model = Model.create(project, snapshot, algorithm_name)

sql/install.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ $$ LANGUAGE plpython3u;
103103
---
104104
--- Regression
105105
---
106-
DROP FUNCTION pgml.train(project_name TEXT, objective TEXT, relation_name TEXT, y_column_name TEXT);
106+
DROP FUNCTION IF EXISTS pgml.train(project_name TEXT, objective TEXT, relation_name TEXT, y_column_name TEXT);
107107
CREATE OR REPLACE FUNCTION pgml.train(project_name TEXT, objective TEXT, relation_name TEXT, y_column_name TEXT)
108-
RETURNS TEXT
108+
RETURNS TABLE(project_name TEXT, objective TEXT, status TEXT)
109109
AS $$
110110
from pgml.model import train
111111

112112
train(project_name, objective, relation_name, y_column_name)
113113

114-
return "OK"
114+
return [(project_name, objective, "deployed")]
115115
$$ LANGUAGE plpython3u;
116116

117117
---

0 commit comments

Comments
 (0)