Enhance API with data loading functionality and update README.

- Added `/load-data` endpoint to load transaction data from either a database or a CSV file.
- Updated `SalaryAnalyticsPipeline` and `DataLoader` to support loading from CSV.
- Implemented data validation and error handling for loading processes.
- Revised README to include new data loading instructions and workflow steps.
- Added checks to ensure data is loaded before running analysis endpoints.
This commit is contained in:
2025-05-01 22:57:55 +01:00
parent 7e7094f0fd
commit 8acfb436f3
12 changed files with 205 additions and 29 deletions
+10 -4
View File
@@ -40,12 +40,18 @@ class ConsistentAmountAnalyzer:
if cv_threshold is None:
cv_threshold = MODEL_CONFIG['cv_threshold']
self.df = self.df.groupby('accountid').apply(
# Create a copy of the original DataFrame
self.const_df = self.df.copy()
# Calculate consistent amount flags
consistent_flags = self.const_df.groupby('accountid').apply(
lambda group: self.flag_consistent_amounts(group, cv_threshold)
).reset_index(level=0, drop=True)
self.const_df = self.df.copy()
return self.df
# Add the flags to the original DataFrame
self.const_df['is_consistent_amount'] = consistent_flags
return self.const_df
def get_consistent_amount_data(self):
"""Get transactions identified as having consistent amounts."""