1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-10 22:36:55 +08:00

Add RecordTemp & update

This commit is contained in:
Jactus
2020-11-02 11:05:40 +08:00
parent da9d1c8ac6
commit 5f9c8be33d
11 changed files with 263 additions and 81 deletions

View File

@@ -3,7 +3,7 @@
import mlflow
from pathlib import Path
from .recorder import MLflowRecorder
class Experiment:
"""
@@ -15,6 +15,19 @@ class Experiment:
self.id = None
self.recorders = list()
def create_recorder(self):
"""
Create a recorder for each experiment.
Parameters
----------
Returns
-------
A recorder instance.
"""
raise NotImplementedError(f"Please implement the `create_recorder` method.")
def search_records(self, **kwargs):
"""
Get a pandas DataFrame of records that fit the search criteria of the experiment.
@@ -36,15 +49,39 @@ class Experiment:
"""
raise NotImplementedError(f"Please implement the `search_records` method.")
def delete_recorder(self, rid):
"""
Create a recorder for each experiment.
Parameters
----------
rid : str
the id of the recorder to be deleted.
Returns
-------
A recorder instance.
"""
raise NotImplementedError(f"Please implement the `delete_recorder` method.")
class MLflowExperiment(Experiment):
"""
Use mlflow to implement Experiment.
"""
def create_recorder(self):
recorder = MLflowRecorder(self.id)
self.recorders.append(recorder)
return recorders
def search_records(self, **kwargs):
filter_string = "" if kwargs.get("filter_string") is None else kwargs.get("filter_string")
run_view_type = 1 if kwargs.get("run_view_type") is None else kwargs.get("run_view_type")
max_results = 100000 if kwargs.get("max_results") is None else kwargs.get("max_results")
order_by = kwargs.get("order_by")
return mlflow.search_runs([self.experiment_id], filter_string, run_view_type, max_results, order_by)
def delete_recorder(self, rid):
mlflow.delete_run(rid)
self.recorders = [r for r in self.recorders if r.recorder_id == rid]