Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow loose reinitialization from runs also
  • Loading branch information
PGijsbers committed Nov 18, 2020
commit ecb6906f6b3883799b6f87ddc86680eea705e8bc
7 changes: 5 additions & 2 deletions openml/runs/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def get_run_trace(run_id: int) -> OpenMLRunTrace:
return run_trace


def initialize_model_from_run(run_id: int) -> Any:
def initialize_model_from_run(run_id: int, strict_version: bool = True) -> Any:
"""
Initialized a model based on a run_id (i.e., using the exact
same parameter settings)
Expand All @@ -331,12 +331,15 @@ def initialize_model_from_run(run_id: int) -> Any:
run_id : int
The Openml run_id

strict_version: bool (default=True)
See `flow_to_model` strict_version.

Returns
-------
model
"""
run = get_run(run_id)
return initialize_model(run.setup_id)
return initialize_model(run.setup_id, strict_version)


def initialize_model_from_trace(
Expand Down
11 changes: 6 additions & 5 deletions openml/setups/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,17 @@ def __list_setups(api_call, output_format="object"):
return setups


def initialize_model(setup_id: int) -> Any:
"""
Initialized a model based on a setup_id (i.e., using the exact
same parameter settings)
def initialize_model(setup_id: int, strict_version: bool = True) -> Any:
""" Initialized a model based on a setup_id (i.e., using the exact same parameter settings)

Parameters
----------
setup_id : int
The Openml setup_id

strict_version: bool (default=True)
See `flow_to_model` strict_version.

Returns
-------
model
Expand All @@ -256,7 +257,7 @@ def initialize_model(setup_id: int) -> Any:
subflow = flow
subflow.parameters[hyperparameter.parameter_name] = hyperparameter.value

model = flow.extension.flow_to_model(flow)
model = flow.extension.flow_to_model(flow, strict_version=strict_version)
return model


Expand Down