def get_combained_values(truth_list, result_list):
    combained_values = []
    for truth, result in zip(truth_list, result_list):
        t_truth = [datetime.datetime.strptime(truth_point, '%Y-%m-%d %H:%M:%S') for truth_point in truth[0]]
        dict_item = {'GT': [t_truth, truth[1]],
                     'LS': result}
        combained_values.append(dict_item)
    combained_values = cook_raw_value(combained_values)

    return combained_values
예제 #2
0
    delta = timedelta(seconds=0)
    while delta <= delta_max:
        f_init.update({delta: f})
        f += f_item
        delta += t_item
    for s in observed_keys:
        cef = [c, e, f_init]
        cef_measures.update({s: cef})

    return cef_measures


if __name__ == '__main__':
    ground_truth = ['Wisc', 'MSR']

    observed_cases = cook_raw_value(get_observed_cases())

    for case_number, observed in enumerate(observed_cases):
        observed_keys = sorted(observed.keys())
        cef_measures = cef_initialization(c=0.5, e=0.5, observed=observed)

        iter_quantity = 0
        sources_number = len(observed_keys)
        life_span = get_life_span(observed=observed, cef_measures=cef_measures)

        # print initial info
        print 'CASE NUMBER: {}'.format(case_number)
        print 'Ground truth: {}'.format(ground_truth)
        for key in observed_keys:
            print '{}: {}'.format(key, observed.get(key)[1])
        print 'Initial life span: {}'.format(life_span)
예제 #3
0
        "S2.C",
        "S2.E",
        "S2.F, days",
        "S3.C",
        "S3.E",
        "S3.F, days",
        "S4.C",
        "S4.E",
        "S4.F, days",
        "S5.C",
        "S5.E",
        "S5.F, days",
    ]
    # ground_truth = ['Wisc', 'MSR']
    raw_cases = get_observed_cases()
    observed_cases = cook_raw_value(raw_cases)
    observed_keys = sorted(observed_cases[0].keys())
    cef_measures = cef_initialization(c=0.99, e=0.95, observed=observed_cases[0])
    set_of_life_spans = []
    sources_number = len(observed_keys)
    cases_number = len(observed_cases)

    iter_quantity = 0
    data_for_csv = {}
    for case_number, observed in enumerate(observed_cases):
        life_span = get_life_span(observed=observed, cef_measures=cef_measures)
        set_of_life_spans.append(life_span)

        # print initial info
        print "OBJECT NUMBER: {}".format(case_number)
        # print 'Ground truth: {}'.format(ground_truth)
예제 #4
0
    delta = timedelta(seconds=0)
    while delta <= delta_max:
        f_init.update({delta: f})
        f += f_item
        delta += t_item
    for s in observed_keys:
        cef = [c, e, f_init]
        cef_measures.update({s: cef})

    return cef_measures


if __name__ == '__main__':
    ground_truth = ['Wisc', 'MSR']

    observed_cases = cook_raw_value(get_observed_cases())

    for case_number, observed in enumerate(observed_cases):
        observed_keys = sorted(observed.keys())
        cef_measures = cef_initialization(c=0.5, e=0.5, observed=observed)

        iter_quantity = 0
        sources_number = len(observed_keys)
        life_span = get_life_span(observed=observed, cef_measures=cef_measures)

        # print initial info
        print 'CASE NUMBER: {}'.format(case_number)
        print 'Ground truth: {}'.format(ground_truth)
        for key in observed_keys:
            print '{}: {}'.format(key, observed.get(key)[1])
        print 'Initial life span: {}'.format(life_span)
def get_CEF(life_span_set, sources_data):
    """
    :param O:
    :param S:
    :return:
    cl(S,O): capturable
    c(S,O): captured
    ml(S,O): mis-capturable
    m(S,O): mis-captured
    covg: coverage
    exac: exactness
    fresh: freshness
    """
    cl = c = ml = m = 0
    data_for_freshness = []
    for s_life_span, s_data in zip(life_span_set, sources_data):
        synchronised_values = cook_raw_value([{'O': s_life_span, 'S': s_data}])[0]
        O = synchronised_values.get('O')[1]
        S = synchronised_values.get('S')[1]
        s_time_points = synchronised_values.get('S')[0]
        N = len(s_time_points)
        for i in range(N-1):
            if O[i] == S[i] and i == 0:
                c += 1
                cl += 1
                ml += 1
                data_for_freshness.append(timedelta(seconds=0))
            elif O[i] == S[i] and O[i] != O[i-1] and S[i] != S[i-1]:
                c += 1
                cl += 1
                ml += 1
                data_for_freshness.append(timedelta(seconds=0))

            ml += 1
            if O[i] != S[i]:
                cl += 1
                if O[i+1] == S[i+1]:
                    c += 1
                    data_for_freshness.append(s_time_points[i+1]-s_time_points[i])
                elif O[i+1] != S[i+1]:
                    m += 1

            if O[i] == S[i] and O[i+1] != S[i+1]:
                m += 1
        if O[0] != S[0]:
            cl += 1
            ml += 1
            m += 1
        if O[N-1] == S[N-1] and O[N-1] != O[N-2] and S[N-1] != S[N-2]:
                c += 1
                cl += 1
                ml += 1
                data_for_freshness.append(timedelta(seconds=0))
        ml += 1
        if O[N-1] != S[N-1]:
            cl += 1

    c = float(c)
    exac = 1 - float(m)/ml
    covg = float(c)/cl
    delta_for_freshness = sorted(list(set(data_for_freshness)))
    fresh = {timedelta(seconds=0): 0.0}
    for delta in delta_for_freshness:
        c_delta = len([k for k in data_for_freshness if delta >= k])
        fresh_delta = c_delta/c
        fresh.update({delta: fresh_delta})

    return [covg, exac, fresh]