Plotting Module¶
The module includes basic plotting functionality for machine learning applications. Namely, following functions are implemented:
- scripts.plotting.plot_1d_decision_regions(x, y, model, meshsize=0.01, title='unnamed', ax=None)¶
Plots 1d decision regions for given feature and model. In addition, it adds on top training datapoints.
- Parameters
x (
numpy.ndarray) – One dimensional array with values of the given feature.y (
numpy.ndarray) – One dimensional array with labels of given classes from training dataset.model (python object) – Trained model.
meshsize (float, optional) – Space between points wihthin the meshgrid.
title (str, optional) – Title of the plot.
ax (
matplotlib.axes.Axes, optional) – If you want to plot it to the prespecified axes.
- Returns
fig – The plotted 1d decision region.
- Return type
matplotlib.figure.Figure- Raises
AssertionError – If the feature space is not one dimensional.
- scripts.plotting.plot_2d_decision_regions(x, y, model, meshsize=100, marker='s', colors=None, show_probs=False, title='unnamed', ax=None)¶
Plots 2d decision regions for given 2 features and model. In addition, it adds on top training datapoints.
- Parameters
x (
numpy.ndarray) – 2 dimensional array with values of the given features.y (
numpy.ndarray) – One dimensional array with labels of given classes from training dataset.model (python object) – Trained model.
meshsize (float, optional) – Space between points wihthin the meshgrid.
marker (str, optional) – Type of the marker to represent datapoints in the plot.
colors (list, optional) – List with colors for each feature.
show_probs (bool) – Intensity of the regions color is based on the probability of the predicted class.
title (str, optional) – Title of the plot.
ax (
matplotlib.axes.Axes, optional) – If you want to plot it to the prespecified axes.
- Returns
ax – The plotted 2d decision region.
- Return type
matplotlib.axes.Axes- Raises
AssertionError – If the feature space is not two dimensional.