clique / src /synthetic /plot_f1_scores.py
qingy2024's picture
Upload folder using huggingface_hub
bf620c6 verified
import pandas as pd
import matplotlib.pyplot as plt
import sys
def plot_f1_scores(csv_file):
# Read the CSV file
df = pd.read_csv(csv_file)
# Get unique methods
methods = df['Method'].unique()
# Create the plot
plt.figure(figsize=(10, 6))
# Plot each method
for method in methods:
method_data = df[df['Method'] == method]
# Use row index + 1 as x-axis (to start from 1)
x_values = method_data.index + 1
y_values = method_data['F1']
plt.plot(x_values, y_values, marker='o', label=method, linewidth=2, markersize=4)
# Customize the plot
plt.xlabel('Row Number')
plt.ylabel('F1 Score')
plt.title('F1 Scores by Method')
plt.legend()
plt.grid(True, alpha=0.3)
# Show the plot
plt.tight_layout()
plt.show()
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python plot_f1_scores.py <csv_file>")
sys.exit(1)
csv_file = sys.argv[1]
plot_f1_scores(csv_file)