示例#1
0
def lbd_actual_and_predicted_values(input_dict):
    bterms = input_dict['bterms']
    bow_model_constructor = input_dict['bow_model_constructor']
    vocabulary = bow_model_constructor._vocab_to_idx()

    actual_values = [0] * len(vocabulary)
    for bterm in bterms:
        if bterm in vocabulary:
            actual_values[vocabulary[bterm]] = 1
            #print bterm

    heuristics = flatten(input_dict['heuristics'])

    return {
        'apv': [{
            'name': h.name,
            'predicted': list(h.scores),
            'actual': actual_values
        } for h in heuristics]
    }
示例#2
0
def lbd_select_ensemble_heuristic_post(postdata, input_dict, output_dict):
    widget_id = postdata.get('widget_id')[0]

    from workflows.textflows_dot_net.serialization_utils import ToNetObj
    import LatinoInterfaces
    output_dict = {}
    output_dict['serialized_adc'] = LatinoInterfaces.LatinoCF.Save(
        ToNetObj(input_dict['adc']))
    output_dict['vocabulary'] = input_dict[
        'bow_model_constructor'].get_feature_names()
    output_dict['heuristic_scores'] = [{
        'name': hevr.name,
        'scores': hevr.scores.tolist()
    } for hevr in flatten(input_dict['heuristic_scores'])]
    output_dict['bterms'] = input_dict['bterms']
    output_dict['serialized_dataset'] = LatinoInterfaces.LatinoCF.Save(
        ToNetObj(input_dict['dataset']))
    #output_dict['primary_heuristic_index']=input_dict['primary_heuristic_index']

    output_dict['primary_heuristic_index'] = int(
        postdata.get('heuristic_index', [-1])[0])

    return output_dict  #{'heuristic_index': selected_heuristic}
示例#3
0
def lbd_heuristic_min(input_dict):
    heuristic_names = flatten(input_dict.get('heuristics', []))
    return {'heuristic': ('Min', heuristic_names)}
示例#4
0
def lbd_ensemble_average_position(input_dict):
    heuristic_names = flatten(input_dict['heuristics'])
    return {'heuristic': ('AvgPos', heuristic_names)}
示例#5
0
def lbd_ensemble_heuristic_vote(input_dict):
    heuristic_names = flatten(input_dict['heuristics'])
    return {'heuristic': ('Vote', heuristic_names)}
示例#6
0
def lbd_heuristic_norm(input_dict):
    heuristic_names = flatten(input_dict.get('heuristics', []))
    return {
        'norm_heuristics':
        [('Norm', heuristic_name) for heuristic_name in heuristic_names]
    }
示例#7
0
def lbd_heuristic_sum(input_dict):
    heuristic_names = flatten(input_dict.get('heuristics', []))
    return {'heuristic': ('Sum', heuristic_names)}
示例#8
0
def lbd_select_ensemble_heuristic(request, input_dict, output_dict, widget):
    heuristics = [h.name for h in flatten(input_dict['heuristic_scores'])]
    return render(request, 'interactions/lbd_select_ensemble_heuristic.html', {
        'heuristics': heuristics,
        'widget': widget
    })