You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

90 lines
2.2 KiB

#!/usr/bin/env
import matplotlib.pyplot as plt
import csv
import math
from decimal import Decimal
import utils.fs
from utils.fs import search_dir
import utils.io
from utils.io import write_csv
import click
@click.group()
@click.pass_context
def graphs(ctx):
'''Create graphs and figures.\f'''
pass
@graphs.command()
@click.pass_context
def efm(ctx):
import natsort
plt.style.use('seaborn-whitegrid')
# x,y axis values
x = []
y = []
result_files = search_dir('resources/fixed-db-test/', '*.csv')
result_values = []
output = []
for result in result_files:
with open(result, 'r') as f:
reader = csv.reader(f, delimiter=' ')
data = list(reader)
evid = data[1][0].split('/')[-1].split('.')[0]
comp = data[1][1]
lr = data[1][2]
y.append(Decimal(lr))
print(evid)
print(comp)
print(lr)
row = [evid, comp, lr]
output.append(row)
output = natsort.natsorted(output, key=lambda x: x[0])
output.insert(0, ['evidence_name', 'comparison_name', 'likelihood_ratio'])
with open('euroformix_pilot.csv', 'w') as f:
writer = csv.writer(f)
writer.writerows(output)
# open & read the csv file
with open('resources/lowest-with-drop.csv','r') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
next(csv_reader)
#loop through all rows. Puts column (0) in x, & column (1) in y.
for i, row in enumerate(csv_reader):
x.append(Decimal(row[0]))
print(len(x))
print(len(y))
x = x[0:1244]
plt.rcParams['axes.facecolor'] = '#ededed'
plt.ticklabel_format(style='sci', axis='x')
plt.ticklabel_format(style='sci', axis='y')
# plotting the points
plt.scatter(x,y, s=0.75, color='black')
# naming the x,y axis
plt.xlabel('LR - Forensic Statistical Tool v1.5 - With CheckFrequencyForRemoval')
plt.ylabel("LR - EuroForMix v2.1.0 - Nate's Settings")
# giving a title to the graph
plt.title('EuroForMix Vs. Forensic Statistical Tool')
# Graph legend
plt.legend()
# function to show the plot
plt.show()