plot_slice
Generate slice plots for hyperparameter optimization results. Visualize parameter impact on target values, specify axes labels, and analyze optimization trends effectively.
Instructions
Return the slice plot as an image.
Args:
params:
Parameter list to visualize. The default is all parameters.
target:
An index to specify the value to display. To plot nth objective value, set this to n.
Note that this is 0-indexed, i.e., to plot the first objective value, set this to 0.
target_name:
Target’s name to display on the axis label.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | No | ||
| target | No | ||
| target_name | No | Objective Value |
Implementation Reference
- optuna_mcp/server.py:532-555 (handler)The handler function for the 'plot_slice' tool. It generates a slice plot using Optuna's visualization module based on the provided parameters, target index, and name, then converts the Plotly figure to a PNG image and returns it as an MCP Image object.@mcp.tool() def plot_slice( params: list[str] | None = None, target: int = 0, target_name: str = "Objective Value", ) -> Image: """Return the slice plot as an image. Args: params: Parameter list to visualize. The default is all parameters. target: An index to specify the value to display. To plot nth objective value, set this to n. Note that this is 0-indexed, i.e., to plot the first objective value, set this to 0. target_name: Target’s name to display on the axis label. """ fig = optuna.visualization.plot_slice( mcp.study, params=params, target=lambda t: t.values[target], target_name=target_name, ) return Image(data=plotly.io.to_image(fig), format="png")
- optuna_mcp/server.py:686-686 (registration)Registers all tools on the OptunaMCP instance, including the 'plot_slice' handler, by invoking the register_tools function which defines the decorated tool methods.mcp = register_tools(mcp)