Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit78c5628

Browse files
committed
Allow to retrain the same project
1 parent41a7cdf commit78c5628

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

‎pgml/pgml/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
defversion():
2-
return"0.3"
2+
return"0.4"

‎pgml/pgml/model.py‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,19 +420,29 @@ def train(
420420
test_size (float or int, optional): If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split. If int, represents the absolute number of test samples. If None, the value is set to the complement of the train size. If train_size is also None, it will be set to 0.25.
421421
test_sampling: (str, optional): How to sample to create the test data. Defaults to "random". Valid values are ["first", "last", "random"].
422422
"""
423-
project=Project.create(project_name,objective)
424-
snapshot=Snapshot.create(relation_name,y_column_name,test_size,test_sampling)
425-
best_model=None
426-
best_error=None
427423
ifobjective=="regression":
428424
algorithms= ["linear","random_forest"]
429425
elifobjective=="classification":
430426
algorithms= ["random_forest"]
431427
else:
432428
raisePgMLException(
433-
f"Unknown objective'{objective}', available options are: regression, classification"
429+
f"Unknown objective`{objective}`, available options are: regression, classification."
434430
)
435431

432+
try:
433+
project=Project.find_by_name(project_name)
434+
exceptPgMLException:
435+
project=Project.create(project_name,objective)
436+
437+
ifproject.objective!=objective:
438+
raisePgMLException(
439+
f"Project `{project_name}` already exists with a different objective: `{project.objective}`. Create a new project instead."
440+
)
441+
442+
snapshot=Snapshot.create(relation_name,y_column_name,test_size,test_sampling)
443+
best_model=None
444+
best_error=None
445+
436446
foralgorithm_nameinalgorithms:
437447
model=Model.create(project,snapshot,algorithm_name)
438448
model.fit(snapshot)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp