Skip to content
Snippets Groups Projects
Commit fe7e0de0 authored by Julien Breton's avatar Julien Breton
Browse files

graph and evolution

parent 13b8222b
Branches
Tags
No related merge requests found
# libraries # libraries
import json import json
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
......
import json
import numpy as np
import matplotlib.pyplot as plt
def graph_system_evolution_eval(ref_path, new_path, title, output_path):
bars = [[], [], []]
for i in range(len(ref_path)):
sum_perfect_equals = 0
sum_subpart = 0
sum_miss_classification = 0
sum_hallucination = 0
with open(new_path[i]) as file:
data = json.load(file)
data = data["break_down"]
for tag, values in data.items():
sum_perfect_equals += values['perfect_equals']
sum_subpart += values['subpart']
sum_miss_classification += values['miss_classification']
sum_hallucination += values['hallucination']
with open(ref_path[i]) as file:
data = json.load(file)
data = data["break_down"]
for tag, values in data.items():
sum_perfect_equals -= values['perfect_equals']
sum_subpart -= values['subpart']
sum_miss_classification -= values['miss_classification']
sum_hallucination -= values['hallucination']
bars[i].append(sum_perfect_equals)
bars[i].append(sum_subpart)
bars[i].append(sum_miss_classification)
bars[i].append(sum_hallucination)
# set width of bars
barWidth = 0.25
# Set position of bar on X axis
r1 = np.arange(len(bars[0]))
r2 = [x + barWidth for x in r1]
r3 = [x + barWidth for x in r2]
# Make the plot
plt.bar(r1, bars[0], color='#75ac9d', width=barWidth, edgecolor='white', label='GPT-4')
plt.bar(r2, bars[1], color='#fca301', width=barWidth, edgecolor='white', label='Mixtral-8x7b')
plt.bar(r3, bars[2], color='#5619d8', width=barWidth, edgecolor='white', label='Mistral-7b')
# Add xticks on the middle of the group bars
plt.ylabel('Number of predicate')
plt.xlabel(title, fontweight='bold')
plt.xticks([r + barWidth for r in range(len(bars[0]))], ['Perfect equals', 'Subpart', 'Miss classification', 'Others'])
# Create legend & Show graphic
plt.legend()
plt.savefig(output_path)
bars1_path_ref = "../../results/LLM/GPT-4/GPT-4_zero_shot_results.json"
bars2_path_ref = "../../results/LLM/Mixtral-8x7b/MIXTRAL_zero_shot_results.json"
bars3_path_ref = "../../results/LLM/Mistral-7b/MISTRAL_zero_shot_results.json"
bars1_path_new = "../../results/LLM/GPT-4/GPT-4_few_shot_results.json"
bars2_path_new = "../../results/LLM/Mixtral-8x7b/MIXTRAL_few_shot_results.json"
bars3_path_new = "../../results/LLM/Mistral-7b/MISTRAL_few_shot_results.json"
title = "Evolution from Zero-shot to Few-shot predicate extraction"
output_path = "../../results/LLM/zero_shot_to_few_shot_evolution.png"
paths_ref = [bars1_path_ref, bars2_path_ref, bars3_path_ref]
paths_new = [bars1_path_new, bars2_path_new, bars3_path_new]
graph_system_evolution_eval(paths_ref, paths_new, title, output_path)
\ No newline at end of file
results/LLM/zero_shot_to_few_shot_evolution.png

26 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment