def confusion_matrix (dataset,subgroup,targetColumn):
    """Returns the confusion matrix of a dataset with a subgroup.""" 
    total_rows = len(dataset)

    #Calculate the complement of the dataset over the subgroup
    complement = dataset[~dataset.index.isin(subgroup.index)]

    #Elements of confusion matrix
    subgroup_pos_target_rate = len(subgroup[subgroup[targetColumn] == 1]) / total_rows
    subgroup_neg_target_rate = len(subgroup[subgroup[targetColumn] == 0]) / total_rows
    complement_pos_target_rate = len(complement[complement[targetColumn] == 1]) / total_rows
    complement_neg_target_rate = len(complement[complement[targetColumn] == 0]) / total_rows
    
    return [[subgroup_pos_target_rate,complement_pos_target_rate],
            [subgroup_neg_target_rate,complement_neg_target_rate]]