lightgbm.plot_metric(booster, metric=None, dataset_names=None, ax=None, xlim=None, ylim=None, title='Metric during training', xlabel='Iterations', ylabel='@metric@', figsize=None, dpi=None, grid=True)[source]

Plot one metric during training.

  • booster (dict or LGBMModel) – Dictionary returned from lightgbm.train() or LGBMModel instance.

  • metric (str or None, optional (default=None)) – The metric name to plot. Only one metric supported because different metrics have various scales. If None, first metric picked from dictionary (according to hashcode).

  • dataset_names (list of str, or None, optional (default=None)) – List of the dataset names which are used to calculate metric to plot. If None, all datasets are used.

  • ax (matplotlib.axes.Axes or None, optional (default=None)) – Target axes instance. If None, new figure and axes will be created.

  • xlim (tuple of 2 elements or None, optional (default=None)) – Tuple passed to ax.xlim().

  • ylim (tuple of 2 elements or None, optional (default=None)) – Tuple passed to ax.ylim().

  • title (str or None, optional (default="Metric during training")) – Axes title. If None, title is disabled.

  • xlabel (str or None, optional (default="Iterations")) – X-axis title label. If None, title is disabled.

  • ylabel (str or None, optional (default="@metric@")) – Y-axis title label. If ‘auto’, metric name is used. If None, title is disabled. @metric@ placeholder can be used, and it will be replaced with metric name.

  • figsize (tuple of 2 elements or None, optional (default=None)) – Figure size.

  • dpi (int or None, optional (default=None)) – Resolution of the figure.

  • grid (bool, optional (default=True)) – Whether to add a grid for axes.


ax – The plot with metric’s history over the training.

Return type: