|
|
|
import os |
|
|
|
|
|
import matplotlib.pyplot as plt |
|
|
|
cols = ["precision", "recall", "f1-score", "support"] |
|
|
|
|
|
def generate_plot_by_nikud_dagesh_sin_dict(nikud_dagesh_sin_dict, title, y_axis, plot_folder=None): |
|
|
|
plt.figure(figsize=(8, 6)) |
|
plt.title(title) |
|
|
|
ax = plt.gca() |
|
indexes = list(range(1, len(nikud_dagesh_sin_dict["nikud"]) + 1)) |
|
|
|
|
|
ax.plot(indexes, nikud_dagesh_sin_dict["nikud"], color='blue', label='Nikud') |
|
ax.plot(indexes, nikud_dagesh_sin_dict["dagesh"], color='green', label='Dagesh') |
|
ax.plot(indexes, nikud_dagesh_sin_dict["sin"], color='red', label='Sin') |
|
|
|
|
|
ax.legend() |
|
|
|
|
|
ax.set_xlabel('Epoch') |
|
ax.set_ylabel(y_axis) |
|
|
|
if plot_folder is None: |
|
plt.show() |
|
else: |
|
plt.savefig(os.path.join(plot_folder, f'{title.replace(" ", "_")}_plot.jpg')) |
|
|
|
|
|
def generate_word_and_letter_accuracy_plot(word_and_letter_accuracy_dict, title, plot_folder=None): |
|
|
|
plt.figure(figsize=(8, 6)) |
|
plt.title(title) |
|
|
|
ax = plt.gca() |
|
indexes = list(range(1, len(word_and_letter_accuracy_dict["all_nikud_letter"]) + 1)) |
|
|
|
|
|
ax.plot(indexes, word_and_letter_accuracy_dict["all_nikud_letter"], color='blue', label='Letter') |
|
ax.plot(indexes, word_and_letter_accuracy_dict["all_nikud_word"], color='green', label='Word') |
|
|
|
|
|
ax.legend() |
|
|
|
|
|
ax.set_xlabel("Epoch") |
|
ax.set_ylabel("Accuracy") |
|
|
|
if plot_folder is None: |
|
plt.show() |
|
else: |
|
plt.savefig(os.path.join(plot_folder, 'word_and_letter_accuracy_plot.jpg')) |
|
|