@export
def plot_cluster(db_cluster: DBSCAN, data: pd.DataFrame, x_predict: np.ndarray, plot_label: str=None, plot_features: Tuple[(int, int)]=(0, 1), verbose: bool=False, cut_off: int=3, xlabel: str=None, ylabel: str=None):
    '\n    Plot clustered data as scatter chart.\n\n    Parameters\n    ----------\n    db_cluster : DBSCAN\n        DBScan Cluster (from SkLearn DBSCAN).\n    data : pd.DataFrame\n        Dataframe containing original data.\n    x_predict : np.ndarray\n        The DBSCAN predict numpy array\n    plot_label : str, optional\n         If set the column to use to label data points\n         (the default is None)\n    plot_features :  Tuple[int, int], optional\n        Which two features in x_predict to plot (the default is (0, 1))\n    verbose : bool, optional\n        Verbose execution with some extra info\n        (the default is False)\n    cut_off : int, optional\n        The cluster size below which items are considered outliers\n        (the default is 3)\n    xlabel : str, optional\n        x-axis label (the default is None)\n    ylabel : str, optional\n        y-axis label (the default is None)\n\n    '
    max_idx = (x_predict.shape[1] - 1)
    if (plot_features[0] >= x_predict.shape[1]):
        raise ValueError('plot_features[0] index must be a value from 0 to {}.'.format(max_idx))
    if (plot_features[1] >= x_predict.shape[1]):
        raise ValueError('plot_features[1] index must be a value from 0 to {}.'.format(max_idx))
    if (plot_features[0] == plot_features[1]):
        mssg = 'plot_features indexes must be 2 different values in range 0 to'
        raise ValueError((mssg + f' {max_idx}.'))
    labels = db_cluster.labels_
    core_samples_mask = np.zeros_like(labels, dtype=bool)
    core_samples_mask[db_cluster.core_sample_indices_] = True
    unique_labels = set(labels)
    colors = [cm.Spectral(each) for each in np.linspace(0, 1, len(unique_labels))]
    n_clusters_ = (len(set(labels)) - (1 if ((- 1) in labels) else 0))
    n_noise_ = list(labels).count((- 1))
    (_, counts) = np.unique(labels, return_counts=True)
    if verbose:
        print(('Estimated number of clusters: %d' % n_clusters_))
        print(('Estimated number of noise points: %d' % n_noise_))
    if ((not isinstance(data, pd.DataFrame)) or ((plot_label is not None) and (plot_label not in data))):
        plot_label = None
    p_label = None
    for (cluster_id, color) in zip(unique_labels, colors):
        if (cluster_id == (- 1)):
            color = [0, 0, 0, 1]
        class_member_mask = (labels == cluster_id)
        cluster_size = counts[cluster_id]
        marker_size = cluster_size
        marker = 'o'
        font_size = 'small'
        alpha = 0.4
        if (cluster_size < cut_off):
            marker = '+'
            marker_size = 10
            font_size = 'large'
            alpha = 1.0
        xy_pos = x_predict[(class_member_mask & core_samples_mask)]
        plt.plot(xy_pos[:, plot_features[0]], xy_pos[:, plot_features[1]], marker, markerfacecolor=tuple(color), markersize=marker_size)
        if plot_label:
            first_row = data[class_member_mask].iloc[0]
            if ((not first_row.empty) and (plot_label in first_row)):
                p_label = first_row[plot_label]
                try:
                    plt.annotate(p_label, xy=(xy_pos[(0, plot_features[0])], xy_pos[(0, plot_features[1])]), fontsize=font_size, alpha=alpha)
                except IndexError:
                    pass
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.title(('Estimated number of clusters: %d' % n_clusters_))
    plt.show()
    return plt
Plot clustered data as scatter chart.

Parameters
----------
db_cluster : DBSCAN
    DBScan Cluster (from SkLearn DBSCAN).
data : pd.DataFrame
    Dataframe containing original data.
x_predict : np.ndarray
    The DBSCAN predict numpy array
plot_label : str, optional
     If set the column to use to label data points
     (the default is None)
