File size: 1,030 Bytes
bf620c6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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) |