def validate_class_set(classes, subgroups, positive_class=None):
    'Ensures class names are valid and sub-groups exist.'
    class_set = list(set(classes.values()))
    sub_group_list = list()
    if (subgroups != 'all'):
        if isinstance(subgroups, str):
            subgroups = [subgroups]
        for comb in subgroups:
            cls_list = comb.split(',')
            if (len(set(cls_list)) < 2):
                raise ValueError('This subgroup {} does not contain two unique classes.'.format(comb))
            for cls in cls_list:
                if (cls not in class_set):
                    raise ValueError('Class {} in combination {} does not exist in meta data.'.format(cls, comb))
            sub_group_list.append(cls_list)
    else:
        sub_group_list.append(class_set)
    class_order_in_meta = list()
    for x in class_set:
        if (x not in class_order_in_meta):
            class_order_in_meta.append(x)
    num_classes = len(class_order_in_meta)
    if (num_classes < 2):
        raise ValueError('Atleast two classes are required for predictive analysis! Only one given ({})'.format(set(classes.values())))
    if (num_classes == 2):
        if not_unspecified(positive_class):
            if (positive_class not in class_order_in_meta):
                raise ValueError('Positive class specified does not exist in meta data.\nChoose one of {}'.format(class_order_in_meta))
            print('Positive class specified for AUC calculation: {}'.format(positive_class))
        else:
            positive_class = class_order_in_meta[(- 1)]
            print('Positive class inferred for AUC calculation: {}'.format(positive_class))
    return (class_set, sub_group_list, positive_class)
Ensures class names are valid and sub-groups exist.
def validate_class_set(classes, subgroups, positive_class=None):
    
    class_set = list(set(classes.values()))
    sub_group_list = list()
    if (subgroups != 'all'):
        if isinstance(subgroups, str):
            subgroups = [subgroups]
        for comb in subgroups:
            cls_list = comb.split(',')
            if (len(set(cls_list)) < 2):
                raise ValueError('This subgroup {} does not contain two unique classes.'.format(comb))
            for cls in cls_list:
                if (cls not in class_set):
                    raise ValueError('Class {} in combination {} does not exist in meta data.'.format(cls, comb))
            sub_group_list.append(cls_list)
    else:
        sub_group_list.append(class_set)
    class_order_in_meta = list()
    for x in class_set:
        if (x not in class_order_in_meta):
            class_order_in_meta.append(x)
    num_classes = len(class_order_in_meta)
    if (num_classes < 2):
        raise ValueError('Atleast two classes are required for predictive analysis! Only one given ({})'.format(set(classes.values())))
    if (num_classes == 2):
        if not_unspecified(positive_class):
            if (positive_class not in class_order_in_meta):
                raise ValueError('Positive class specified does not exist in meta data.\nChoose one of {}'.format(class_order_in_meta))
            print('Positive class specified for AUC calculation: {}'.format(positive_class))
        else:
            positive_class = class_order_in_meta[(- 1)]
            print('Positive class inferred for AUC calculation: {}'.format(positive_class))
    return (class_set, sub_group_list, positive_class)