-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d3e5a7
commit 98bb930
Showing
7 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
|
||
# Function to create line graph and save it for each file | ||
def create_line_graph(file_path): | ||
# Read CSV file | ||
df = pd.read_csv(file_path, parse_dates=['Date']) | ||
|
||
# Extract data | ||
date = df['Date'] | ||
prediction = df['Prediction'] | ||
actual = df['Actual'] | ||
|
||
# Plot line graph | ||
plt.figure(figsize=(10, 6)) | ||
plt.plot(date, prediction, label='Prediction', marker='o') | ||
plt.plot(date, actual, label='Actual', marker='o') | ||
|
||
# Add title and labels | ||
file_name = os.path.splitext(os.path.basename(file_path))[0] | ||
plt.title(f'{file_name} - Prediction vs Actual') | ||
plt.xlabel('Date') | ||
plt.ylabel('Value') | ||
|
||
# Rotate x-axis labels for better readability | ||
plt.xticks(rotation=45) | ||
|
||
# Add legend | ||
plt.legend() | ||
|
||
# Save graph as image file | ||
file_name = file_name + '_line_graph.png' | ||
plt.savefig(file_name, bbox_inches='tight') # Adjusted to fit the date in the picture | ||
plt.close() | ||
|
||
# Directory path containing CSV files | ||
directory_path = 'metricdata' | ||
|
||
# Iterate over files in directory | ||
for file in os.listdir(directory_path): | ||
if file.endswith('.csv'): | ||
file_path = os.path.join(directory_path, file) | ||
create_line_graph(file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters