mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-23 13:30:25 +08:00
Merge pull request #474 from c-bata/gh-410-contour-issue
Fix bug of contour plot
This commit is contained in:
@@ -168,6 +168,29 @@ def create_dummy_storage() -> optuna.storages.InMemoryStorage:
|
||||
|
||||
study.optimize(objective_single_inf_report, n_trials=50)
|
||||
|
||||
# Issue 410
|
||||
study = optuna.create_study(study_name="Issue 410", storage=storage, sampler=sampler)
|
||||
|
||||
def objective_issue_410(trial: optuna.Trial) -> float:
|
||||
trial.suggest_categorical("resample_rate", ["50ms"])
|
||||
trial.suggest_categorical("channels", ["all"])
|
||||
trial.suggest_categorical("window_size", [256])
|
||||
if trial.number > 15:
|
||||
raise Exception("Unexpected error")
|
||||
trial.suggest_categorical("cbow", [True])
|
||||
trial.suggest_categorical("model", ["m1"])
|
||||
|
||||
trial.set_user_attr("epochs", 0)
|
||||
trial.set_user_attr("deterministic", True)
|
||||
if trial.number > 10:
|
||||
raise Exception("unexpeccted error")
|
||||
trial.set_user_attr("folder", "/path/to/folder")
|
||||
trial.set_user_attr("resample_type", "foo")
|
||||
trial.set_user_attr("run_id", "0001")
|
||||
return 1.0
|
||||
|
||||
study.optimize(objective_issue_410, n_trials=20, catch=(Exception,))
|
||||
|
||||
# No trials single-objective study
|
||||
optuna.create_study(study_name="single-no-trials", storage=storage, sampler=sampler)
|
||||
|
||||
|
||||
@@ -166,6 +166,31 @@ const plotContour = (
|
||||
const xIndices = xAxis.indices
|
||||
const yIndices = yAxis.indices
|
||||
|
||||
const layout: Partial<plotly.Layout> = {
|
||||
xaxis: {
|
||||
title: xParam.name,
|
||||
type: xAxis.isCat ? "category" : undefined,
|
||||
},
|
||||
yaxis: {
|
||||
title: yParam.name,
|
||||
type: yAxis.isCat ? "category" : undefined,
|
||||
},
|
||||
margin: {
|
||||
l: 50,
|
||||
t: 0,
|
||||
r: 50,
|
||||
b: 50,
|
||||
},
|
||||
uirevision: "true",
|
||||
template: mode === "dark" ? plotlyDarkTemplate : {},
|
||||
}
|
||||
|
||||
// TODO(c-bata): Support parameters that only have the single value
|
||||
if (xIndices.length <= 1 || yIndices.length <= 1) {
|
||||
plotly.react(plotDomId, [], layout)
|
||||
return
|
||||
}
|
||||
|
||||
const xValues: plotly.Datum[] = []
|
||||
const yValues: plotly.Datum[] = []
|
||||
const zValues: plotly.Datum[][] = new Array(yIndices.length)
|
||||
@@ -214,25 +239,6 @@ const plotContour = (
|
||||
showlegend: false,
|
||||
},
|
||||
]
|
||||
|
||||
const layout: Partial<plotly.Layout> = {
|
||||
xaxis: {
|
||||
title: xParam.name,
|
||||
type: xAxis.isCat ? "category" : undefined,
|
||||
},
|
||||
yaxis: {
|
||||
title: yParam.name,
|
||||
type: yAxis.isCat ? "category" : undefined,
|
||||
},
|
||||
margin: {
|
||||
l: 50,
|
||||
t: 0,
|
||||
r: 50,
|
||||
b: 50,
|
||||
},
|
||||
uirevision: "true",
|
||||
template: mode === "dark" ? plotlyDarkTemplate : {},
|
||||
}
|
||||
plotly.react(plotDomId, plotData, layout)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user