lightgbm.plot_metric

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

Plot one metric during training.

Parameters:
  • booster (dict or LGBMModel) – Dictionary returned from lightgbm.train() or LGBMModel instance.
  • metric (string 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 strings 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 (string or None, optional (default="Metric during training")) – Axes title. If None, title is disabled.
  • xlabel (string or None, optional (default="Iterations")) – X-axis title label. If None, title is disabled.
  • ylabel (string or None, optional (default="auto")) – Y-axis title label. If ‘auto’, metric name is used. If None, title is disabled.
  • 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.
Returns:

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

Return type:

matplotlib.axes.Axes