def calculate_cluster_purity(contingency_mat):
    """
    Will calculate the cluster purity given a contingency matrix.

    :param contingency_mat: Contingency matrix containing the observations.
    :return: Cluster purity value
    """
    return contingency_mat.max().sum() / contingency_mat.values.sum()