diff --git a/optuna_dashboard/ts/components/AppDrawer.tsx b/optuna_dashboard/ts/components/AppDrawer.tsx index 79f7d615..0903d72b 100644 --- a/optuna_dashboard/ts/components/AppDrawer.tsx +++ b/optuna_dashboard/ts/components/AppDrawer.tsx @@ -204,21 +204,19 @@ export const AppDrawer: FC<{ /> - {!isPreferential && ( - - - - - - - - - )} + + + + + + + + Trial {trial.number} } /> - - Objective Values = [{trial.values?.join(", ")}] - + {studyDetail?.is_preferential ? null : ( + + Objective Values = [{trial.values?.join(", ")}] + + )} Params = [ {trial.params diff --git a/optuna_dashboard/ts/components/GraphContour.tsx b/optuna_dashboard/ts/components/GraphContour.tsx index d7e2aa13..c75e1500 100644 --- a/optuna_dashboard/ts/components/GraphContour.tsx +++ b/optuna_dashboard/ts/components/GraphContour.tsx @@ -11,6 +11,7 @@ import { useTheme, Box, } from "@mui/material" +import blue from "@mui/material/colors/blue" import { plotlyDarkTemplate } from "./PlotlyDarkMode" import { useMergedUnionSearchSpace } from "../searchSpace" @@ -211,32 +212,62 @@ const plotContour = ( } }) + if (!study.is_preferential) { + const plotData: Partial[] = [ + { + type: "contour", + x: xIndices, + y: yIndices, + z: zValues, + colorscale: "Blues", + connectgaps: true, + hoverinfo: "none", + line: { + smoothing: 1.3, + }, + reversescale: study.directions[objectiveId] !== "minimize", + // https://github.com/plotly/react-plotly.js/issues/251 + // @ts-ignore + contours: { + coloring: "heatmap", + }, + }, + { + type: "scatter", + x: xValues, + y: yValues, + marker: { line: { width: 2.0, color: "Grey" }, color: "black" }, + mode: "markers", + showlegend: false, + }, + ] + plotly.react(plotDomId, plotData, layout) + return + } + + layout.legend = { + y: 0.8, + } + const bestTrialIndices = study.best_trials.map((trial) => trial.number) const plotData: Partial[] = [ { - type: "contour", - x: xIndices, - y: yIndices, - z: zValues, - colorscale: "Blues", - connectgaps: true, - hoverinfo: "none", - line: { - smoothing: 1.3, - }, - reversescale: study.directions[objectiveId] !== "minimize", - // https://github.com/plotly/react-plotly.js/issues/251 - // @ts-ignore - contours: { - coloring: "heatmap", + type: "scatter", + x: xValues.filter((_, i) => bestTrialIndices.includes(i)), + y: yValues.filter((_, i) => bestTrialIndices.includes(i)), + marker: { + line: { width: 2.0, color: "Grey" }, + color: blue[200], }, + name: "best trials", + mode: "markers", }, { type: "scatter", - x: xValues, - y: yValues, + x: xValues.filter((_, i) => !bestTrialIndices.includes(i)), + y: yValues.filter((_, i) => !bestTrialIndices.includes(i)), marker: { line: { width: 2.0, color: "Grey" }, color: "black" }, + name: "others", mode: "markers", - showlegend: false, }, ] plotly.react(plotDomId, plotData, layout) diff --git a/optuna_dashboard/ts/components/PreferentialAnalytics.tsx b/optuna_dashboard/ts/components/PreferentialAnalytics.tsx new file mode 100644 index 00000000..d8623f97 --- /dev/null +++ b/optuna_dashboard/ts/components/PreferentialAnalytics.tsx @@ -0,0 +1,68 @@ +import React, { FC } from "react" +import { + Box, + Card, + CardContent, + Paper, + Typography, + useTheme, +} from "@mui/material" +import Grid2 from "@mui/material/Unstable_Grid2" +import { DataGrid, DataGridColumn } from "./DataGrid" +import { BestTrialsCard } from "./BestTrialsCard" +import { useStudyDetailValue, useStudySummaryValue } from "../state" +import { Contour } from "./GraphContour" + +export const PreferentialAnalytics: FC<{ studyId: number }> = ({ studyId }) => { + const theme = useTheme() + const studySummary = useStudySummaryValue(studyId) + const studyDetail = useStudyDetailValue(studyId) + + const userAttrs = studySummary?.user_attrs || studyDetail?.user_attrs || [] + const userAttrColumns: DataGridColumn[] = [ + { field: "key", label: "Key", sortable: true }, + { field: "value", label: "Value", sortable: true }, + ] + return ( + + + + + + + + + + + + + + + Study User Attributes + + + columns={userAttrColumns} + rows={userAttrs} + keyField={"key"} + dense={true} + initialRowsPerPage={5} + rowsPerPageOption={[5, 10, { label: "All", value: -1 }]} + /> + + + + + + ) +} diff --git a/optuna_dashboard/ts/components/StudyDetail.tsx b/optuna_dashboard/ts/components/StudyDetail.tsx index 738166b5..fedfd625 100644 --- a/optuna_dashboard/ts/components/StudyDetail.tsx +++ b/optuna_dashboard/ts/components/StudyDetail.tsx @@ -30,6 +30,7 @@ import { GraphEdf } from "./GraphEdf" import { TrialList } from "./TrialList" import { StudyHistory } from "./StudyHistory" import { PreferentialTrials } from "./PreferentialTrials" +import { PreferentialAnalytics } from "./PreferentialAnalytics" interface ParamTypes { studyId: string @@ -98,7 +99,9 @@ export const StudyDetail: FC<{ ) } else if (page === "analytics") { - content = ( + content = isPreferential ? ( + + ) : ( Hyperparameter Relationships