fixes #4 - adds modular analyses system using plugins

This commit is contained in:
2025-02-10 02:12:12 +01:00
parent 59fed26abf
commit e57869374b
22 changed files with 1018 additions and 179 deletions

View File

@@ -0,0 +1,31 @@
import os
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from .basePlotAnalysis import BasePlotAnalysis
from flask import current_app, url_for
import matplotlib
matplotlib.use('Agg')
class PlotPeakHours(BasePlotAnalysis):
name = "Peak Hours Analysis"
description = "Identifies peak activity hours using a bar chart."
plot_filename = "peak_hours.png"
note = ""
def transform_data(self, df: pd.DataFrame) -> pd.DataFrame:
"""Transform data to add was_active column and extract peak hours"""
return df
def plot_data(self, df: pd.DataFrame):
"""Generate bar chart for peak hours"""
peak_hours = df[df["was_active"]]["hour"].value_counts().sort_index()
plt.figure(figsize=(12, 5))
sns.barplot(x=peak_hours.index, y=peak_hours.values, hue=peak_hours.values, palette="coolwarm")
plt.xlabel("Hour of the Day")
plt.ylabel("Activity Count")
plt.title("Peak Hours of User Activity")
plt.xticks(range(0, 24))