Issue
I created a study to optimize a model with Optuna, which produced a .db file with the same name as the study_name.
The problem is that I'm trying to load the results by using:
study = optuna.create_study(study_name=study_name,
storage=f"sqlite:///{results_folder}/results.db",
directions=["maximize", "maximize"],
load_if_exists=True)
but I renamed the original .db file, and I can't remember what was its original name (i.e., the original study_name value).
I seem to understand that I can rename the file and use the new file name in the "storage" argument when loading the study, but I should use the original value of study_name. In case I don't, I get a message saying that:
[W 2022-08-31 14:55:26,962] Study instance does not contain completed trials.
[W 2022-08-31 14:55:26,964] Your study does not have any completed trials.
Is there any way I can get it back from the .db file?
Solution
Yep! The db file is query-able. Study names are stored in a table called "studies", so you can use your database interface of choice to query that table. However, if you're storing multiple study results in this one db file, you'll need to be able to remember which of the study names you find is actually the one you're after.
Here's a quick example of how to do it in python, probably not the best code but still:
import sqlite3
con = sqlite3.connect("/path/to/your/file/results.db")
cur = con.cursor()
res = cur.execute("SELECT * FROM studies")
res.fetchall()
Answered By - John C
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.