plot_features :  Tuple[int, int], optional
    Which two features in x_predict to plot (the default is (0, 1))
verbose : bool, optional
    Verbose execution with some extra info
    (the default is False)
cut_off : int, optional
    The cluster size below which items are considered outliers
    (the default is 3)
xlabel : str, optional
    x-axis label (the default is None)
ylabel : str, optional
    y-axis label (the default is None)
@export
def plot_cluster(db_cluster: DBSCAN, data: pd.DataFrame, x_predict: np.ndarray, plot_label: str=None, plot_features: Tuple[(int, int)]=(0, 1), verbose: bool=False, cut_off: int=3, xlabel: str=None, ylabel: str=None):
    '\n    Plot clustered data as scatter chart.\n\n    Parameters\n    ----------\n    db_cluster : DBSCAN\n        DBScan Cluster (from SkLearn DBSCAN).\n    data : pd.DataFrame\n        Dataframe containing original data.\n    x_predict : np.ndarray\n        The DBSCAN predict numpy array\n    plot_label : str, optional\n         If set the column to use to label data points\n         (the default is None)\n    plot_features :  Tuple[int, int], optional\n        Which two features in x_predict to plot (the default is (0, 1))\n    verbose : bool, optional\n        Verbose execution with some extra info\n        (the default is False)\n    cut_off : int, optional\n        The cluster size below which items are considered outliers\n        (the default is 3)\n    xlabel : str, optional\n        x-axis label (the default is None)\n    ylabel : str, optional\n        y-axis label (the default is None)\n\n    '
    max_idx = (x_predict.shape[1] - 1)
    if (plot_features[0] >= x_predict.shape[1]):
        raise ValueError('plot_features[0] index must be a value from 0 to {}.'.format(max_idx))
    if (plot_features[1] >= x_predict.shape[1]):
        raise ValueError('plot_features[1] index must be a value from 0 to {}.'.format(max_idx))
    if (plot_features[0] == plot_features[1]):
        mssg = 'plot_features indexes must be 2 different values in range 0 to'
        raise ValueError((mssg + f' {max_idx}.'))
    labels = db_cluster.labels_
    core_samples_mask = np.zeros_like(labels, dtype=bool)
    core_samples_mask[db_cluster.core_sample_indices_] = True
    unique_labels = set(labels)
    colors = [cm.Spectral(each) for each in np.linspace(0, 1, len(unique_labels))]
    n_clusters_ = (len(set(labels)) - (1 if ((- 1) in labels) else 0))
    n_noise_ = list(labels).count((- 1))
    (_, counts) = np.unique(labels, return_counts=True)
    if verbose:
        print(('Estimated number of clusters: %d' % n_clusters_))
        print(('Estimated number of noise points: %d' % n_noise_))
    if ((not isinstance(data, pd.DataFrame)) or ((plot_label is not None) and (plot_label not in data))):
        plot_label = None
    p_label = None
    for (cluster_id, color) in zip(unique_labels, colors):
        if (cluster_id == (- 1)):
            color = [0, 0, 0, 1]
        class_member_mask = (labels == cluster_id)
        cluster_size = counts[cluster_id]
        marker_size = cluster_size
        marker = 'o'
        font_size = 'small'
        alpha = 0.4
        if (cluster_size < cut_off):
            marker = '+'
            marker_size = 10
            font_size = 'large'
            alpha = 1.0
        xy_pos = x_predict[(class_member_mask & core_samples_mask)]
        plt.plot(xy_pos[:, plot_features[0]], xy_pos[:, plot_features[1]], marker, markerfacecolor=tuple(color), markersize=marker_size)
        if plot_label:
            first_row = data[class_member_mask].iloc[0]
            if ((not first_row.empty) and (plot_label in first_row)):
                p_label = first_row[plot_label]
                try:
                    plt.annotate(p_label, xy=(xy_pos[(0, plot_features[0])], xy_pos[(0, plot_features[1])]), fontsize=font_size, alpha=alpha)
                except IndexError:
                    pass
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.title(('Estimated number of clusters: %d' % n_clusters_))
    plt.show()
    return plt