-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add template for reading experiment (#48)
* Add template for reading experiment * add code * read latest exp --------- Co-authored-by: Young <[email protected]>
- Loading branch information
1 parent
deeb83d
commit 44e5610
Showing
2 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import qlib | ||
from mlflow.tracking import MlflowClient | ||
from mlflow.entities import ViewType | ||
qlib.init() | ||
|
||
from qlib.workflow import R | ||
# here is the documents of the https://qlib.readthedocs.io/en/latest/component/recorder.html | ||
|
||
# TODO: list all the recorder and metrics | ||
|
||
# Assuming you have already listed the experiments | ||
experiments = R.list_experiments() | ||
|
||
# Iterate through each experiment to list its recorders and metrics | ||
experiment_name = None | ||
for experiment in experiments: | ||
print(f"Experiment: {experiment}") | ||
recorders = R.list_recorders(experiment_name=experiment) | ||
# print(recorders) | ||
for recorder_id in recorders: | ||
if recorder_id is not None: | ||
experiment_name = experiment | ||
print(f"Recorder ID: {recorder_id}") | ||
recorder = R.get_recorder(recorder_id=recorder_id, experiment_name=experiment) | ||
metrics = recorder.list_metrics() | ||
print(f"Metrics: {metrics}") | ||
|
||
# TODO: get the latest recorder | ||
|
||
recorder_list = R.list_recorders(experiment_name="workflow") | ||
end_times = {key: value.info['end_time'] for key, value in recorder_list.items()} | ||
sorted_end_times = dict(sorted(end_times.items(), key=lambda item: item[1], reverse=True)) | ||
|
||
latest_recorder_id = next(iter(sorted_end_times)) | ||
print(f"Latest recorder ID: {latest_recorder_id}") | ||
|
||
latest_recorder = R.get_recorder(experiment_name=experiment_name, recorder_id=latest_recorder_id) | ||
print(f"Latest recorder: {latest_recorder}") | ||
|
||
pred_df = latest_recorder.load_object("pred.pkl") | ||
print("pred_df", pred_df) | ||
|
||
ic_df = latest_recorder.load_object("sig_analysis/ic.pkl") | ||
print("ic_df: ", ic_df) | ||
|
||
ric_df = latest_recorder.load_object("sig_analysis/ric.pkl") | ||
print("ric_df: ", ric_df) | ||
|
||
print("list_metrics: ", latest_recorder.list_metrics()) | ||
print("IC: ", latest_recorder.list_metrics()["IC"]) | ||
print("ICIR: ", latest_recorder.list_metrics()["ICIR"]) | ||
print("Rank IC: ", latest_recorder.list_metrics()["Rank IC"]) | ||
print("Rank ICIR: ", latest_recorder.list_metrics()["Rank ICIR"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters