def class_counts(rows, labels):
    """
    Counts the number of each type of example in a dataset.
    :param rows: array of samples
    :param labels: rows data labels.
    :return: a dictionary of label -> count.
    """
    counts = {cls: 0 for cls in set(labels)}  # a dictionary of label -> count.
    for idx, x in enumerate(rows):
        # in our dataset format, the label is always the last column
        label = labels[idx]
        counts[label] += 1
    return counts