示例#1
0
def set_label_ensemble_args(name, description, args, labels, multi_label_data,
                            number_of_ensembles, fields, model_fields,
                            objective_field):
    """Set of args needed to build an ensemble per label

    """
    if model_fields is None:
        model_fields = []
    else:
        model_fields = relative_input_fields(fields, model_fields)
    if objective_field is None:
        objective_field = fields.objective_field
    objective_id = fields.field_id(objective_field)
    objective_field = fields.fields[objective_id]['name']
    ensemble_args_list = []

    for index in range(number_of_ensembles - 1, -1, -1):
        label = labels[index]
        all_labels = get_all_labels(multi_label_data)
        (new_name, label_field,
         single_label_fields) = label_model_args(name, label, all_labels,
                                                 model_fields, objective_field)
        ensemble_args = set_ensemble_args(new_name, description, args,
                                          single_label_fields, label_field,
                                          fields)
        if multi_label_data is not None:
            ensemble_args.update(
                user_metadata={'multi_label_data': multi_label_data})
        ensemble_args_list.append(ensemble_args)
    return ensemble_args_list
示例#2
0
def set_label_ensemble_args(name, description, args, labels, multi_label_data,
                            number_of_ensembles, fields, model_fields,
                            objective_field):
    """Set of args needed to build an ensemble per label

    """
    if model_fields is None:
        model_fields = []
    else:
        model_fields = relative_input_fields(fields, model_fields)
    if objective_field is None:
        objective_field = fields.objective_field
    objective_id = fields.field_id(objective_field)
    objective_field = fields.fields[objective_id]['name']
    ensemble_args_list = []

    for index in range(number_of_ensembles - 1, -1, -1):
        label = labels[index]
        all_labels = get_all_labels(multi_label_data)
        (new_name, label_field, single_label_fields) = label_model_args(
            name, label, all_labels, model_fields, objective_field)
        ensemble_args = set_ensemble_args(new_name, description, args,
                                          single_label_fields,
                                          label_field, fields)
        if multi_label_data is not None:
            ensemble_args.update(
                user_metadata={'multi_label_data': multi_label_data})
        ensemble_args_list.append(ensemble_args)
    return ensemble_args_list
示例#3
0
def set_label_evaluation_args(name, description, args, labels, all_labels,
                              number_of_evaluations, fields, fields_map,
                              objective_field):
    """Set of args needed to build an evaluation per label

    """
    if objective_field is None:
        objective_id = fields.field_id(fields.objective_field)
        objective_field = fields.fields[objective_id]['name']
    evaluation_args_list = []

    for index in range(number_of_evaluations - 1, -1, -1):
        label = labels[index]
        new_name = label_model_args(
            name, label, all_labels, [], objective_field)[0]
        evaluation_args = set_evaluation_args(new_name, description, args,
                                              fields, fields_map)
        evaluation_args_list.append(evaluation_args)
    return evaluation_args_list
示例#4
0
def set_label_evaluation_args(name, description, args, labels, all_labels,
                              number_of_evaluations, fields, dataset_fields,
                              fields_map, objective_field):
    """Set of args needed to build an evaluation per label

    """
    if objective_field is None:
        objective_id = fields.field_id(fields.objective_field)
        objective_field = fields.fields[objective_id]['name']
    evaluation_args_list = []

    for index in range(number_of_evaluations - 1, -1, -1):
        label = labels[index]
        new_name = label_model_args(name, label, all_labels, [],
                                    objective_field)[0]
        evaluation_args = set_evaluation_args(new_name, description, args,
                                              fields, dataset_fields,
                                              fields_map)
        evaluation_args_list.append(evaluation_args)
    return evaluation_args_list
示例#5
0
def set_label_model_args(name, description, args, labels, all_labels, fields,
                         model_fields, objective_field):
    """Set of args needed to build a model per label

    """
    if model_fields is None:
        model_fields = []
    else:
        model_fields = relative_input_fields(fields, model_fields)
    if objective_field is None:
        objective_id = fields.field_id(fields.objective_field)
        objective_field = fields.fields[objective_id]['name']
    model_args_list = []

    for index in range(args.number_of_models - 1, -1, -1):
        label = labels[index]
        (new_name, label_field, single_label_fields) = label_model_args(
            name, label, all_labels, model_fields, objective_field)
        model_args = set_model_args(new_name, description, args,
                                    label_field, fields,
                                    single_label_fields)
        model_args_list.append(model_args)
    return model_args_list
示例#6
0
    if not args.model_fields_:
        args.model_fields_ = relative_input_fields(fields, args.model_fields_)
    if args.objective_field is None:
        args.objective_field = fields.objective_field
    try:
        objective_id = fields.field_id(args.objective_field)
    except ValueError, exc:
        sys.exit(exc)
    objective_field = fields.fields[objective_id]['name']
    ensemble_args_list = []

    for index in range(number_of_ensembles - 1, -1, -1):
        label = labels[index]
        all_labels = get_all_labels(multi_label_data)
        (new_name, label_field, single_label_fields) = label_model_args(
            args.name, label, all_labels, args.model_fields_,
            objective_field)
        ensemble_args = set_ensemble_args(args, name=new_name,
                                          objective_id=label_field,
                                          model_fields=single_label_fields,
                                          fields=fields)
        if multi_label_data is not None:
            ensemble_args.update(
                user_metadata={'multi_label_data': multi_label_data})

        ensemble_args_list.append(ensemble_args)
    return ensemble_args_list


def set_ensemble_args(args, name=None,
                      objective_id=None, model_fields=None, fields=None):
示例#7
0
                              number_of_evaluations, fields, dataset_fields,
                              objective_field):
    """Set of args needed to build an evaluation per label

    """
    if objective_field is None:
        try:
            objective_id = fields.field_id(fields.objective_field)
        except ValueError, exc:
            sys.exit(exc)
        objective_field = fields.fields[objective_id]['name']
    evaluation_args_list = []

    for index in range(number_of_evaluations - 1, -1, -1):
        label = labels[index]
        new_name = label_model_args(
            args.name, label, all_labels, [], objective_field)[0]
        evaluation_args = set_evaluation_args(args,
                                              fields=fields,
                                              dataset_fields=dataset_fields,
                                              name=new_name)
        evaluation_args_list.append(evaluation_args)
    return evaluation_args_list


def create_evaluations(model_or_ensemble_ids, datasets, evaluation_args,
                       args, api=None,
                       path=None, session_file=None, log=None,
                       existing_evaluations=0):
    """Create evaluations for a list of models

       ``model_or_ensemble_ids``: list of model or ensemble ids to create