import pandas as pd
from fraud_summary import FraudSummary
import matplotlib.pyplot as plt

df = pd.read_csv("synthetic_fraud_dataset.csv")

avg_amount = df["amount"].mean()
fraud_rate = df["is_fraud"].mean()
avg_device_risk = df["device_risk_score"].mean()

summary = FraudSummary(avg_amount, fraud_rate, avg_device_risk)

# print(summary)

# How many transactions occured per hour

amount_by_hour = df.groupby("hour")["amount"].sum()
# print(amount_by_hour)
# plt.plot(amount_by_hour.index, amount_by_hour.values)
# plt.xlabel("Hour of Day")
# plt.ylabel("Total Transactions")
# plt.title("Transactions ocurred per hour")
# plt.show()

# fig , ax = plt.subplots()
# ax.plot(amount_by_hour.index, amount_by_hour.values)
# ax.set_xlabel("Hour of Day")
# ax.set_ylabel("Total Transactions")
# ax.set_title("Transactions ocurred per hour")
# plt.show()

fig, (ax1 , ax2) = plt.subplots(1, 2, figsize = (12, 5))
print(plt.subplots(1,2))

# First figure
ax1.plot(amount_by_hour.index, amount_by_hour.values, color = "blue")
ax1.set_xlabel("Hour of Day")
ax1.set_ylabel("Total Transactions")
ax1.set_title("Transactions ocurred per hour")

# Second figure
count_by_hour = df.groupby("hour")["amount"].count()
ax2.bar(count_by_hour.index, count_by_hour.values, color = "green")
ax2.set_title("Transactions count by hour")
ax2.set_ylabel("Numer of transactions")

# plt.show()