Skip to main content
Glama
optuna

Optuna MCP Server

Official
by optuna

plot_param_importances

Visualize the importance of hyperparameters in optimization studies. Specify parameters, target values, and names to generate a clear plot for analyzing parameter impact on results.

Instructions

Return the parameter importances 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.
            By default, all objective will be plotted by setting target to None.
        target_name:
            Target’s name to display on the legend.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNo
targetNo
target_nameNoObjective Value

Implementation Reference

  • The handler function implementing the plot_param_importances tool. It uses Optuna's visualization module to create a parameter importances plot with a PedAnova importance evaluator and returns the plot as a PNG image via the Image type.
    @mcp.tool()
    def plot_param_importances(
        params: list[str] | None = None,
        target: int | None = None,
        target_name: str = "Objective Value",
    ) -> Image:
        """Return the parameter importances 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.
                By default, all objective will be plotted by setting target to None.
            target_name:
                Target’s name to display on the legend.
        """
        evaluator = optuna.importance.PedAnovaImportanceEvaluator()
        fig = optuna.visualization.plot_param_importances(
            mcp.study,
            evaluator=evaluator,
            params=params,
            target=(lambda t: t.values[target]) if target is not None else None,
            target_name=target_name,
        )
        return Image(data=plotly.io.to_image(fig), format="png")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/optuna/optuna-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server