Пример #1
0
def circle_results(file):
    t = PrettyTable(['Description', 'Total', 'True Pos.', 'False Pos.', 'True Neg.', 'False Neg.', 'Precision', 'Sensitivity',
                     'Dice Coeff.', 'Jaccard Ind.', 'Jaccard Dist.'])
    f = open(file, 'r')
    for line in f:
        totals = line.split()
        description = totals[0]
        tp = totals[1]
        fp = totals[2]
        tn = totals[3]
        fn = totals[4]
        total = int(tp) + int(fp) + int(tn) + int(fn)
        precision = evaluation.precision(tp, fp)
        sensitivity = evaluation.sensitivity(tp, fn)
        # fmeasure = evaluation.fmeasure(tp, fp, fn)
        dicecoeff = evaluation.dicecoeff(tp, fp, fn)
        jaccardindex = evaluation.jaccardindex(tp, fp, fn)
        jaccarddifference = 1 - jaccardindex
        t.add_row([description, str(total), str(tp), str(fp), str(tn), str(fn), str(precision), str(sensitivity), str(dicecoeff),
                  str(jaccardindex), str(jaccarddifference)])

    print "Circle Detection\n"
    print t

    now = "\n" + str(datetime.now()) + "\n"
    data = t.get_string()
    r = open('circle_test_results.txt', 'ab')
    r.write(now)
    r.write(data)
    r.write("\n")
    r.close()
Пример #2
0
    f = open(file, 'r')
    for line in f:
        lines += 1
        totals = line.split()
        # totals[0] is image name
        tp += int(totals[1])
        fp += int(totals[2])
        tn += int(totals[3])
        fn += int(totals[4])
    f.close()

    precision = evaluation.precision(tp, fp)
    sensitivity = evaluation.sensitivity(tp, fn)
    fmeasure = evaluation.fmeasure(tp, fp, fn)
    dicecoeff = evaluation.dicecoeff(tp, fp, fn)
    jaccardindex = evaluation.jaccardindex(tp, fp, fn)

    r = open('circle_found_results.txt', 'a')
    r.write('File name: ' + file + '\n')
    r.write('Lines: ' + str(lines) + '\n')
    r.write('True Positives: ' + str(tp) + '\n')
    r.write('False Positives: ' + str(fp) + '\n')
    r.write('True Negatives: ' + str(tn) + '\n')
    r.write('False Negatives: ' + str(fn) + '\n')
    r.write('Precision: ' + str(precision) + '\n')
    r.write('Sensitivity: ' + str(sensitivity) + '\n')
    r.write('F-Measure: ' + str(fmeasure) + '\n')
    r.write('Dice Coefficent: ' + str(dicecoeff) + '\n')
    r.write('Jaccard Index: ' + str(jaccardindex) + '\n' + '\n')
    r.close()
Пример #3
0
    fn = 0

    f = open(file, 'r')
    for line in f:
        lines += 1
        totals = line.split()
        tp += int(totals[0])
        fp += int(totals[1])
        tn += int(totals[2])
        fn += int(totals[3])
    f.close()

    precision = evaluation.precision(tp, fp)
    sensitivity = evaluation.sensitivity(tp, fn)
    fmeasure = evaluation.fmeasure(tp, fp, fn)
    dicecoeff = evaluation.dicecoeff(tp, fp, fn)
    jaccardindex = evaluation.jaccardindex(tp, fp, fn)

    r = open('circle_found_results.txt', 'a')
    r.write('File name: ' + file + '\n')
    r.write('Lines: ' + str(lines) + '\n')
    r.write('True Positives: ' + str(tp) + '\n')
    r.write('False Positives: ' + str(fp) + '\n')
    r.write('True Negatives: ' + str(tn) + '\n')
    r.write('False Negatives: ' + str(fn) + '\n')
    r.write('Precision: ' + str(precision) + '\n')
    r.write('Sensitivity: ' + str(sensitivity) + '\n')
    r.write('F-Measure: ' + str(fmeasure) + '\n')
    r.write('Dice Coefficent: ' + str(dicecoeff) + '\n')
    r.write('Jaccard Index: ' + str(jaccardindex) + '\n' + '\n')
    r.close()