Spaces:
Runtime error
Runtime error
Upload 18 files
Browse files- .replit +40 -0
- app.py +997 -0
- conversation_handler.py +312 -0
- data_processor.py +178 -0
- expense_categorizer.py +195 -0
- financial_calendar.py +421 -0
- financial_health.py +354 -0
- goal_tracker.py +349 -0
- predictive_analytics.py +305 -0
- pyproject.toml +1135 -0
- replit.md +70 -0
- requirements.txt +48 -0
- sample_transactions.csv +54 -0
- smart_alerts.py +301 -0
- utils.py +278 -0
- uv.lock +0 -0
- vector_store.py +242 -0
- visualizations.py +303 -0
.replit
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
modules = ["python-3.11"]
|
| 2 |
+
|
| 3 |
+
[nix]
|
| 4 |
+
channel = "stable-25_05"
|
| 5 |
+
packages = ["bash", "glibcLocales"]
|
| 6 |
+
|
| 7 |
+
[deployment]
|
| 8 |
+
deploymentTarget = "autoscale"
|
| 9 |
+
run = ["streamlit", "run", "app.py", "--server.port", "5000"]
|
| 10 |
+
|
| 11 |
+
[workflows]
|
| 12 |
+
runButton = "Project"
|
| 13 |
+
|
| 14 |
+
[[workflows.workflow]]
|
| 15 |
+
name = "Project"
|
| 16 |
+
mode = "parallel"
|
| 17 |
+
author = "agent"
|
| 18 |
+
|
| 19 |
+
[[workflows.workflow.tasks]]
|
| 20 |
+
task = "workflow.run"
|
| 21 |
+
args = "Finance Assistant"
|
| 22 |
+
|
| 23 |
+
[[workflows.workflow]]
|
| 24 |
+
name = "Finance Assistant"
|
| 25 |
+
author = "agent"
|
| 26 |
+
|
| 27 |
+
[[workflows.workflow.tasks]]
|
| 28 |
+
task = "shell.exec"
|
| 29 |
+
args = "streamlit run app.py --server.port 5000"
|
| 30 |
+
waitForPort = 5000
|
| 31 |
+
|
| 32 |
+
[workflows.workflow.metadata]
|
| 33 |
+
outputType = "webview"
|
| 34 |
+
|
| 35 |
+
[[ports]]
|
| 36 |
+
localPort = 5000
|
| 37 |
+
externalPort = 80
|
| 38 |
+
|
| 39 |
+
[agent]
|
| 40 |
+
integrations = ["python_openai==1.0.0"]
|
app.py
ADDED
|
@@ -0,0 +1,997 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
import plotly.graph_objects as go
|
| 5 |
+
import numpy as np
|
| 6 |
+
from datetime import datetime, timedelta, date
|
| 7 |
+
import os
|
| 8 |
+
from typing import List, Dict, Any
|
| 9 |
+
import json
|
| 10 |
+
|
| 11 |
+
from data_processor import DataProcessor
|
| 12 |
+
from expense_categorizer import ExpenseCategorizer
|
| 13 |
+
from vector_store import VectorStore
|
| 14 |
+
from conversation_handler import ConversationHandler
|
| 15 |
+
from visualizations import FinanceVisualizer
|
| 16 |
+
from utils import format_currency, validate_file
|
| 17 |
+
from financial_health import FinancialHealthAnalyzer
|
| 18 |
+
from predictive_analytics import PredictiveAnalytics
|
| 19 |
+
from smart_alerts import SmartAlertsSystem
|
| 20 |
+
from goal_tracker import GoalTracker
|
| 21 |
+
from financial_calendar import FinancialCalendar
|
| 22 |
+
|
| 23 |
+
# Configure Streamlit page
|
| 24 |
+
st.set_page_config(
|
| 25 |
+
page_title="AI Finance Assistant",
|
| 26 |
+
page_icon="💰",
|
| 27 |
+
layout="wide",
|
| 28 |
+
initial_sidebar_state="expanded"
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# Initialize session state
|
| 32 |
+
if 'data_processor' not in st.session_state:
|
| 33 |
+
st.session_state.data_processor = DataProcessor()
|
| 34 |
+
if 'categorizer' not in st.session_state:
|
| 35 |
+
st.session_state.categorizer = ExpenseCategorizer()
|
| 36 |
+
if 'vector_store' not in st.session_state:
|
| 37 |
+
st.session_state.vector_store = VectorStore()
|
| 38 |
+
if 'conversation_handler' not in st.session_state:
|
| 39 |
+
st.session_state.conversation_handler = ConversationHandler()
|
| 40 |
+
if 'visualizer' not in st.session_state:
|
| 41 |
+
st.session_state.visualizer = FinanceVisualizer()
|
| 42 |
+
if 'health_analyzer' not in st.session_state:
|
| 43 |
+
st.session_state.health_analyzer = FinancialHealthAnalyzer()
|
| 44 |
+
if 'predictive_analytics' not in st.session_state:
|
| 45 |
+
st.session_state.predictive_analytics = PredictiveAnalytics()
|
| 46 |
+
if 'smart_alerts' not in st.session_state:
|
| 47 |
+
st.session_state.smart_alerts = SmartAlertsSystem()
|
| 48 |
+
if 'goal_tracker' not in st.session_state:
|
| 49 |
+
st.session_state.goal_tracker = GoalTracker()
|
| 50 |
+
if 'financial_calendar' not in st.session_state:
|
| 51 |
+
st.session_state.financial_calendar = FinancialCalendar()
|
| 52 |
+
if 'transactions_df' not in st.session_state:
|
| 53 |
+
st.session_state.transactions_df = None
|
| 54 |
+
if 'chat_history' not in st.session_state:
|
| 55 |
+
st.session_state.chat_history = []
|
| 56 |
+
if 'user_goals' not in st.session_state:
|
| 57 |
+
st.session_state.user_goals = []
|
| 58 |
+
if 'budgets' not in st.session_state:
|
| 59 |
+
st.session_state.budgets = {}
|
| 60 |
+
|
| 61 |
+
def main():
|
| 62 |
+
# Enhanced header with branding
|
| 63 |
+
st.markdown("""
|
| 64 |
+
<div style='text-align: center; padding: 20px; background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); border-radius: 10px; margin-bottom: 30px;'>
|
| 65 |
+
<h1 style='color: white; margin: 0; font-size: 3em;'>🚀 FinancePilot</h1>
|
| 66 |
+
<h3 style='color: white; margin: 0; font-weight: 300;'>Your AI-Powered Financial Co-Pilot</h3>
|
| 67 |
+
<p style='color: white; margin: 10px 0 0 0; opacity: 0.9;'>Transform your financial data into actionable insights with next-level AI</p>
|
| 68 |
+
</div>
|
| 69 |
+
""", unsafe_allow_html=True)
|
| 70 |
+
|
| 71 |
+
# Feature highlights
|
| 72 |
+
if st.session_state.transactions_df is None:
|
| 73 |
+
st.markdown("""
|
| 74 |
+
<div style='text-align: center; margin: 30px 0;'>
|
| 75 |
+
<h2>🌟 Revolutionary Features</h2>
|
| 76 |
+
</div>
|
| 77 |
+
""", unsafe_allow_html=True)
|
| 78 |
+
|
| 79 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 80 |
+
|
| 81 |
+
with col1:
|
| 82 |
+
st.markdown("""
|
| 83 |
+
<div style='text-align: center; padding: 20px; border: 2px solid #667eea; border-radius: 10px; margin: 10px;'>
|
| 84 |
+
<h3>🏥</h3>
|
| 85 |
+
<h4>Health Score</h4>
|
| 86 |
+
<p>AI-powered financial wellness scoring</p>
|
| 87 |
+
</div>
|
| 88 |
+
""", unsafe_allow_html=True)
|
| 89 |
+
|
| 90 |
+
with col2:
|
| 91 |
+
st.markdown("""
|
| 92 |
+
<div style='text-align: center; padding: 20px; border: 2px solid #667eea; border-radius: 10px; margin: 10px;'>
|
| 93 |
+
<h3>🔮</h3>
|
| 94 |
+
<h4>Predictions</h4>
|
| 95 |
+
<p>Future spending forecasts & trends</p>
|
| 96 |
+
</div>
|
| 97 |
+
""", unsafe_allow_html=True)
|
| 98 |
+
|
| 99 |
+
with col3:
|
| 100 |
+
st.markdown("""
|
| 101 |
+
<div style='text-align: center; padding: 20px; border: 2px solid #667eea; border-radius: 10px; margin: 10px;'>
|
| 102 |
+
<h3>🚨</h3>
|
| 103 |
+
<h4>Smart Alerts</h4>
|
| 104 |
+
<p>Proactive spending notifications</p>
|
| 105 |
+
</div>
|
| 106 |
+
""", unsafe_allow_html=True)
|
| 107 |
+
|
| 108 |
+
with col4:
|
| 109 |
+
st.markdown("""
|
| 110 |
+
<div style='text-align: center; padding: 20px; border: 2px solid #667eea; border-radius: 10px; margin: 10px;'>
|
| 111 |
+
<h3>🎯</h3>
|
| 112 |
+
<h4>Goal Tracking</h4>
|
| 113 |
+
<p>Personalized savings strategies</p>
|
| 114 |
+
</div>
|
| 115 |
+
""", unsafe_allow_html=True)
|
| 116 |
+
|
| 117 |
+
# Enhanced sidebar with branding
|
| 118 |
+
with st.sidebar:
|
| 119 |
+
# Sidebar Branding Header
|
| 120 |
+
st.markdown("""
|
| 121 |
+
<div style='text-align: center; padding: 20px; background: linear-gradient(45deg, #667eea, #764ba2); border-radius: 10px; margin-bottom: 25px;'>
|
| 122 |
+
<h2 style='color: white; margin: 0; font-size: 1.8em;'>🚀 FinancePilot</h2>
|
| 123 |
+
<p style='color: white; margin: 5px 0 0 0; opacity: 0.9; font-size: 0.9em;'>Control Center</p>
|
| 124 |
+
</div>
|
| 125 |
+
""", unsafe_allow_html=True)
|
| 126 |
+
|
| 127 |
+
# Data Upload Section
|
| 128 |
+
st.markdown("""
|
| 129 |
+
<div style='text-align: center; padding: 15px; background: linear-gradient(45deg, #4facfe, #00f2fe); border-radius: 10px; margin-bottom: 20px;'>
|
| 130 |
+
<h4 style='color: white; margin: 0;'>📁 Data Upload</h4>
|
| 131 |
+
<p style='color: white; margin: 0; font-size: 0.9em;'>CSV & Excel supported</p>
|
| 132 |
+
</div>
|
| 133 |
+
""", unsafe_allow_html=True)
|
| 134 |
+
uploaded_file = st.file_uploader(
|
| 135 |
+
"Upload your bank statement",
|
| 136 |
+
type=['csv', 'xlsx', 'xls'],
|
| 137 |
+
help="Upload CSV or Excel files with transaction data"
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
if uploaded_file is not None:
|
| 141 |
+
if validate_file(uploaded_file):
|
| 142 |
+
with st.spinner("Processing your financial data..."):
|
| 143 |
+
# Process the uploaded file
|
| 144 |
+
df = st.session_state.data_processor.load_file(uploaded_file)
|
| 145 |
+
|
| 146 |
+
if df is not None:
|
| 147 |
+
# Categorize expenses
|
| 148 |
+
df_categorized = st.session_state.categorizer.categorize_transactions(df)
|
| 149 |
+
|
| 150 |
+
# Store in vector database
|
| 151 |
+
st.session_state.vector_store.add_transactions(df_categorized)
|
| 152 |
+
|
| 153 |
+
# Update session state
|
| 154 |
+
st.session_state.transactions_df = df_categorized
|
| 155 |
+
|
| 156 |
+
st.success(f"✅ Processed {len(df_categorized)} transactions!")
|
| 157 |
+
|
| 158 |
+
# Display basic stats
|
| 159 |
+
st.subheader("📊 Quick Stats")
|
| 160 |
+
total_transactions = len(df_categorized)
|
| 161 |
+
total_amount = df_categorized['amount'].sum()
|
| 162 |
+
avg_transaction = df_categorized['amount'].mean()
|
| 163 |
+
|
| 164 |
+
st.metric("Total Transactions", total_transactions)
|
| 165 |
+
st.metric("Total Amount", format_currency(total_amount))
|
| 166 |
+
st.metric("Average Transaction", format_currency(avg_transaction))
|
| 167 |
+
|
| 168 |
+
# Gamification elements
|
| 169 |
+
st.markdown("---")
|
| 170 |
+
st.markdown("### 🏆 Your Achievements")
|
| 171 |
+
|
| 172 |
+
# Calculate achievements
|
| 173 |
+
categories = len(df_categorized['category'].unique()) if 'category' in df_categorized.columns else 0
|
| 174 |
+
months_tracked = len(df_categorized['month_year'].unique()) if 'month_year' in df_categorized.columns else 0
|
| 175 |
+
|
| 176 |
+
# Achievement badges
|
| 177 |
+
achievements = []
|
| 178 |
+
if total_transactions >= 100:
|
| 179 |
+
achievements.append("🥇 Transaction Master")
|
| 180 |
+
elif total_transactions >= 50:
|
| 181 |
+
achievements.append("🥈 Data Enthusiast")
|
| 182 |
+
elif total_transactions >= 10:
|
| 183 |
+
achievements.append("🥉 Getting Started")
|
| 184 |
+
|
| 185 |
+
if categories >= 8:
|
| 186 |
+
achievements.append("🎨 Category Expert")
|
| 187 |
+
elif categories >= 5:
|
| 188 |
+
achievements.append("📊 Category Tracker")
|
| 189 |
+
|
| 190 |
+
if months_tracked >= 6:
|
| 191 |
+
achievements.append("📅 Long-term Planner")
|
| 192 |
+
elif months_tracked >= 3:
|
| 193 |
+
achievements.append("⏰ Consistent Tracker")
|
| 194 |
+
|
| 195 |
+
for achievement in achievements:
|
| 196 |
+
st.success(achievement)
|
| 197 |
+
|
| 198 |
+
# Progress to next level
|
| 199 |
+
st.markdown("### 📈 Level Progress")
|
| 200 |
+
if total_transactions < 100:
|
| 201 |
+
progress = total_transactions / 100
|
| 202 |
+
st.progress(progress)
|
| 203 |
+
st.caption(f"{100 - total_transactions} more transactions to Master level!")
|
| 204 |
+
else:
|
| 205 |
+
st.balloons()
|
| 206 |
+
st.success("🎉 Master level achieved!")
|
| 207 |
+
else:
|
| 208 |
+
st.error("❌ Invalid file format or structure")
|
| 209 |
+
|
| 210 |
+
# Main content area
|
| 211 |
+
if st.session_state.transactions_df is not None:
|
| 212 |
+
df = st.session_state.transactions_df
|
| 213 |
+
|
| 214 |
+
# Create tabs with better organization and flow
|
| 215 |
+
tab0, tab1, tab2, tab3, tab4, tab5, tab6, tab7, tab8 = st.tabs([
|
| 216 |
+
"🏠 Dashboard",
|
| 217 |
+
"💬 AI Chat",
|
| 218 |
+
"📈 Analytics",
|
| 219 |
+
"🔍 Explorer",
|
| 220 |
+
"🏥 Health",
|
| 221 |
+
"🔮 Predictions",
|
| 222 |
+
"🚨 Alerts",
|
| 223 |
+
"🎯 Goals",
|
| 224 |
+
"📅 Calendar"
|
| 225 |
+
])
|
| 226 |
+
|
| 227 |
+
with tab0:
|
| 228 |
+
# MAIN DASHBOARD - Overview of everything
|
| 229 |
+
st.markdown("""
|
| 230 |
+
<div style='text-align: center; margin-bottom: 30px;'>
|
| 231 |
+
<h2 style='color: #667eea;'>📊 Financial Dashboard</h2>
|
| 232 |
+
<p style='color: #666; font-size: 1.1em;'>Your complete financial overview at a glance</p>
|
| 233 |
+
</div>
|
| 234 |
+
""", unsafe_allow_html=True)
|
| 235 |
+
|
| 236 |
+
# Quick Stats Cards
|
| 237 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 238 |
+
|
| 239 |
+
# Calculate key metrics
|
| 240 |
+
total_transactions = len(df)
|
| 241 |
+
total_spending = abs(df[df['amount'] < 0]['amount'].sum())
|
| 242 |
+
total_income = df[df['amount'] > 0]['amount'].sum()
|
| 243 |
+
net_worth = total_income - total_spending
|
| 244 |
+
|
| 245 |
+
with col1:
|
| 246 |
+
st.markdown("""
|
| 247 |
+
<div style='background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 20px; border-radius: 10px; text-align: center; margin: 5px;'>
|
| 248 |
+
<h3 style='color: white; margin: 0;'>💳</h3>
|
| 249 |
+
<h2 style='color: white; margin: 10px 0;'>{}</h2>
|
| 250 |
+
<p style='color: white; margin: 0; opacity: 0.9;'>Total Transactions</p>
|
| 251 |
+
</div>
|
| 252 |
+
""".format(total_transactions), unsafe_allow_html=True)
|
| 253 |
+
|
| 254 |
+
with col2:
|
| 255 |
+
st.markdown("""
|
| 256 |
+
<div style='background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); padding: 20px; border-radius: 10px; text-align: center; margin: 5px;'>
|
| 257 |
+
<h3 style='color: white; margin: 0;'>💸</h3>
|
| 258 |
+
<h2 style='color: white; margin: 10px 0;'>{}</h2>
|
| 259 |
+
<p style='color: white; margin: 0; opacity: 0.9;'>Total Spending</p>
|
| 260 |
+
</div>
|
| 261 |
+
""".format(format_currency(total_spending)), unsafe_allow_html=True)
|
| 262 |
+
|
| 263 |
+
with col3:
|
| 264 |
+
st.markdown("""
|
| 265 |
+
<div style='background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); padding: 20px; border-radius: 10px; text-align: center; margin: 5px;'>
|
| 266 |
+
<h3 style='color: white; margin: 0;'>💰</h3>
|
| 267 |
+
<h2 style='color: white; margin: 10px 0;'>{}</h2>
|
| 268 |
+
<p style='color: white; margin: 0; opacity: 0.9;'>Total Income</p>
|
| 269 |
+
</div>
|
| 270 |
+
""".format(format_currency(total_income)), unsafe_allow_html=True)
|
| 271 |
+
|
| 272 |
+
with col4:
|
| 273 |
+
net_color = "#43a047" if net_worth >= 0 else "#e53e3e"
|
| 274 |
+
net_icon = "📈" if net_worth >= 0 else "📉"
|
| 275 |
+
st.markdown("""
|
| 276 |
+
<div style='background: {}; padding: 20px; border-radius: 10px; text-align: center; margin: 5px;'>
|
| 277 |
+
<h3 style='color: white; margin: 0;'>{}</h3>
|
| 278 |
+
<h2 style='color: white; margin: 10px 0;'>{}</h2>
|
| 279 |
+
<p style='color: white; margin: 0; opacity: 0.9;'>Net Flow</p>
|
| 280 |
+
</div>
|
| 281 |
+
""".format(net_color, net_icon, format_currency(net_worth)), unsafe_allow_html=True)
|
| 282 |
+
|
| 283 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 284 |
+
|
| 285 |
+
# Three-column layout for dashboard sections
|
| 286 |
+
dash_col1, dash_col2, dash_col3 = st.columns([1, 1, 1])
|
| 287 |
+
|
| 288 |
+
with dash_col1:
|
| 289 |
+
# Health Score Card
|
| 290 |
+
st.markdown("""
|
| 291 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; margin: 10px 0; box-shadow: 0 2px 4px rgba(0,0,0,0.1);'>
|
| 292 |
+
<h4 style='color: #667eea; margin-top: 0;'>🏥 Health Score</h4>
|
| 293 |
+
</div>
|
| 294 |
+
""", unsafe_allow_html=True)
|
| 295 |
+
|
| 296 |
+
# Mini health score
|
| 297 |
+
health_data = st.session_state.health_analyzer.calculate_health_score(df)
|
| 298 |
+
score = health_data['total_score']
|
| 299 |
+
grade = health_data['grade']
|
| 300 |
+
|
| 301 |
+
st.markdown(f"""
|
| 302 |
+
<div style='text-align: center; padding: 10px;'>
|
| 303 |
+
<h1 style='color: #667eea; margin: 0; font-size: 3em;'>{score}</h1>
|
| 304 |
+
<h3 style='color: #666; margin: 0;'>Grade: {grade}</h3>
|
| 305 |
+
</div>
|
| 306 |
+
""", unsafe_allow_html=True)
|
| 307 |
+
|
| 308 |
+
if st.button("📊 View Full Health Analysis", key="health_dash"):
|
| 309 |
+
st.info("💡 Switch to the Health tab for detailed analysis!")
|
| 310 |
+
|
| 311 |
+
with dash_col2:
|
| 312 |
+
# Recent Alerts Card
|
| 313 |
+
st.markdown("""
|
| 314 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; margin: 10px 0; box-shadow: 0 2px 4px rgba(0,0,0,0.1);'>
|
| 315 |
+
<h4 style='color: #f5576c; margin-top: 0;'>🚨 Smart Alerts</h4>
|
| 316 |
+
</div>
|
| 317 |
+
""", unsafe_allow_html=True)
|
| 318 |
+
|
| 319 |
+
# Quick alerts preview
|
| 320 |
+
alerts = st.session_state.smart_alerts.generate_alerts(df, st.session_state.budgets)
|
| 321 |
+
|
| 322 |
+
if alerts:
|
| 323 |
+
alert_count = len(alerts)
|
| 324 |
+
high_priority = len([a for a in alerts if a.get('severity') == 'high'])
|
| 325 |
+
|
| 326 |
+
st.markdown(f"""
|
| 327 |
+
<div style='text-align: center; padding: 10px;'>
|
| 328 |
+
<h2 style='color: #f5576c; margin: 0;'>{alert_count}</h2>
|
| 329 |
+
<p style='color: #666; margin: 5px 0;'>Active Alerts</p>
|
| 330 |
+
<p style='color: #e53e3e; margin: 0; font-weight: bold;'>{high_priority} High Priority</p>
|
| 331 |
+
</div>
|
| 332 |
+
""", unsafe_allow_html=True)
|
| 333 |
+
|
| 334 |
+
# Show top alert
|
| 335 |
+
if alerts:
|
| 336 |
+
top_alert = alerts[0]
|
| 337 |
+
st.warning(f"⚠️ {top_alert['message'][:50]}...")
|
| 338 |
+
else:
|
| 339 |
+
st.success("🎉 No alerts - you're doing great!")
|
| 340 |
+
|
| 341 |
+
if st.button("🔍 View All Alerts", key="alerts_dash"):
|
| 342 |
+
st.info("💡 Switch to the Alerts tab for detailed information!")
|
| 343 |
+
|
| 344 |
+
with dash_col3:
|
| 345 |
+
# Goals Progress Card
|
| 346 |
+
st.markdown("""
|
| 347 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; margin: 10px 0; box-shadow: 0 2px 4px rgba(0,0,0,0.1);'>
|
| 348 |
+
<h4 style='color: #43a047; margin-top: 0;'>🎯 Goals Progress</h4>
|
| 349 |
+
</div>
|
| 350 |
+
""", unsafe_allow_html=True)
|
| 351 |
+
|
| 352 |
+
if st.session_state.user_goals:
|
| 353 |
+
total_goals = len(st.session_state.user_goals)
|
| 354 |
+
completed_goals = len([g for g in st.session_state.user_goals if g['progress_percentage'] >= 100])
|
| 355 |
+
avg_progress = np.mean([g['progress_percentage'] for g in st.session_state.user_goals])
|
| 356 |
+
|
| 357 |
+
st.markdown(f"""
|
| 358 |
+
<div style='text-align: center; padding: 10px;'>
|
| 359 |
+
<h2 style='color: #43a047; margin: 0;'>{total_goals}</h2>
|
| 360 |
+
<p style='color: #666; margin: 5px 0;'>Active Goals</p>
|
| 361 |
+
<p style='color: #43a047; margin: 0; font-weight: bold;'>{avg_progress:.1f}% Avg Progress</p>
|
| 362 |
+
</div>
|
| 363 |
+
""", unsafe_allow_html=True)
|
| 364 |
+
|
| 365 |
+
# Show next goal
|
| 366 |
+
next_goal = min(st.session_state.user_goals, key=lambda x: x['days_remaining'])
|
| 367 |
+
st.info(f"⏰ Next: {next_goal['name']} ({next_goal['days_remaining']} days)")
|
| 368 |
+
else:
|
| 369 |
+
st.markdown("""
|
| 370 |
+
<div style='text-align: center; padding: 20px;'>
|
| 371 |
+
<p style='color: #666;'>No goals set yet</p>
|
| 372 |
+
</div>
|
| 373 |
+
""", unsafe_allow_html=True)
|
| 374 |
+
|
| 375 |
+
if st.button("🎯 Manage Goals", key="goals_dash"):
|
| 376 |
+
st.info("💡 Switch to the Goals tab to create and manage your financial goals!")
|
| 377 |
+
|
| 378 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 379 |
+
|
| 380 |
+
# Quick Actions Section
|
| 381 |
+
st.markdown("""
|
| 382 |
+
<div style='background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); padding: 20px; border-radius: 10px; margin: 20px 0;'>
|
| 383 |
+
<h3 style='color: white; text-align: center; margin: 0;'>⚡ Quick Actions</h3>
|
| 384 |
+
</div>
|
| 385 |
+
""", unsafe_allow_html=True)
|
| 386 |
+
|
| 387 |
+
action_col1, action_col2, action_col3, action_col4 = st.columns(4)
|
| 388 |
+
|
| 389 |
+
with action_col1:
|
| 390 |
+
if st.button("💬 Ask AI Assistant", key="quick_chat"):
|
| 391 |
+
st.info("💡 Go to AI Chat tab to ask questions about your finances!")
|
| 392 |
+
|
| 393 |
+
with action_col2:
|
| 394 |
+
if st.button("📈 View Analytics", key="quick_analytics"):
|
| 395 |
+
st.info("💡 Go to Analytics tab for detailed spending analysis!")
|
| 396 |
+
|
| 397 |
+
with action_col3:
|
| 398 |
+
if st.button("🔮 See Predictions", key="quick_predictions"):
|
| 399 |
+
st.info("💡 Go to Predictions tab to forecast future spending!")
|
| 400 |
+
|
| 401 |
+
with action_col4:
|
| 402 |
+
if st.button("📅 Calendar View", key="quick_calendar"):
|
| 403 |
+
st.info("💡 Go to Calendar tab to see spending patterns by date!")
|
| 404 |
+
|
| 405 |
+
# Recent Activity Section
|
| 406 |
+
st.markdown("""
|
| 407 |
+
<div style='margin-top: 30px;'>
|
| 408 |
+
<h3 style='color: #667eea;'>📋 Recent Activity</h3>
|
| 409 |
+
</div>
|
| 410 |
+
""", unsafe_allow_html=True)
|
| 411 |
+
|
| 412 |
+
# Show recent transactions in a nice format
|
| 413 |
+
recent_transactions = df.head(5)
|
| 414 |
+
|
| 415 |
+
for _, transaction in recent_transactions.iterrows():
|
| 416 |
+
amount_color = "#e53e3e" if transaction['amount'] < 0 else "#43a047"
|
| 417 |
+
amount_symbol = "💸" if transaction['amount'] < 0 else "💰"
|
| 418 |
+
|
| 419 |
+
st.markdown(f"""
|
| 420 |
+
<div style='background: white; border-left: 4px solid {amount_color}; padding: 15px; margin: 10px 0; border-radius: 5px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);'>
|
| 421 |
+
<div style='display: flex; justify-content: space-between; align-items: center;'>
|
| 422 |
+
<div>
|
| 423 |
+
<strong>{transaction['description']}</strong><br>
|
| 424 |
+
<small style='color: #666;'>{transaction['date'].strftime('%Y-%m-%d') if hasattr(transaction['date'], 'strftime') else str(transaction['date'])}</small>
|
| 425 |
+
</div>
|
| 426 |
+
<div style='text-align: right;'>
|
| 427 |
+
<span style='font-size: 1.2em;'>{amount_symbol}</span>
|
| 428 |
+
<strong style='color: {amount_color}; font-size: 1.1em;'>{format_currency(abs(transaction['amount']))}</strong>
|
| 429 |
+
</div>
|
| 430 |
+
</div>
|
| 431 |
+
</div>
|
| 432 |
+
""", unsafe_allow_html=True)
|
| 433 |
+
|
| 434 |
+
with tab1:
|
| 435 |
+
st.header("💬 Ask Your Finance Assistant")
|
| 436 |
+
st.markdown("Ask questions about your spending habits in natural language!")
|
| 437 |
+
|
| 438 |
+
# Chat interface
|
| 439 |
+
user_question = st.text_input(
|
| 440 |
+
"Ask a question about your finances:",
|
| 441 |
+
placeholder="e.g., How much did I spend on food last month?",
|
| 442 |
+
key="user_input"
|
| 443 |
+
)
|
| 444 |
+
|
| 445 |
+
if st.button("Ask") and user_question:
|
| 446 |
+
with st.spinner("Analyzing your financial data..."):
|
| 447 |
+
# Get response from conversation handler
|
| 448 |
+
response = st.session_state.conversation_handler.get_response(
|
| 449 |
+
user_question,
|
| 450 |
+
st.session_state.vector_store,
|
| 451 |
+
df
|
| 452 |
+
)
|
| 453 |
+
|
| 454 |
+
# Add to chat history
|
| 455 |
+
st.session_state.chat_history.append({
|
| 456 |
+
"question": user_question,
|
| 457 |
+
"answer": response,
|
| 458 |
+
"timestamp": datetime.now()
|
| 459 |
+
})
|
| 460 |
+
|
| 461 |
+
# Display chat history
|
| 462 |
+
if st.session_state.chat_history:
|
| 463 |
+
st.subheader("💭 Conversation History")
|
| 464 |
+
for i, chat in enumerate(reversed(st.session_state.chat_history[-5:])): # Show last 5
|
| 465 |
+
with st.expander(f"Q: {chat['question'][:50]}...", expanded=(i==0)):
|
| 466 |
+
st.write(f"**Question:** {chat['question']}")
|
| 467 |
+
st.write(f"**Answer:** {chat['answer']}")
|
| 468 |
+
st.write(f"*{chat['timestamp'].strftime('%Y-%m-%d %H:%M:%S')}*")
|
| 469 |
+
|
| 470 |
+
with tab2:
|
| 471 |
+
st.header("📈 Financial Analytics")
|
| 472 |
+
|
| 473 |
+
col1, col2 = st.columns(2)
|
| 474 |
+
|
| 475 |
+
with col1:
|
| 476 |
+
# Spending by category pie chart
|
| 477 |
+
st.subheader("Spending by Category")
|
| 478 |
+
category_spending = df.groupby('category')['amount'].sum().abs()
|
| 479 |
+
fig_pie = px.pie(
|
| 480 |
+
values=category_spending.values,
|
| 481 |
+
names=category_spending.index,
|
| 482 |
+
title="Expense Distribution by Category"
|
| 483 |
+
)
|
| 484 |
+
st.plotly_chart(fig_pie, use_container_width=True)
|
| 485 |
+
|
| 486 |
+
with col2:
|
| 487 |
+
# Monthly spending trend
|
| 488 |
+
st.subheader("Monthly Spending Trend")
|
| 489 |
+
monthly_spending = st.session_state.visualizer.create_monthly_trend(df)
|
| 490 |
+
st.plotly_chart(monthly_spending, use_container_width=True)
|
| 491 |
+
|
| 492 |
+
# Top spending categories
|
| 493 |
+
st.subheader("📊 Top Spending Categories")
|
| 494 |
+
top_categories = df.groupby('category')['amount'].sum().abs().sort_values(ascending=False).head(10)
|
| 495 |
+
fig_bar = px.bar(
|
| 496 |
+
x=top_categories.index,
|
| 497 |
+
y=top_categories.values,
|
| 498 |
+
title="Top 10 Spending Categories",
|
| 499 |
+
labels={'x': 'Category', 'y': 'Amount'}
|
| 500 |
+
)
|
| 501 |
+
st.plotly_chart(fig_bar, use_container_width=True)
|
| 502 |
+
|
| 503 |
+
with tab3:
|
| 504 |
+
st.header("🔍 Transaction Explorer")
|
| 505 |
+
|
| 506 |
+
# Filters
|
| 507 |
+
col1, col2, col3 = st.columns(3)
|
| 508 |
+
|
| 509 |
+
with col1:
|
| 510 |
+
categories = ['All'] + list(df['category'].unique())
|
| 511 |
+
selected_category = st.selectbox("Filter by Category", categories)
|
| 512 |
+
|
| 513 |
+
with col2:
|
| 514 |
+
date_range = st.date_input(
|
| 515 |
+
"Date Range",
|
| 516 |
+
value=(df['date'].min(), df['date'].max()),
|
| 517 |
+
min_value=df['date'].min(),
|
| 518 |
+
max_value=df['date'].max()
|
| 519 |
+
)
|
| 520 |
+
|
| 521 |
+
with col3:
|
| 522 |
+
amount_range = st.slider(
|
| 523 |
+
"Amount Range",
|
| 524 |
+
float(df['amount'].min()),
|
| 525 |
+
float(df['amount'].max()),
|
| 526 |
+
(float(df['amount'].min()), float(df['amount'].max()))
|
| 527 |
+
)
|
| 528 |
+
|
| 529 |
+
# Filter data
|
| 530 |
+
filtered_df = df.copy()
|
| 531 |
+
|
| 532 |
+
if selected_category != 'All':
|
| 533 |
+
filtered_df = filtered_df[filtered_df['category'] == selected_category]
|
| 534 |
+
|
| 535 |
+
if len(date_range) == 2:
|
| 536 |
+
filtered_df = filtered_df[
|
| 537 |
+
(filtered_df['date'] >= pd.to_datetime(date_range[0])) &
|
| 538 |
+
(filtered_df['date'] <= pd.to_datetime(date_range[1]))
|
| 539 |
+
]
|
| 540 |
+
|
| 541 |
+
filtered_df = filtered_df[
|
| 542 |
+
(filtered_df['amount'] >= amount_range[0]) &
|
| 543 |
+
(filtered_df['amount'] <= amount_range[1])
|
| 544 |
+
]
|
| 545 |
+
|
| 546 |
+
# Display filtered transactions
|
| 547 |
+
st.subheader(f"📋 Transactions ({len(filtered_df)} found)")
|
| 548 |
+
|
| 549 |
+
if len(filtered_df) > 0:
|
| 550 |
+
# Format for display
|
| 551 |
+
display_df = filtered_df.copy()
|
| 552 |
+
display_df['amount'] = display_df['amount'].apply(format_currency)
|
| 553 |
+
display_df['date'] = display_df['date'].dt.strftime('%Y-%m-%d')
|
| 554 |
+
|
| 555 |
+
st.dataframe(
|
| 556 |
+
display_df[['date', 'description', 'amount', 'category']],
|
| 557 |
+
use_container_width=True
|
| 558 |
+
)
|
| 559 |
+
|
| 560 |
+
# Download filtered data
|
| 561 |
+
csv = filtered_df.to_csv(index=False)
|
| 562 |
+
st.download_button(
|
| 563 |
+
label="📥 Download Filtered Data",
|
| 564 |
+
data=csv,
|
| 565 |
+
file_name=f"filtered_transactions_{datetime.now().strftime('%Y%m%d')}.csv",
|
| 566 |
+
mime="text/csv"
|
| 567 |
+
)
|
| 568 |
+
else:
|
| 569 |
+
st.info("No transactions found matching the selected filters.")
|
| 570 |
+
|
| 571 |
+
with tab4:
|
| 572 |
+
# Enhanced Health Score Layout
|
| 573 |
+
st.markdown("""
|
| 574 |
+
<div style='text-align: center; margin-bottom: 30px;'>
|
| 575 |
+
<h2 style='color: #667eea;'>🏥 Financial Health Analysis</h2>
|
| 576 |
+
<p style='color: #666; font-size: 1.1em;'>Comprehensive assessment of your financial wellness</p>
|
| 577 |
+
</div>
|
| 578 |
+
""", unsafe_allow_html=True)
|
| 579 |
+
|
| 580 |
+
# Calculate health score
|
| 581 |
+
health_data = st.session_state.health_analyzer.calculate_health_score(df)
|
| 582 |
+
|
| 583 |
+
col1, col2 = st.columns(2)
|
| 584 |
+
|
| 585 |
+
with col1:
|
| 586 |
+
# Health Score Card
|
| 587 |
+
st.markdown("""
|
| 588 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 15px; padding: 25px; margin: 10px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
|
| 589 |
+
<h4 style='color: #667eea; margin-top: 0; text-align: center;'>📊 Overall Health Score</h4>
|
| 590 |
+
</div>
|
| 591 |
+
""", unsafe_allow_html=True)
|
| 592 |
+
|
| 593 |
+
health_fig = st.session_state.health_analyzer.create_health_score_visualization(health_data)
|
| 594 |
+
st.plotly_chart(health_fig, use_container_width=True)
|
| 595 |
+
|
| 596 |
+
# Health insights in cards
|
| 597 |
+
st.markdown("""
|
| 598 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 15px; padding: 25px; margin: 15px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
|
| 599 |
+
<h4 style='color: #4facfe; margin-top: 0;'>💡 Key Insights</h4>
|
| 600 |
+
</div>
|
| 601 |
+
""", unsafe_allow_html=True)
|
| 602 |
+
|
| 603 |
+
for insight in health_data['insights']:
|
| 604 |
+
st.markdown(f"""
|
| 605 |
+
<div style='background: #f8f9fa; border-left: 4px solid #4facfe; padding: 15px; margin: 10px 0; border-radius: 5px;'>
|
| 606 |
+
<p style='margin: 0; color: #333;'>{insight}</p>
|
| 607 |
+
</div>
|
| 608 |
+
""", unsafe_allow_html=True)
|
| 609 |
+
|
| 610 |
+
with col2:
|
| 611 |
+
# Component scores card
|
| 612 |
+
st.markdown("""
|
| 613 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 15px; padding: 25px; margin: 10px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
|
| 614 |
+
<h4 style='color: #667eea; margin-top: 0; text-align: center;'>🎯 Component Analysis</h4>
|
| 615 |
+
</div>
|
| 616 |
+
""", unsafe_allow_html=True)
|
| 617 |
+
|
| 618 |
+
component_fig = st.session_state.health_analyzer.create_component_scores_chart(health_data['component_scores'])
|
| 619 |
+
st.plotly_chart(component_fig, use_container_width=True)
|
| 620 |
+
|
| 621 |
+
# Improvement tips in cards
|
| 622 |
+
st.markdown("""
|
| 623 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 15px; padding: 25px; margin: 15px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
|
| 624 |
+
<h4 style='color: #43a047; margin-top: 0;'>🚀 Improvement Tips</h4>
|
| 625 |
+
</div>
|
| 626 |
+
""", unsafe_allow_html=True)
|
| 627 |
+
|
| 628 |
+
for tip in health_data['improvement_tips']:
|
| 629 |
+
st.markdown(f"""
|
| 630 |
+
<div style='background: #f1f8e9; border-left: 4px solid #43a047; padding: 15px; margin: 10px 0; border-radius: 5px;'>
|
| 631 |
+
<p style='margin: 0; color: #333;'>{tip}</p>
|
| 632 |
+
</div>
|
| 633 |
+
""", unsafe_allow_html=True)
|
| 634 |
+
|
| 635 |
+
with tab5:
|
| 636 |
+
st.header("🔮 Financial Predictions")
|
| 637 |
+
|
| 638 |
+
# Spending predictions
|
| 639 |
+
predictions = st.session_state.predictive_analytics.predict_future_spending(df, months_ahead=3)
|
| 640 |
+
|
| 641 |
+
col1, col2 = st.columns(2)
|
| 642 |
+
|
| 643 |
+
with col1:
|
| 644 |
+
# Prediction chart
|
| 645 |
+
pred_fig = st.session_state.predictive_analytics.create_prediction_chart(df, predictions)
|
| 646 |
+
st.plotly_chart(pred_fig, use_container_width=True)
|
| 647 |
+
|
| 648 |
+
# Prediction summary
|
| 649 |
+
st.subheader("📊 Forecast Summary")
|
| 650 |
+
if predictions['predictions']:
|
| 651 |
+
avg_prediction = np.mean(predictions['predictions'])
|
| 652 |
+
st.metric("Avg Monthly Spending (Next 3 months)", format_currency(avg_prediction))
|
| 653 |
+
st.metric("Trend Direction", predictions['trend_direction'].title())
|
| 654 |
+
st.metric("Confidence Level", f"{predictions['confidence_level']:.1f}%")
|
| 655 |
+
|
| 656 |
+
with col2:
|
| 657 |
+
# Category predictions
|
| 658 |
+
category_predictions = st.session_state.predictive_analytics.predict_category_spending(df)
|
| 659 |
+
|
| 660 |
+
if category_predictions:
|
| 661 |
+
st.subheader("📈 Category Forecasts")
|
| 662 |
+
for category, pred_data in list(category_predictions.items())[:5]:
|
| 663 |
+
st.write(f"**{category}**")
|
| 664 |
+
st.write(f"Predicted: {format_currency(pred_data['predicted_amount'])}")
|
| 665 |
+
st.write(f"Trend: {pred_data['trend']} ({pred_data['confidence']:.0f}% confidence)")
|
| 666 |
+
st.write("---")
|
| 667 |
+
|
| 668 |
+
# Anomalies
|
| 669 |
+
anomalies = st.session_state.predictive_analytics.detect_spending_anomalies(df)
|
| 670 |
+
if anomalies:
|
| 671 |
+
st.subheader("⚠️ Detected Anomalies")
|
| 672 |
+
for anomaly in anomalies[:3]:
|
| 673 |
+
severity_color = "🔴" if anomaly['severity'] == 'high' else "🟡"
|
| 674 |
+
st.write(f"{severity_color} {anomaly['type'].replace('_', ' ').title()}")
|
| 675 |
+
if 'month' in anomaly:
|
| 676 |
+
st.write(f"Month: {anomaly['month']}")
|
| 677 |
+
st.write(f"Amount: {format_currency(anomaly['amount'])}")
|
| 678 |
+
st.write("---")
|
| 679 |
+
|
| 680 |
+
with tab6:
|
| 681 |
+
# Enhanced Alerts Layout
|
| 682 |
+
st.markdown("""
|
| 683 |
+
<div style='text-align: center; margin-bottom: 30px;'>
|
| 684 |
+
<h2 style='color: #f5576c;'>🚨 Smart Financial Alerts</h2>
|
| 685 |
+
<p style='color: #666; font-size: 1.1em;'>Proactive notifications to keep your finances on track</p>
|
| 686 |
+
</div>
|
| 687 |
+
""", unsafe_allow_html=True)
|
| 688 |
+
|
| 689 |
+
# Generate and display alerts
|
| 690 |
+
alerts = st.session_state.smart_alerts.generate_alerts(df, st.session_state.budgets)
|
| 691 |
+
|
| 692 |
+
if alerts:
|
| 693 |
+
# Alert summary cards at top
|
| 694 |
+
alert_summary = st.session_state.smart_alerts.create_alerts_summary(alerts)
|
| 695 |
+
|
| 696 |
+
sum_col1, sum_col2, sum_col3, sum_col4 = st.columns(4)
|
| 697 |
+
|
| 698 |
+
with sum_col1:
|
| 699 |
+
st.markdown(f"""
|
| 700 |
+
<div style='background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%); padding: 20px; border-radius: 10px; text-align: center; margin: 5px;'>
|
| 701 |
+
<h3 style='color: white; margin: 0;'>🚨</h3>
|
| 702 |
+
<h2 style='color: white; margin: 10px 0;'>{alert_summary['total_alerts']}</h2>
|
| 703 |
+
<p style='color: white; margin: 0; opacity: 0.9;'>Total Alerts</p>
|
| 704 |
+
</div>
|
| 705 |
+
""", unsafe_allow_html=True)
|
| 706 |
+
|
| 707 |
+
with sum_col2:
|
| 708 |
+
st.markdown(f"""
|
| 709 |
+
<div style='background: linear-gradient(135deg, #e53e3e 0%, #ff6b35 100%); padding: 20px; border-radius: 10px; text-align: center; margin: 5px;'>
|
| 710 |
+
<h3 style='color: white; margin: 0;'>🔴</h3>
|
| 711 |
+
<h2 style='color: white; margin: 10px 0;'>{alert_summary['high_severity']}</h2>
|
| 712 |
+
<p style='color: white; margin: 0; opacity: 0.9;'>High Priority</p>
|
| 713 |
+
</div>
|
| 714 |
+
""", unsafe_allow_html=True)
|
| 715 |
+
|
| 716 |
+
with sum_col3:
|
| 717 |
+
st.markdown(f"""
|
| 718 |
+
<div style='background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%); padding: 20px; border-radius: 10px; text-align: center; margin: 5px;'>
|
| 719 |
+
<h3 style='color: white; margin: 0;'>🟡</h3>
|
| 720 |
+
<h2 style='color: white; margin: 10px 0;'>{alert_summary['medium_severity']}</h2>
|
| 721 |
+
<p style='color: white; margin: 0; opacity: 0.9;'>Medium Priority</p>
|
| 722 |
+
</div>
|
| 723 |
+
""", unsafe_allow_html=True)
|
| 724 |
+
|
| 725 |
+
with sum_col4:
|
| 726 |
+
st.markdown(f"""
|
| 727 |
+
<div style='background: linear-gradient(135deg, #2196f3 0%, #64b5f6 100%); padding: 20px; border-radius: 10px; text-align: center; margin: 5px;'>
|
| 728 |
+
<h3 style='color: white; margin: 0;'>🔵</h3>
|
| 729 |
+
<h2 style='color: white; margin: 10px 0;'>{alert_summary['low_severity']}</h2>
|
| 730 |
+
<p style='color: white; margin: 0; opacity: 0.9;'>Low Priority</p>
|
| 731 |
+
</div>
|
| 732 |
+
""", unsafe_allow_html=True)
|
| 733 |
+
|
| 734 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 735 |
+
|
| 736 |
+
# Alert details in cards
|
| 737 |
+
st.markdown("""
|
| 738 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 15px; padding: 25px; margin: 20px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
|
| 739 |
+
<h4 style='color: #f5576c; margin-top: 0;'>📋 Alert Details</h4>
|
| 740 |
+
</div>
|
| 741 |
+
""", unsafe_allow_html=True)
|
| 742 |
+
|
| 743 |
+
# Display alerts with better styling
|
| 744 |
+
for alert in alerts:
|
| 745 |
+
severity_colors = {
|
| 746 |
+
'high': '#ffebee',
|
| 747 |
+
'medium': '#fff3e0',
|
| 748 |
+
'low': '#e3f2fd'
|
| 749 |
+
}
|
| 750 |
+
border_colors = {
|
| 751 |
+
'high': '#f44336',
|
| 752 |
+
'medium': '#ff9800',
|
| 753 |
+
'low': '#2196f3'
|
| 754 |
+
}
|
| 755 |
+
|
| 756 |
+
severity = alert.get('severity', 'low')
|
| 757 |
+
bg_color = severity_colors.get(severity, '#f5f5f5')
|
| 758 |
+
border_color = border_colors.get(severity, '#ddd')
|
| 759 |
+
|
| 760 |
+
st.markdown(f"""
|
| 761 |
+
<div style='background: {bg_color}; border-left: 4px solid {border_color}; padding: 15px; margin: 10px 0; border-radius: 5px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);'>
|
| 762 |
+
<p style='margin: 0; color: #333; font-weight: 500;'>{alert['message']}</p>
|
| 763 |
+
</div>
|
| 764 |
+
""", unsafe_allow_html=True)
|
| 765 |
+
else:
|
| 766 |
+
st.markdown("""
|
| 767 |
+
<div style='text-align: center; padding: 50px; background: linear-gradient(135deg, #43a047 0%, #66bb6a 100%); border-radius: 15px; margin: 20px 0;'>
|
| 768 |
+
<h1 style='color: white; margin: 0; font-size: 4em;'>🎉</h1>
|
| 769 |
+
<h2 style='color: white; margin: 20px 0;'>All Clear!</h2>
|
| 770 |
+
<p style='color: white; opacity: 0.9; font-size: 1.2em;'>No alerts detected - your finances look healthy!</p>
|
| 771 |
+
</div>
|
| 772 |
+
""", unsafe_allow_html=True)
|
| 773 |
+
|
| 774 |
+
# Budget Management Card
|
| 775 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 776 |
+
st.markdown("""
|
| 777 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 15px; padding: 25px; margin: 20px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
|
| 778 |
+
<h4 style='color: #43a047; margin-top: 0;'>💰 Budget Management</h4>
|
| 779 |
+
</div>
|
| 780 |
+
""", unsafe_allow_html=True)
|
| 781 |
+
|
| 782 |
+
budget_col1, budget_col2 = st.columns(2)
|
| 783 |
+
|
| 784 |
+
with budget_col1:
|
| 785 |
+
st.markdown("##### Set New Budget")
|
| 786 |
+
if 'category' in df.columns:
|
| 787 |
+
categories = df['category'].unique()
|
| 788 |
+
selected_category = st.selectbox("Category", categories, key="budget_category")
|
| 789 |
+
budget_amount = st.number_input(f"Monthly Budget ($)", min_value=0.0, step=50.0, key="budget_amount")
|
| 790 |
+
|
| 791 |
+
if st.button("💾 Set Budget", key="set_budget_btn"):
|
| 792 |
+
st.session_state.budgets[selected_category] = budget_amount
|
| 793 |
+
st.success(f"✅ Budget set for {selected_category}: {format_currency(budget_amount)}")
|
| 794 |
+
st.rerun()
|
| 795 |
+
|
| 796 |
+
with budget_col2:
|
| 797 |
+
st.markdown("##### Current Budgets")
|
| 798 |
+
if st.session_state.budgets:
|
| 799 |
+
for category, amount in st.session_state.budgets.items():
|
| 800 |
+
st.markdown(f"""
|
| 801 |
+
<div style='background: #f8f9fa; border: 1px solid #e9ecef; padding: 10px; margin: 5px 0; border-radius: 5px; display: flex; justify-content: space-between;'>
|
| 802 |
+
<span style='font-weight: 500;'>{category}</span>
|
| 803 |
+
<span style='color: #43a047; font-weight: bold;'>{format_currency(amount)}</span>
|
| 804 |
+
</div>
|
| 805 |
+
""", unsafe_allow_html=True)
|
| 806 |
+
else:
|
| 807 |
+
st.info("No budgets set yet. Set your first budget to get started!")
|
| 808 |
+
|
| 809 |
+
with tab7:
|
| 810 |
+
st.header("🎯 Financial Goals")
|
| 811 |
+
|
| 812 |
+
col1, col2 = st.columns(2)
|
| 813 |
+
|
| 814 |
+
with col1:
|
| 815 |
+
st.subheader("➕ Create New Goal")
|
| 816 |
+
|
| 817 |
+
goal_name = st.text_input("Goal Name", placeholder="e.g., Emergency Fund")
|
| 818 |
+
goal_type = st.selectbox("Goal Type", st.session_state.goal_tracker.goal_types)
|
| 819 |
+
target_amount = st.number_input("Target Amount ($)", min_value=0.0, step=100.0)
|
| 820 |
+
target_date = st.date_input("Target Date", min_value=datetime.now().date())
|
| 821 |
+
current_amount = st.number_input("Current Amount ($)", min_value=0.0, step=50.0)
|
| 822 |
+
|
| 823 |
+
if st.button("Create Goal"):
|
| 824 |
+
new_goal = st.session_state.goal_tracker.create_goal(
|
| 825 |
+
goal_name, target_amount, target_date, goal_type, current_amount
|
| 826 |
+
)
|
| 827 |
+
st.session_state.user_goals.append(new_goal)
|
| 828 |
+
st.success(f"Goal '{goal_name}' created successfully!")
|
| 829 |
+
st.rerun()
|
| 830 |
+
|
| 831 |
+
with col2:
|
| 832 |
+
st.subheader("📋 Your Goals")
|
| 833 |
+
|
| 834 |
+
if st.session_state.user_goals:
|
| 835 |
+
for i, goal in enumerate(st.session_state.user_goals):
|
| 836 |
+
with st.expander(f"{goal['name']} ({goal['progress_percentage']:.1f}% complete)"):
|
| 837 |
+
|
| 838 |
+
# Goal progress chart
|
| 839 |
+
progress_fig = st.session_state.goal_tracker.create_goal_progress_chart(goal)
|
| 840 |
+
st.plotly_chart(progress_fig, use_container_width=True)
|
| 841 |
+
|
| 842 |
+
# Goal details
|
| 843 |
+
col_a, col_b = st.columns(2)
|
| 844 |
+
with col_a:
|
| 845 |
+
st.write(f"**Target:** {format_currency(goal['target_amount'])}")
|
| 846 |
+
st.write(f"**Current:** {format_currency(goal['current_amount'])}")
|
| 847 |
+
st.write(f"**Target Date:** {goal['target_date']}")
|
| 848 |
+
with col_b:
|
| 849 |
+
st.write(f"**Status:** {goal['status']}")
|
| 850 |
+
st.write(f"**Days Remaining:** {goal['days_remaining']}")
|
| 851 |
+
st.write(f"**Monthly Savings Needed:** {format_currency(goal['monthly_savings_needed'])}")
|
| 852 |
+
|
| 853 |
+
# Feasibility analysis
|
| 854 |
+
feasibility = st.session_state.goal_tracker.analyze_goal_feasibility(goal, df)
|
| 855 |
+
st.write(f"**Feasibility:** {feasibility['feasibility']}")
|
| 856 |
+
st.write(f"**Success Probability:** {feasibility['success_probability']:.1f}%")
|
| 857 |
+
|
| 858 |
+
# Remove goal button
|
| 859 |
+
if st.button(f"Remove Goal", key=f"remove_{i}"):
|
| 860 |
+
st.session_state.user_goals.pop(i)
|
| 861 |
+
st.rerun()
|
| 862 |
+
else:
|
| 863 |
+
st.info("No goals set yet. Create your first goal to get started!")
|
| 864 |
+
|
| 865 |
+
# Goal strategies
|
| 866 |
+
if st.session_state.user_goals:
|
| 867 |
+
st.subheader("💡 Savings Strategies")
|
| 868 |
+
for goal in st.session_state.user_goals[:2]: # Show strategies for first 2 goals
|
| 869 |
+
strategies = st.session_state.goal_tracker.generate_savings_strategies(goal, df)
|
| 870 |
+
if strategies:
|
| 871 |
+
st.write(f"**Strategies for {goal['name']}:**")
|
| 872 |
+
strategy_fig = st.session_state.goal_tracker.create_savings_strategy_chart(strategies)
|
| 873 |
+
st.plotly_chart(strategy_fig, use_container_width=True)
|
| 874 |
+
|
| 875 |
+
for strategy in strategies[:3]:
|
| 876 |
+
st.write(f"• **{strategy['strategy']}**: {strategy['description']}")
|
| 877 |
+
|
| 878 |
+
with tab8:
|
| 879 |
+
st.header("📅 Financial Calendar")
|
| 880 |
+
|
| 881 |
+
# Month/Year selector
|
| 882 |
+
col1, col2 = st.columns(2)
|
| 883 |
+
with col1:
|
| 884 |
+
selected_year = st.selectbox("Year", range(2020, 2030), index=4) # Default to 2024
|
| 885 |
+
with col2:
|
| 886 |
+
selected_month = st.selectbox("Month", range(1, 13), index=datetime.now().month-1)
|
| 887 |
+
|
| 888 |
+
# Generate calendar data
|
| 889 |
+
calendar_data = st.session_state.financial_calendar.create_calendar_view(df, selected_year, selected_month)
|
| 890 |
+
|
| 891 |
+
col1, col2 = st.columns(2)
|
| 892 |
+
|
| 893 |
+
with col1:
|
| 894 |
+
# Calendar heatmap
|
| 895 |
+
calendar_fig = st.session_state.financial_calendar.create_calendar_heatmap(calendar_data)
|
| 896 |
+
st.plotly_chart(calendar_fig, use_container_width=True)
|
| 897 |
+
|
| 898 |
+
# Month statistics
|
| 899 |
+
st.subheader("📊 Month Statistics")
|
| 900 |
+
month_stats = calendar_data['month_stats']
|
| 901 |
+
st.metric("Total Spending", format_currency(month_stats['total_spending']))
|
| 902 |
+
st.metric("Total Income", format_currency(month_stats['total_income']))
|
| 903 |
+
st.metric("Net Flow", format_currency(month_stats['net_flow']))
|
| 904 |
+
st.metric("Transaction Count", month_stats['transaction_count'])
|
| 905 |
+
st.metric("Most Active Day", month_stats['most_active_day'])
|
| 906 |
+
|
| 907 |
+
with col2:
|
| 908 |
+
# Spending patterns
|
| 909 |
+
if calendar_data['patterns']:
|
| 910 |
+
pattern_fig = st.session_state.financial_calendar.create_spending_pattern_chart(calendar_data['patterns'])
|
| 911 |
+
st.plotly_chart(pattern_fig, use_container_width=True)
|
| 912 |
+
|
| 913 |
+
# Calendar insights
|
| 914 |
+
insights = st.session_state.financial_calendar.get_calendar_insights(calendar_data)
|
| 915 |
+
st.subheader("💡 Calendar Insights")
|
| 916 |
+
for insight in insights:
|
| 917 |
+
st.info(insight)
|
| 918 |
+
|
| 919 |
+
# Daily cash flow
|
| 920 |
+
st.subheader("💰 Daily Cash Flow")
|
| 921 |
+
flow_fig = st.session_state.financial_calendar.create_monthly_flow_chart(df)
|
| 922 |
+
st.plotly_chart(flow_fig, use_container_width=True)
|
| 923 |
+
|
| 924 |
+
else:
|
| 925 |
+
# Enhanced welcome screen with proper branding
|
| 926 |
+
st.markdown("""
|
| 927 |
+
<div style='text-align: center; padding: 50px 20px; margin: 50px 0;'>
|
| 928 |
+
<h1 style='color: #667eea; font-size: 4em; margin: 0; font-weight: 300;'>🚀 AI FinancePilot</h1>
|
| 929 |
+
<h2 style='color: #764ba2; margin: 30px 0; font-weight: 300; font-size: 2em;'>Your Intelligent Financial Co-Pilot</h2>
|
| 930 |
+
<p style='color: #666; font-size: 1.4em; margin: 40px 0; max-width: 800px; margin-left: auto; margin-right: auto; line-height: 1.6;'>
|
| 931 |
+
Transform your financial data into actionable insights with revolutionary AI-powered analytics
|
| 932 |
+
</p>
|
| 933 |
+
</div>
|
| 934 |
+
""", unsafe_allow_html=True)
|
| 935 |
+
|
| 936 |
+
# Getting Started Card
|
| 937 |
+
st.markdown("""
|
| 938 |
+
<div style='background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; border-radius: 15px; margin: 40px 0; text-align: center;'>
|
| 939 |
+
<h3 style='margin: 0 0 20px 0; font-size: 1.8em;'>👆 Get Started</h3>
|
| 940 |
+
<p style='margin: 0; opacity: 0.9; font-size: 1.2em;'>Upload your bank statement using the sidebar to unlock powerful financial insights</p>
|
| 941 |
+
</div>
|
| 942 |
+
""", unsafe_allow_html=True)
|
| 943 |
+
|
| 944 |
+
# Requirements and Features
|
| 945 |
+
col1, col2 = st.columns(2)
|
| 946 |
+
|
| 947 |
+
with col1:
|
| 948 |
+
st.markdown("""
|
| 949 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 15px; padding: 25px; margin: 20px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
|
| 950 |
+
<h4 style='color: #667eea; margin-top: 0;'>📋 File Requirements</h4>
|
| 951 |
+
<p style='margin: 0; color: #333;'>Your CSV/Excel file should contain:</p>
|
| 952 |
+
<ul style='color: #666; margin: 15px 0;'>
|
| 953 |
+
<li><strong>Date</strong> column (transaction dates)</li>
|
| 954 |
+
<li><strong>Description</strong> column (transaction details)</li>
|
| 955 |
+
<li><strong>Amount</strong> column (transaction amounts)</li>
|
| 956 |
+
</ul>
|
| 957 |
+
</div>
|
| 958 |
+
""", unsafe_allow_html=True)
|
| 959 |
+
|
| 960 |
+
with col2:
|
| 961 |
+
st.markdown("""
|
| 962 |
+
<div style='background: white; border: 1px solid #e0e0e0; border-radius: 15px; padding: 25px; margin: 20px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
|
| 963 |
+
<h4 style='color: #43a047; margin-top: 0;'>🎯 What You Can Do</h4>
|
| 964 |
+
<ul style='color: #666; margin: 15px 0;'>
|
| 965 |
+
<li>🤖 <strong>AI Chat</strong>: Natural language queries</li>
|
| 966 |
+
<li>📊 <strong>Analytics</strong>: Beautiful charts & insights</li>
|
| 967 |
+
<li>🏥 <strong>Health Score</strong>: Financial wellness rating</li>
|
| 968 |
+
<li>🔮 <strong>Predictions</strong>: Future spending forecasts</li>
|
| 969 |
+
<li>🚨 <strong>Smart Alerts</strong>: Proactive notifications</li>
|
| 970 |
+
<li>🎯 <strong>Goals</strong>: Savings strategy recommendations</li>
|
| 971 |
+
</ul>
|
| 972 |
+
</div>
|
| 973 |
+
""", unsafe_allow_html=True)
|
| 974 |
+
|
| 975 |
+
# Example Questions Card
|
| 976 |
+
st.markdown("""
|
| 977 |
+
<div style='background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: white; padding: 25px; border-radius: 15px; margin: 30px 0;'>
|
| 978 |
+
<h4 style='margin: 0 0 20px 0; text-align: center;'>💬 Example Questions You Can Ask</h4>
|
| 979 |
+
<div style='display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 0;'>
|
| 980 |
+
<div style='background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px;'>
|
| 981 |
+
<p style='margin: 0; opacity: 0.9;'>"How much did I spend on food last month?"</p>
|
| 982 |
+
</div>
|
| 983 |
+
<div style='background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px;'>
|
| 984 |
+
<p style='margin: 0; opacity: 0.9;'>"What's my biggest expense category?"</p>
|
| 985 |
+
</div>
|
| 986 |
+
<div style='background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px;'>
|
| 987 |
+
<p style='margin: 0; opacity: 0.9;'>"Show me my travel expenses for the last 6 months"</p>
|
| 988 |
+
</div>
|
| 989 |
+
<div style='background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px;'>
|
| 990 |
+
<p style='margin: 0; opacity: 0.9;'>"How does my spending compare to last year?"</p>
|
| 991 |
+
</div>
|
| 992 |
+
</div>
|
| 993 |
+
</div>
|
| 994 |
+
""", unsafe_allow_html=True)
|
| 995 |
+
|
| 996 |
+
if __name__ == "__main__":
|
| 997 |
+
main()
|
conversation_handler.py
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from typing import List, Dict, Any, Optional
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
from datetime import datetime, timedelta
|
| 7 |
+
import re
|
| 8 |
+
from openai import OpenAI
|
| 9 |
+
|
| 10 |
+
class ConversationHandler:
|
| 11 |
+
"""Handles conversational AI interactions for financial queries."""
|
| 12 |
+
|
| 13 |
+
def __init__(self):
|
| 14 |
+
# Initialize OpenAI client
|
| 15 |
+
self.openai_api_key = os.getenv("OPENAI_API_KEY", "sk-default-key")
|
| 16 |
+
self.client = OpenAI(api_key=self.openai_api_key)
|
| 17 |
+
|
| 18 |
+
# the newest OpenAI model is "gpt-5" which was released August 7, 2025.
|
| 19 |
+
# do not change this unless explicitly requested by the user
|
| 20 |
+
self.model = "gpt-5"
|
| 21 |
+
|
| 22 |
+
self.conversation_memory = []
|
| 23 |
+
|
| 24 |
+
def get_response(self, user_query: str, vector_store, df: pd.DataFrame) -> str:
|
| 25 |
+
"""Generate a response to user's financial query."""
|
| 26 |
+
try:
|
| 27 |
+
# Search for relevant transactions
|
| 28 |
+
relevant_transactions = vector_store.search_transactions(user_query, n_results=10)
|
| 29 |
+
|
| 30 |
+
# Analyze the query to determine response type
|
| 31 |
+
query_analysis = self._analyze_query(user_query, df)
|
| 32 |
+
|
| 33 |
+
# Generate contextual response
|
| 34 |
+
response = self._generate_response(user_query, relevant_transactions, query_analysis, df)
|
| 35 |
+
|
| 36 |
+
# Store in conversation memory
|
| 37 |
+
self.conversation_memory.append({
|
| 38 |
+
"query": user_query,
|
| 39 |
+
"response": response,
|
| 40 |
+
"timestamp": datetime.now()
|
| 41 |
+
})
|
| 42 |
+
|
| 43 |
+
return response
|
| 44 |
+
|
| 45 |
+
except Exception as e:
|
| 46 |
+
return f"I apologize, but I encountered an error while analyzing your financial data: {str(e)}"
|
| 47 |
+
|
| 48 |
+
def _analyze_query(self, query: str, df: pd.DataFrame) -> Dict[str, Any]:
|
| 49 |
+
"""Analyze the user query to understand intent and extract parameters."""
|
| 50 |
+
query_lower = query.lower()
|
| 51 |
+
|
| 52 |
+
analysis = {
|
| 53 |
+
"intent": "general",
|
| 54 |
+
"time_period": None,
|
| 55 |
+
"category": None,
|
| 56 |
+
"amount_range": None,
|
| 57 |
+
"needs_calculation": False,
|
| 58 |
+
"needs_visualization": False
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
# Detect intent
|
| 62 |
+
if any(word in query_lower for word in ["how much", "total", "sum", "spent", "spend"]):
|
| 63 |
+
analysis["intent"] = "spending_analysis"
|
| 64 |
+
analysis["needs_calculation"] = True
|
| 65 |
+
|
| 66 |
+
elif any(word in query_lower for word in ["compare", "comparison", "vs", "versus"]):
|
| 67 |
+
analysis["intent"] = "comparison"
|
| 68 |
+
analysis["needs_calculation"] = True
|
| 69 |
+
|
| 70 |
+
elif any(word in query_lower for word in ["trend", "pattern", "over time", "monthly"]):
|
| 71 |
+
analysis["intent"] = "trend_analysis"
|
| 72 |
+
analysis["needs_visualization"] = True
|
| 73 |
+
|
| 74 |
+
elif any(word in query_lower for word in ["category", "categories", "type", "types"]):
|
| 75 |
+
analysis["intent"] = "category_analysis"
|
| 76 |
+
|
| 77 |
+
elif any(word in query_lower for word in ["budget", "recommend", "advice", "suggest"]):
|
| 78 |
+
analysis["intent"] = "recommendation"
|
| 79 |
+
|
| 80 |
+
# Extract time periods
|
| 81 |
+
time_patterns = {
|
| 82 |
+
"last month": "last_month",
|
| 83 |
+
"this month": "current_month",
|
| 84 |
+
"last year": "last_year",
|
| 85 |
+
"this year": "current_year",
|
| 86 |
+
"last 6 months": "last_6_months",
|
| 87 |
+
"last week": "last_week"
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
for pattern, period in time_patterns.items():
|
| 91 |
+
if pattern in query_lower:
|
| 92 |
+
analysis["time_period"] = period
|
| 93 |
+
break
|
| 94 |
+
|
| 95 |
+
# Extract categories
|
| 96 |
+
categories = df['category'].unique() if 'category' in df.columns else []
|
| 97 |
+
for category in categories:
|
| 98 |
+
if category.lower() in query_lower:
|
| 99 |
+
analysis["category"] = category
|
| 100 |
+
break
|
| 101 |
+
|
| 102 |
+
return analysis
|
| 103 |
+
|
| 104 |
+
def _generate_response(self, query: str, relevant_transactions: List[Dict],
|
| 105 |
+
analysis: Dict[str, Any], df: pd.DataFrame) -> str:
|
| 106 |
+
"""Generate AI response based on query analysis and relevant data."""
|
| 107 |
+
|
| 108 |
+
# Prepare context for the AI
|
| 109 |
+
context = self._prepare_context(relevant_transactions, analysis, df)
|
| 110 |
+
|
| 111 |
+
# Create the prompt
|
| 112 |
+
system_prompt = """You are a knowledgeable personal finance assistant.
|
| 113 |
+
Analyze the provided financial data and answer the user's question accurately.
|
| 114 |
+
Provide specific numbers, dates, and actionable insights.
|
| 115 |
+
Format your response in a clear, conversational manner.
|
| 116 |
+
If calculations are needed, show the math.
|
| 117 |
+
Always be helpful and encouraging about financial management."""
|
| 118 |
+
|
| 119 |
+
user_prompt = f"""
|
| 120 |
+
User Question: {query}
|
| 121 |
+
|
| 122 |
+
Financial Data Context:
|
| 123 |
+
{context}
|
| 124 |
+
|
| 125 |
+
Please provide a comprehensive answer based on the data provided.
|
| 126 |
+
"""
|
| 127 |
+
|
| 128 |
+
try:
|
| 129 |
+
response = self.client.chat.completions.create(
|
| 130 |
+
model=self.model,
|
| 131 |
+
messages=[
|
| 132 |
+
{"role": "system", "content": system_prompt},
|
| 133 |
+
{"role": "user", "content": user_prompt}
|
| 134 |
+
],
|
| 135 |
+
max_tokens=500,
|
| 136 |
+
temperature=0.3
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
return response.choices[0].message.content
|
| 140 |
+
|
| 141 |
+
except Exception as e:
|
| 142 |
+
# Fallback to rule-based response
|
| 143 |
+
return self._generate_fallback_response(query, analysis, df)
|
| 144 |
+
|
| 145 |
+
def _prepare_context(self, relevant_transactions: List[Dict],
|
| 146 |
+
analysis: Dict[str, Any], df: pd.DataFrame) -> str:
|
| 147 |
+
"""Prepare context string for AI prompt."""
|
| 148 |
+
context_parts = []
|
| 149 |
+
|
| 150 |
+
# Add relevant transactions
|
| 151 |
+
if relevant_transactions:
|
| 152 |
+
context_parts.append("Relevant Transactions:")
|
| 153 |
+
for i, tx in enumerate(relevant_transactions[:5]): # Limit to top 5
|
| 154 |
+
metadata = tx['metadata']
|
| 155 |
+
context_parts.append(
|
| 156 |
+
f"- {metadata['date']}: {metadata['description']} "
|
| 157 |
+
f"${abs(metadata['amount']):.2f} ({metadata['category']})"
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
# Add summary statistics based on analysis
|
| 161 |
+
if analysis["intent"] == "spending_analysis":
|
| 162 |
+
context_parts.append(self._get_spending_summary(df, analysis))
|
| 163 |
+
elif analysis["intent"] == "category_analysis":
|
| 164 |
+
context_parts.append(self._get_category_summary(df))
|
| 165 |
+
elif analysis["intent"] == "trend_analysis":
|
| 166 |
+
context_parts.append(self._get_trend_summary(df))
|
| 167 |
+
|
| 168 |
+
return "\n".join(context_parts)
|
| 169 |
+
|
| 170 |
+
def _get_spending_summary(self, df: pd.DataFrame, analysis: Dict[str, Any]) -> str:
|
| 171 |
+
"""Generate spending summary based on time period and category."""
|
| 172 |
+
summary_parts = ["Spending Summary:"]
|
| 173 |
+
|
| 174 |
+
# Filter by time period if specified
|
| 175 |
+
filtered_df = self._filter_by_time_period(df, analysis["time_period"])
|
| 176 |
+
|
| 177 |
+
# Filter by category if specified
|
| 178 |
+
if analysis["category"]:
|
| 179 |
+
filtered_df = filtered_df[filtered_df['category'] == analysis["category"]]
|
| 180 |
+
|
| 181 |
+
# Calculate totals
|
| 182 |
+
total_spent = filtered_df[filtered_df['amount'] < 0]['amount'].sum()
|
| 183 |
+
total_income = filtered_df[filtered_df['amount'] > 0]['amount'].sum()
|
| 184 |
+
|
| 185 |
+
summary_parts.append(f"Total Expenses: ${abs(total_spent):.2f}")
|
| 186 |
+
summary_parts.append(f"Total Income: ${total_income:.2f}")
|
| 187 |
+
summary_parts.append(f"Net: ${total_income + total_spent:.2f}")
|
| 188 |
+
summary_parts.append(f"Number of transactions: {len(filtered_df)}")
|
| 189 |
+
|
| 190 |
+
return "\n".join(summary_parts)
|
| 191 |
+
|
| 192 |
+
def _get_category_summary(self, df: pd.DataFrame) -> str:
|
| 193 |
+
"""Generate category breakdown summary."""
|
| 194 |
+
if 'category' not in df.columns:
|
| 195 |
+
return "Category information not available."
|
| 196 |
+
|
| 197 |
+
category_spending = df[df['amount'] < 0].groupby('category')['amount'].sum().abs().sort_values(ascending=False)
|
| 198 |
+
|
| 199 |
+
summary_parts = ["Category Breakdown:"]
|
| 200 |
+
for category, amount in category_spending.head(5).items():
|
| 201 |
+
summary_parts.append(f"- {category}: ${amount:.2f}")
|
| 202 |
+
|
| 203 |
+
return "\n".join(summary_parts)
|
| 204 |
+
|
| 205 |
+
def _get_trend_summary(self, df: pd.DataFrame) -> str:
|
| 206 |
+
"""Generate trend analysis summary."""
|
| 207 |
+
monthly_spending = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 208 |
+
|
| 209 |
+
summary_parts = ["Monthly Spending Trend:"]
|
| 210 |
+
for month, amount in monthly_spending.tail(6).items():
|
| 211 |
+
summary_parts.append(f"- {month}: ${amount:.2f}")
|
| 212 |
+
|
| 213 |
+
# Add trend direction
|
| 214 |
+
if len(monthly_spending) >= 2:
|
| 215 |
+
recent_change = monthly_spending.iloc[-1] - monthly_spending.iloc[-2]
|
| 216 |
+
trend = "increasing" if recent_change > 0 else "decreasing"
|
| 217 |
+
summary_parts.append(f"Recent trend: {trend} by ${abs(recent_change):.2f}")
|
| 218 |
+
|
| 219 |
+
return "\n".join(summary_parts)
|
| 220 |
+
|
| 221 |
+
def _filter_by_time_period(self, df: pd.DataFrame, time_period: str) -> pd.DataFrame:
|
| 222 |
+
"""Filter dataframe by specified time period."""
|
| 223 |
+
if not time_period:
|
| 224 |
+
return df
|
| 225 |
+
|
| 226 |
+
now = datetime.now()
|
| 227 |
+
|
| 228 |
+
if time_period == "last_month":
|
| 229 |
+
start_date = (now - timedelta(days=30)).replace(day=1)
|
| 230 |
+
end_date = now.replace(day=1) - timedelta(days=1)
|
| 231 |
+
elif time_period == "current_month":
|
| 232 |
+
start_date = now.replace(day=1)
|
| 233 |
+
end_date = now
|
| 234 |
+
elif time_period == "last_year":
|
| 235 |
+
start_date = datetime(now.year - 1, 1, 1)
|
| 236 |
+
end_date = datetime(now.year - 1, 12, 31)
|
| 237 |
+
elif time_period == "current_year":
|
| 238 |
+
start_date = datetime(now.year, 1, 1)
|
| 239 |
+
end_date = now
|
| 240 |
+
elif time_period == "last_6_months":
|
| 241 |
+
start_date = now - timedelta(days=180)
|
| 242 |
+
end_date = now
|
| 243 |
+
elif time_period == "last_week":
|
| 244 |
+
start_date = now - timedelta(days=7)
|
| 245 |
+
end_date = now
|
| 246 |
+
else:
|
| 247 |
+
return df
|
| 248 |
+
|
| 249 |
+
return df[(df['date'] >= start_date) & (df['date'] <= end_date)]
|
| 250 |
+
|
| 251 |
+
def _generate_fallback_response(self, query: str, analysis: Dict[str, Any], df: pd.DataFrame) -> str:
|
| 252 |
+
"""Generate a basic response when AI is not available."""
|
| 253 |
+
|
| 254 |
+
if analysis["intent"] == "spending_analysis":
|
| 255 |
+
filtered_df = self._filter_by_time_period(df, analysis["time_period"])
|
| 256 |
+
if analysis["category"]:
|
| 257 |
+
filtered_df = filtered_df[filtered_df['category'] == analysis["category"]]
|
| 258 |
+
|
| 259 |
+
total_spent = abs(filtered_df[filtered_df['amount'] < 0]['amount'].sum())
|
| 260 |
+
period_text = analysis["time_period"].replace("_", " ") if analysis["time_period"] else "all time"
|
| 261 |
+
category_text = f" on {analysis['category']}" if analysis["category"] else ""
|
| 262 |
+
|
| 263 |
+
return f"You spent ${total_spent:.2f}{category_text} during {period_text}."
|
| 264 |
+
|
| 265 |
+
elif analysis["intent"] == "category_analysis":
|
| 266 |
+
if 'category' in df.columns:
|
| 267 |
+
top_category = df[df['amount'] < 0].groupby('category')['amount'].sum().abs().idxmax()
|
| 268 |
+
return f"Your highest spending category is {top_category}."
|
| 269 |
+
|
| 270 |
+
return "I can help you analyze your financial data. Please try rephrasing your question or upload your transaction data first."
|
| 271 |
+
|
| 272 |
+
def get_budget_recommendations(self, df: pd.DataFrame) -> List[str]:
|
| 273 |
+
"""Generate budget recommendations based on spending patterns."""
|
| 274 |
+
recommendations = []
|
| 275 |
+
|
| 276 |
+
if 'category' not in df.columns:
|
| 277 |
+
return ["Upload transaction data to get personalized budget recommendations."]
|
| 278 |
+
|
| 279 |
+
# Analyze spending patterns
|
| 280 |
+
monthly_spending = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 281 |
+
category_spending = df[df['amount'] < 0].groupby('category')['amount'].sum().abs()
|
| 282 |
+
|
| 283 |
+
# High spending categories
|
| 284 |
+
if len(category_spending) > 0:
|
| 285 |
+
top_category = category_spending.idxmax()
|
| 286 |
+
top_amount = category_spending.max()
|
| 287 |
+
recommendations.append(
|
| 288 |
+
f"💡 Your highest spending is on {top_category} (${top_amount:.2f}). "
|
| 289 |
+
f"Consider setting a monthly budget for this category."
|
| 290 |
+
)
|
| 291 |
+
|
| 292 |
+
# Trend analysis
|
| 293 |
+
if len(monthly_spending) >= 2:
|
| 294 |
+
recent_change = monthly_spending.iloc[-1] - monthly_spending.iloc[-2]
|
| 295 |
+
if recent_change > 0:
|
| 296 |
+
recommendations.append(
|
| 297 |
+
f"⚠️ Your spending increased by ${recent_change:.2f} last month. "
|
| 298 |
+
f"Consider reviewing your recent purchases."
|
| 299 |
+
)
|
| 300 |
+
else:
|
| 301 |
+
recommendations.append(
|
| 302 |
+
f"✅ Good job! You reduced spending by ${abs(recent_change):.2f} last month."
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
# Average recommendations
|
| 306 |
+
avg_monthly = monthly_spending.mean() if len(monthly_spending) > 0 else 0
|
| 307 |
+
recommendations.append(
|
| 308 |
+
f"📊 Your average monthly spending is ${avg_monthly:.2f}. "
|
| 309 |
+
f"Consider setting aside 20% of your income for savings."
|
| 310 |
+
)
|
| 311 |
+
|
| 312 |
+
return recommendations
|
data_processor.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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import streamlit as st
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
import numpy as np
|
| 5 |
+
from typing import Optional, Dict, Any
|
| 6 |
+
import io
|
| 7 |
+
|
| 8 |
+
class DataProcessor:
|
| 9 |
+
"""Handles loading and preprocessing of financial data files."""
|
| 10 |
+
|
| 11 |
+
def __init__(self):
|
| 12 |
+
self.required_columns = ['date', 'description', 'amount']
|
| 13 |
+
self.column_mappings = {
|
| 14 |
+
# Common variations of column names
|
| 15 |
+
'date': ['date', 'transaction_date', 'posting_date', 'Date', 'Transaction Date'],
|
| 16 |
+
'description': ['description', 'desc', 'memo', 'Description', 'Memo', 'Transaction Description'],
|
| 17 |
+
'amount': ['amount', 'Amount', 'transaction_amount', 'debit', 'credit', 'Transaction Amount']
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
def load_file(self, uploaded_file) -> Optional[pd.DataFrame]:
|
| 21 |
+
"""Load and preprocess uploaded financial data file."""
|
| 22 |
+
try:
|
| 23 |
+
# Determine file type and read accordingly
|
| 24 |
+
if uploaded_file.name.endswith('.csv'):
|
| 25 |
+
df = pd.read_csv(uploaded_file)
|
| 26 |
+
elif uploaded_file.name.endswith(('.xlsx', '.xls')):
|
| 27 |
+
df = pd.read_excel(uploaded_file)
|
| 28 |
+
else:
|
| 29 |
+
st.error("Unsupported file format. Please upload CSV or Excel files.")
|
| 30 |
+
return None
|
| 31 |
+
|
| 32 |
+
# Clean and standardize the dataframe
|
| 33 |
+
df_cleaned = self._clean_dataframe(df)
|
| 34 |
+
|
| 35 |
+
if df_cleaned is not None:
|
| 36 |
+
st.success(f"Successfully loaded {len(df_cleaned)} transactions")
|
| 37 |
+
return df_cleaned
|
| 38 |
+
else:
|
| 39 |
+
return None
|
| 40 |
+
|
| 41 |
+
except Exception as e:
|
| 42 |
+
st.error(f"Error reading file: {str(e)}")
|
| 43 |
+
return None
|
| 44 |
+
|
| 45 |
+
def _clean_dataframe(self, df: pd.DataFrame) -> Optional[pd.DataFrame]:
|
| 46 |
+
"""Clean and standardize the dataframe structure."""
|
| 47 |
+
try:
|
| 48 |
+
# Map columns to standard names
|
| 49 |
+
df_mapped = self._map_columns(df)
|
| 50 |
+
|
| 51 |
+
if df_mapped is None:
|
| 52 |
+
return None
|
| 53 |
+
|
| 54 |
+
# Clean data types and values
|
| 55 |
+
df_cleaned = self._clean_data_types(df_mapped)
|
| 56 |
+
|
| 57 |
+
# Remove invalid transactions
|
| 58 |
+
df_cleaned = self._remove_invalid_transactions(df_cleaned)
|
| 59 |
+
|
| 60 |
+
# Add derived columns
|
| 61 |
+
df_cleaned = self._add_derived_columns(df_cleaned)
|
| 62 |
+
|
| 63 |
+
return df_cleaned
|
| 64 |
+
|
| 65 |
+
except Exception as e:
|
| 66 |
+
st.error(f"Error cleaning data: {str(e)}")
|
| 67 |
+
return None
|
| 68 |
+
|
| 69 |
+
def _map_columns(self, df: pd.DataFrame) -> Optional[pd.DataFrame]:
|
| 70 |
+
"""Map column names to standard format."""
|
| 71 |
+
df_copy = df.copy()
|
| 72 |
+
column_mapping = {}
|
| 73 |
+
|
| 74 |
+
# Find matching columns for each required field
|
| 75 |
+
for required_col in self.required_columns:
|
| 76 |
+
found_column = None
|
| 77 |
+
|
| 78 |
+
for col in df_copy.columns:
|
| 79 |
+
if col.lower().strip() in [mapping.lower() for mapping in self.column_mappings[required_col]]:
|
| 80 |
+
found_column = col
|
| 81 |
+
break
|
| 82 |
+
|
| 83 |
+
if found_column:
|
| 84 |
+
column_mapping[found_column] = required_col
|
| 85 |
+
else:
|
| 86 |
+
st.error(f"Required column '{required_col}' not found. Available columns: {list(df_copy.columns)}")
|
| 87 |
+
return None
|
| 88 |
+
|
| 89 |
+
# Rename columns
|
| 90 |
+
df_copy = df_copy.rename(columns=column_mapping)
|
| 91 |
+
|
| 92 |
+
# Keep only required columns and any additional useful columns
|
| 93 |
+
columns_to_keep = self.required_columns.copy()
|
| 94 |
+
|
| 95 |
+
# Add any remaining columns that might be useful
|
| 96 |
+
for col in df_copy.columns:
|
| 97 |
+
if col not in columns_to_keep and col.lower() in ['category', 'type', 'account', 'balance']:
|
| 98 |
+
columns_to_keep.append(col)
|
| 99 |
+
|
| 100 |
+
return df_copy[columns_to_keep]
|
| 101 |
+
|
| 102 |
+
def _clean_data_types(self, df: pd.DataFrame) -> pd.DataFrame:
|
| 103 |
+
"""Clean and convert data types."""
|
| 104 |
+
df_copy = df.copy()
|
| 105 |
+
|
| 106 |
+
# Clean and convert date column
|
| 107 |
+
try:
|
| 108 |
+
df_copy['date'] = pd.to_datetime(df_copy['date'], errors='coerce')
|
| 109 |
+
except Exception as e:
|
| 110 |
+
st.warning(f"Date conversion issues: {str(e)}")
|
| 111 |
+
df_copy['date'] = pd.to_datetime(df_copy['date'], errors='coerce', infer_datetime_format=True)
|
| 112 |
+
|
| 113 |
+
# Clean and convert amount column
|
| 114 |
+
if df_copy['amount'].dtype == 'object':
|
| 115 |
+
# Remove currency symbols and convert to numeric
|
| 116 |
+
df_copy['amount'] = df_copy['amount'].astype(str).str.replace(r'[^\d.-]', '', regex=True)
|
| 117 |
+
df_copy['amount'] = pd.to_numeric(df_copy['amount'], errors='coerce')
|
| 118 |
+
|
| 119 |
+
# Clean description column
|
| 120 |
+
df_copy['description'] = df_copy['description'].astype(str).str.strip()
|
| 121 |
+
|
| 122 |
+
return df_copy
|
| 123 |
+
|
| 124 |
+
def _remove_invalid_transactions(self, df: pd.DataFrame) -> pd.DataFrame:
|
| 125 |
+
"""Remove transactions with invalid or missing data."""
|
| 126 |
+
initial_count = len(df)
|
| 127 |
+
|
| 128 |
+
# Remove rows with missing essential data
|
| 129 |
+
df_clean = df.dropna(subset=['date', 'description', 'amount'])
|
| 130 |
+
|
| 131 |
+
# Remove transactions with zero amounts (optional)
|
| 132 |
+
df_clean = df_clean[df_clean['amount'] != 0]
|
| 133 |
+
|
| 134 |
+
# Remove future dates
|
| 135 |
+
df_clean = df_clean[df_clean['date'] <= datetime.now()]
|
| 136 |
+
|
| 137 |
+
removed_count = initial_count - len(df_clean)
|
| 138 |
+
if removed_count > 0:
|
| 139 |
+
st.info(f"Removed {removed_count} invalid transactions")
|
| 140 |
+
|
| 141 |
+
return df_clean
|
| 142 |
+
|
| 143 |
+
def _add_derived_columns(self, df: pd.DataFrame) -> pd.DataFrame:
|
| 144 |
+
"""Add useful derived columns."""
|
| 145 |
+
df_copy = df.copy()
|
| 146 |
+
|
| 147 |
+
# Add transaction type (debit/credit)
|
| 148 |
+
df_copy['transaction_type'] = df_copy['amount'].apply(
|
| 149 |
+
lambda x: 'credit' if x > 0 else 'debit'
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
# Add absolute amount for easier analysis
|
| 153 |
+
df_copy['abs_amount'] = df_copy['amount'].abs()
|
| 154 |
+
|
| 155 |
+
# Add month and year columns
|
| 156 |
+
df_copy['month'] = df_copy['date'].dt.month
|
| 157 |
+
df_copy['year'] = df_copy['date'].dt.year
|
| 158 |
+
df_copy['month_year'] = df_copy['date'].dt.to_period('M')
|
| 159 |
+
|
| 160 |
+
# Add day of week
|
| 161 |
+
df_copy['day_of_week'] = df_copy['date'].dt.day_name()
|
| 162 |
+
|
| 163 |
+
return df_copy
|
| 164 |
+
|
| 165 |
+
def get_summary_stats(self, df: pd.DataFrame) -> Dict[str, Any]:
|
| 166 |
+
"""Generate summary statistics for the dataset."""
|
| 167 |
+
return {
|
| 168 |
+
'total_transactions': len(df),
|
| 169 |
+
'date_range': {
|
| 170 |
+
'start': df['date'].min(),
|
| 171 |
+
'end': df['date'].max()
|
| 172 |
+
},
|
| 173 |
+
'total_debits': df[df['amount'] < 0]['amount'].sum(),
|
| 174 |
+
'total_credits': df[df['amount'] > 0]['amount'].sum(),
|
| 175 |
+
'net_amount': df['amount'].sum(),
|
| 176 |
+
'avg_transaction': df['amount'].mean(),
|
| 177 |
+
'unique_descriptions': df['description'].nunique()
|
| 178 |
+
}
|
expense_categorizer.py
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import numpy as np
|
| 4 |
+
from typing import List, Dict, Any
|
| 5 |
+
import re
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
class ExpenseCategorizer:
|
| 9 |
+
"""Automatically categorizes expenses using transformer models."""
|
| 10 |
+
|
| 11 |
+
def __init__(self):
|
| 12 |
+
self.categories = [
|
| 13 |
+
"Food & Dining",
|
| 14 |
+
"Transportation",
|
| 15 |
+
"Shopping",
|
| 16 |
+
"Bills & Utilities",
|
| 17 |
+
"Entertainment",
|
| 18 |
+
"Health & Medical",
|
| 19 |
+
"Travel",
|
| 20 |
+
"Education",
|
| 21 |
+
"Insurance",
|
| 22 |
+
"Investment",
|
| 23 |
+
"Income",
|
| 24 |
+
"Transfer",
|
| 25 |
+
"Other"
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
# Initialize the classification pipeline
|
| 29 |
+
self.classifier = None
|
| 30 |
+
self._initialize_classifier()
|
| 31 |
+
|
| 32 |
+
# Keyword mappings for fallback categorization
|
| 33 |
+
self.keyword_mappings = {
|
| 34 |
+
"Food & Dining": [
|
| 35 |
+
"restaurant", "cafe", "food", "dining", "pizza", "burger", "starbucks",
|
| 36 |
+
"mcdonald", "subway", "grocery", "market", "supermarket", "uber eats",
|
| 37 |
+
"doordash", "grubhub", "delivery", "takeout"
|
| 38 |
+
],
|
| 39 |
+
"Transportation": [
|
| 40 |
+
"gas", "fuel", "uber", "lyft", "taxi", "bus", "train", "metro",
|
| 41 |
+
"parking", "toll", "car", "vehicle", "auto", "mechanic", "tire"
|
| 42 |
+
],
|
| 43 |
+
"Shopping": [
|
| 44 |
+
"amazon", "walmart", "target", "mall", "store", "retail", "clothing",
|
| 45 |
+
"shoes", "electronics", "books", "home depot", "lowes"
|
| 46 |
+
],
|
| 47 |
+
"Bills & Utilities": [
|
| 48 |
+
"electric", "electricity", "gas bill", "water", "internet", "phone",
|
| 49 |
+
"cable", "subscription", "netflix", "spotify", "utility", "bill"
|
| 50 |
+
],
|
| 51 |
+
"Entertainment": [
|
| 52 |
+
"movie", "cinema", "theater", "concert", "game", "sport", "gym",
|
| 53 |
+
"fitness", "netflix", "spotify", "entertainment", "club", "bar"
|
| 54 |
+
],
|
| 55 |
+
"Health & Medical": [
|
| 56 |
+
"doctor", "hospital", "pharmacy", "medical", "health", "dental",
|
| 57 |
+
"vision", "clinic", "prescription", "medicine", "cvs", "walgreens"
|
| 58 |
+
],
|
| 59 |
+
"Travel": [
|
| 60 |
+
"airline", "flight", "hotel", "airbnb", "rental car", "vacation",
|
| 61 |
+
"travel", "booking", "expedia", "trip", "resort"
|
| 62 |
+
],
|
| 63 |
+
"Education": [
|
| 64 |
+
"school", "university", "college", "tuition", "education", "book",
|
| 65 |
+
"course", "training", "certification"
|
| 66 |
+
],
|
| 67 |
+
"Insurance": [
|
| 68 |
+
"insurance", "premium", "policy", "coverage", "deductible"
|
| 69 |
+
],
|
| 70 |
+
"Investment": [
|
| 71 |
+
"investment", "stock", "bond", "mutual fund", "401k", "ira",
|
| 72 |
+
"retirement", "savings", "dividend", "brokerage"
|
| 73 |
+
],
|
| 74 |
+
"Income": [
|
| 75 |
+
"salary", "payroll", "wage", "bonus", "refund", "cashback",
|
| 76 |
+
"deposit", "payment received", "income"
|
| 77 |
+
],
|
| 78 |
+
"Transfer": [
|
| 79 |
+
"transfer", "atm", "withdrawal", "deposit", "check", "wire",
|
| 80 |
+
"payment to", "send money"
|
| 81 |
+
]
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
def _initialize_classifier(self):
|
| 85 |
+
"""Initialize the transformer-based classifier."""
|
| 86 |
+
# For now, use keyword-based categorization only
|
| 87 |
+
# AI model will be added when transformers dependency is resolved
|
| 88 |
+
self.classifier = None
|
| 89 |
+
st.info("🔍 Using keyword-based categorization (AI categorization coming soon!)")
|
| 90 |
+
|
| 91 |
+
def categorize_transactions(self, df: pd.DataFrame) -> pd.DataFrame:
|
| 92 |
+
"""Categorize all transactions in the dataframe."""
|
| 93 |
+
df_copy = df.copy()
|
| 94 |
+
|
| 95 |
+
# Add category column if it doesn't exist
|
| 96 |
+
if 'category' not in df_copy.columns:
|
| 97 |
+
df_copy['category'] = 'Other'
|
| 98 |
+
|
| 99 |
+
total_transactions = len(df_copy)
|
| 100 |
+
progress_bar = st.progress(0)
|
| 101 |
+
status_text = st.empty()
|
| 102 |
+
|
| 103 |
+
for i, (idx, row) in enumerate(df_copy.iterrows()):
|
| 104 |
+
# Update progress
|
| 105 |
+
progress = min(1.0, (i + 1) / total_transactions)
|
| 106 |
+
progress_bar.progress(progress)
|
| 107 |
+
status_text.text(f"Categorizing transaction {i + 1} of {total_transactions}")
|
| 108 |
+
|
| 109 |
+
# Categorize the transaction
|
| 110 |
+
category = self._categorize_single_transaction(row['description'], row.get('amount', 0))
|
| 111 |
+
df_copy.at[idx, 'category'] = category
|
| 112 |
+
|
| 113 |
+
# Clean up progress indicators
|
| 114 |
+
progress_bar.empty()
|
| 115 |
+
status_text.empty()
|
| 116 |
+
|
| 117 |
+
return df_copy
|
| 118 |
+
|
| 119 |
+
def _categorize_single_transaction(self, description: str, amount: float = 0) -> str:
|
| 120 |
+
"""Categorize a single transaction."""
|
| 121 |
+
description = str(description).lower().strip()
|
| 122 |
+
|
| 123 |
+
# First, try keyword-based categorization for speed
|
| 124 |
+
keyword_category = self._categorize_by_keywords(description, amount)
|
| 125 |
+
|
| 126 |
+
if keyword_category != "Other":
|
| 127 |
+
return keyword_category
|
| 128 |
+
|
| 129 |
+
# If keyword categorization fails and transformer is available, use AI
|
| 130 |
+
if self.classifier is not None:
|
| 131 |
+
try:
|
| 132 |
+
result = self.classifier(description, self.categories)
|
| 133 |
+
# Return the category with highest score if confidence is reasonable
|
| 134 |
+
if result['scores'][0] > 0.3: # Confidence threshold
|
| 135 |
+
return result['labels'][0]
|
| 136 |
+
except Exception as e:
|
| 137 |
+
# Fallback to keyword categorization if AI fails
|
| 138 |
+
pass
|
| 139 |
+
|
| 140 |
+
return "Other"
|
| 141 |
+
|
| 142 |
+
def _categorize_by_keywords(self, description: str, amount: float = 0) -> str:
|
| 143 |
+
"""Categorize transaction based on keyword matching."""
|
| 144 |
+
description_lower = description.lower()
|
| 145 |
+
|
| 146 |
+
# Special handling for income (positive amounts with specific keywords)
|
| 147 |
+
if amount > 0:
|
| 148 |
+
income_keywords = ["salary", "payroll", "deposit", "refund", "cashback", "dividend"]
|
| 149 |
+
if any(keyword in description_lower for keyword in income_keywords):
|
| 150 |
+
return "Income"
|
| 151 |
+
|
| 152 |
+
# Check each category's keywords
|
| 153 |
+
for category, keywords in self.keyword_mappings.items():
|
| 154 |
+
if any(keyword in description_lower for keyword in keywords):
|
| 155 |
+
return category
|
| 156 |
+
|
| 157 |
+
return "Other"
|
| 158 |
+
|
| 159 |
+
def get_category_distribution(self, df: pd.DataFrame) -> Dict[str, Any]:
|
| 160 |
+
"""Get distribution of categories in the dataset."""
|
| 161 |
+
if 'category' not in df.columns:
|
| 162 |
+
return {}
|
| 163 |
+
|
| 164 |
+
category_counts = df['category'].value_counts()
|
| 165 |
+
category_amounts = df.groupby('category')['amount'].sum().abs()
|
| 166 |
+
|
| 167 |
+
return {
|
| 168 |
+
'counts': category_counts.to_dict(),
|
| 169 |
+
'amounts': category_amounts.to_dict(),
|
| 170 |
+
'percentages': (category_counts / len(df) * 100).to_dict()
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
def suggest_custom_categories(self, df: pd.DataFrame) -> List[str]:
|
| 174 |
+
"""Suggest custom categories based on frequent transaction patterns."""
|
| 175 |
+
if 'description' not in df.columns:
|
| 176 |
+
return []
|
| 177 |
+
|
| 178 |
+
# Extract common words from descriptions
|
| 179 |
+
all_descriptions = ' '.join(df['description'].astype(str).str.lower())
|
| 180 |
+
words = re.findall(r'\b[a-zA-Z]{3,}\b', all_descriptions)
|
| 181 |
+
|
| 182 |
+
# Count word frequency
|
| 183 |
+
from collections import Counter
|
| 184 |
+
word_counts = Counter(words)
|
| 185 |
+
|
| 186 |
+
# Get most common words that aren't already in our categories
|
| 187 |
+
common_words = [word for word, count in word_counts.most_common(20)
|
| 188 |
+
if count > 5 and len(word) > 3]
|
| 189 |
+
|
| 190 |
+
# Filter out common stop words and already categorized terms
|
| 191 |
+
stop_words = {'the', 'and', 'for', 'with', 'from', 'payment', 'transaction'}
|
| 192 |
+
suggestions = [word.title() for word in common_words
|
| 193 |
+
if word not in stop_words]
|
| 194 |
+
|
| 195 |
+
return suggestions[:10] # Return top 10 suggestions
|
financial_calendar.py
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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graph_objects as go
|
| 6 |
+
import plotly.express as px
|
| 7 |
+
from plotly.subplots import make_subplots
|
| 8 |
+
import calendar
|
| 9 |
+
|
| 10 |
+
class FinancialCalendar:
|
| 11 |
+
"""Interactive financial calendar with spending patterns and insights."""
|
| 12 |
+
|
| 13 |
+
def __init__(self):
|
| 14 |
+
self.color_scheme = {
|
| 15 |
+
'income': '#4CAF50',
|
| 16 |
+
'expense': '#F44336',
|
| 17 |
+
'recurring': '#FF9800',
|
| 18 |
+
'unusual': '#9C27B0'
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
def create_calendar_view(self, df: pd.DataFrame, year: int = None, month: int = None) -> Dict[str, Any]:
|
| 22 |
+
"""Create calendar view of financial transactions."""
|
| 23 |
+
|
| 24 |
+
if year is None:
|
| 25 |
+
year = datetime.now().year
|
| 26 |
+
if month is None:
|
| 27 |
+
month = datetime.now().month
|
| 28 |
+
|
| 29 |
+
# Filter data for the specified month/year
|
| 30 |
+
calendar_data = df[
|
| 31 |
+
(df['date'].dt.year == year) &
|
| 32 |
+
(df['date'].dt.month == month)
|
| 33 |
+
].copy()
|
| 34 |
+
|
| 35 |
+
# Group transactions by day
|
| 36 |
+
daily_summary = self._create_daily_summary(calendar_data)
|
| 37 |
+
|
| 38 |
+
# Identify patterns
|
| 39 |
+
patterns = self._identify_spending_patterns(calendar_data)
|
| 40 |
+
|
| 41 |
+
# Create calendar heatmap data
|
| 42 |
+
calendar_matrix = self._create_calendar_matrix(daily_summary, year, month)
|
| 43 |
+
|
| 44 |
+
return {
|
| 45 |
+
'calendar_matrix': calendar_matrix,
|
| 46 |
+
'daily_summary': daily_summary,
|
| 47 |
+
'patterns': patterns,
|
| 48 |
+
'month_stats': self._calculate_month_stats(calendar_data),
|
| 49 |
+
'year': year,
|
| 50 |
+
'month': month
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
def _create_daily_summary(self, df: pd.DataFrame) -> Dict[int, Dict[str, Any]]:
|
| 54 |
+
"""Create summary for each day of the month."""
|
| 55 |
+
daily_summary = {}
|
| 56 |
+
|
| 57 |
+
for day in range(1, 32): # Maximum days in a month
|
| 58 |
+
day_data = df[df['date'].dt.day == day]
|
| 59 |
+
|
| 60 |
+
if len(day_data) > 0:
|
| 61 |
+
total_income = day_data[day_data['amount'] > 0]['amount'].sum()
|
| 62 |
+
total_expense = abs(day_data[day_data['amount'] < 0]['amount'].sum())
|
| 63 |
+
net_flow = total_income - total_expense
|
| 64 |
+
|
| 65 |
+
# Categorize transactions
|
| 66 |
+
categories = {}
|
| 67 |
+
if 'category' in day_data.columns:
|
| 68 |
+
categories = day_data[day_data['amount'] < 0].groupby('category')['amount'].sum().abs().to_dict()
|
| 69 |
+
|
| 70 |
+
daily_summary[day] = {
|
| 71 |
+
'total_income': total_income,
|
| 72 |
+
'total_expense': total_expense,
|
| 73 |
+
'net_flow': net_flow,
|
| 74 |
+
'transaction_count': len(day_data),
|
| 75 |
+
'categories': categories,
|
| 76 |
+
'transactions': day_data[['description', 'amount', 'category']].to_dict('records') if 'category' in day_data.columns else day_data[['description', 'amount']].to_dict('records'),
|
| 77 |
+
'day_type': self._classify_day_type(day_data, total_expense)
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
return daily_summary
|
| 81 |
+
|
| 82 |
+
def _classify_day_type(self, day_data: pd.DataFrame, total_expense: float) -> str:
|
| 83 |
+
"""Classify the type of spending day."""
|
| 84 |
+
|
| 85 |
+
if len(day_data) == 0:
|
| 86 |
+
return 'inactive'
|
| 87 |
+
|
| 88 |
+
# Check for income
|
| 89 |
+
if any(day_data['amount'] > 0):
|
| 90 |
+
return 'income_day'
|
| 91 |
+
|
| 92 |
+
# Check for high spending
|
| 93 |
+
if total_expense > 200: # Threshold for high spending
|
| 94 |
+
return 'high_spending'
|
| 95 |
+
|
| 96 |
+
# Check for recurring bills
|
| 97 |
+
recurring_keywords = ['bill', 'payment', 'subscription', 'rent', 'mortgage', 'insurance']
|
| 98 |
+
if any(keyword in desc.lower() for desc in day_data['description'].astype(str) for keyword in recurring_keywords):
|
| 99 |
+
return 'bills_day'
|
| 100 |
+
|
| 101 |
+
# Regular spending
|
| 102 |
+
if total_expense > 0:
|
| 103 |
+
return 'regular_spending'
|
| 104 |
+
|
| 105 |
+
return 'inactive'
|
| 106 |
+
|
| 107 |
+
def _identify_spending_patterns(self, df: pd.DataFrame) -> Dict[str, Any]:
|
| 108 |
+
"""Identify spending patterns within the month."""
|
| 109 |
+
patterns = {
|
| 110 |
+
'busiest_days': [],
|
| 111 |
+
'highest_spending_days': [],
|
| 112 |
+
'recurring_patterns': [],
|
| 113 |
+
'weekend_vs_weekday': {},
|
| 114 |
+
'category_patterns': {}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
if len(df) == 0:
|
| 118 |
+
return patterns
|
| 119 |
+
|
| 120 |
+
# Busiest days (most transactions)
|
| 121 |
+
daily_counts = df.groupby(df['date'].dt.day).size()
|
| 122 |
+
patterns['busiest_days'] = daily_counts.nlargest(3).to_dict()
|
| 123 |
+
|
| 124 |
+
# Highest spending days
|
| 125 |
+
daily_spending = df[df['amount'] < 0].groupby(df['date'].dt.day)['amount'].sum().abs()
|
| 126 |
+
patterns['highest_spending_days'] = daily_spending.nlargest(3).to_dict()
|
| 127 |
+
|
| 128 |
+
# Weekend vs Weekday analysis
|
| 129 |
+
df['is_weekend'] = df['date'].dt.weekday >= 5
|
| 130 |
+
weekend_spending = abs(df[(df['amount'] < 0) & (df['is_weekend'])]['amount'].sum())
|
| 131 |
+
weekday_spending = abs(df[(df['amount'] < 0) & (~df['is_weekend'])]['amount'].sum())
|
| 132 |
+
|
| 133 |
+
patterns['weekend_vs_weekday'] = {
|
| 134 |
+
'weekend_total': weekend_spending,
|
| 135 |
+
'weekday_total': weekday_spending,
|
| 136 |
+
'weekend_preference': weekend_spending > weekday_spending
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
# Category patterns by day of week
|
| 140 |
+
if 'category' in df.columns:
|
| 141 |
+
category_by_day = df[df['amount'] < 0].groupby([df['date'].dt.day_name(), 'category'])['amount'].sum().abs()
|
| 142 |
+
patterns['category_patterns'] = category_by_day.to_dict()
|
| 143 |
+
|
| 144 |
+
return patterns
|
| 145 |
+
|
| 146 |
+
def _create_calendar_matrix(self, daily_summary: Dict[int, Dict[str, Any]], year: int, month: int) -> List[List[Dict[str, Any]]]:
|
| 147 |
+
"""Create matrix representation of calendar for visualization."""
|
| 148 |
+
|
| 149 |
+
# Get calendar layout
|
| 150 |
+
cal = calendar.monthcalendar(year, month)
|
| 151 |
+
calendar_matrix = []
|
| 152 |
+
|
| 153 |
+
for week in cal:
|
| 154 |
+
week_data = []
|
| 155 |
+
for day in week:
|
| 156 |
+
if day == 0:
|
| 157 |
+
# Empty cell for days not in this month
|
| 158 |
+
week_data.append({
|
| 159 |
+
'day': 0,
|
| 160 |
+
'empty': True,
|
| 161 |
+
'spending': 0,
|
| 162 |
+
'income': 0,
|
| 163 |
+
'net': 0,
|
| 164 |
+
'type': 'empty'
|
| 165 |
+
})
|
| 166 |
+
else:
|
| 167 |
+
day_info = daily_summary.get(day, {})
|
| 168 |
+
week_data.append({
|
| 169 |
+
'day': day,
|
| 170 |
+
'empty': False,
|
| 171 |
+
'spending': day_info.get('total_expense', 0),
|
| 172 |
+
'income': day_info.get('total_income', 0),
|
| 173 |
+
'net': day_info.get('net_flow', 0),
|
| 174 |
+
'transactions': day_info.get('transaction_count', 0),
|
| 175 |
+
'type': day_info.get('day_type', 'inactive'),
|
| 176 |
+
'categories': day_info.get('categories', {})
|
| 177 |
+
})
|
| 178 |
+
calendar_matrix.append(week_data)
|
| 179 |
+
|
| 180 |
+
return calendar_matrix
|
| 181 |
+
|
| 182 |
+
def _calculate_month_stats(self, df: pd.DataFrame) -> Dict[str, Any]:
|
| 183 |
+
"""Calculate monthly statistics."""
|
| 184 |
+
|
| 185 |
+
total_income = df[df['amount'] > 0]['amount'].sum()
|
| 186 |
+
total_expense = abs(df[df['amount'] < 0]['amount'].sum())
|
| 187 |
+
transaction_count = len(df)
|
| 188 |
+
|
| 189 |
+
# Day-wise breakdown
|
| 190 |
+
daily_avg_expense = total_expense / max(1, len(df['date'].dt.day.unique())) if len(df) > 0 else 0
|
| 191 |
+
|
| 192 |
+
# Most active day
|
| 193 |
+
most_active_day = df['date'].dt.day_name().value_counts().index[0] if len(df) > 0 else 'N/A'
|
| 194 |
+
|
| 195 |
+
return {
|
| 196 |
+
'total_income': total_income,
|
| 197 |
+
'total_expense': total_expense,
|
| 198 |
+
'net_flow': total_income - total_expense,
|
| 199 |
+
'transaction_count': transaction_count,
|
| 200 |
+
'daily_avg_expense': daily_avg_expense,
|
| 201 |
+
'most_active_day': most_active_day,
|
| 202 |
+
'spending_days': len(df[df['amount'] < 0]['date'].dt.day.unique()),
|
| 203 |
+
'income_days': len(df[df['amount'] > 0]['date'].dt.day.unique())
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
def create_calendar_heatmap(self, calendar_data: Dict[str, Any]) -> go.Figure:
|
| 207 |
+
"""Create calendar heatmap visualization."""
|
| 208 |
+
|
| 209 |
+
calendar_matrix = calendar_data['calendar_matrix']
|
| 210 |
+
year = calendar_data['year']
|
| 211 |
+
month = calendar_data['month']
|
| 212 |
+
|
| 213 |
+
# Prepare data for heatmap
|
| 214 |
+
spending_values = []
|
| 215 |
+
day_labels = []
|
| 216 |
+
hover_text = []
|
| 217 |
+
|
| 218 |
+
for week_idx, week in enumerate(calendar_matrix):
|
| 219 |
+
week_spending = []
|
| 220 |
+
week_labels = []
|
| 221 |
+
week_hover = []
|
| 222 |
+
|
| 223 |
+
for day_data in week:
|
| 224 |
+
if day_data['empty']:
|
| 225 |
+
week_spending.append(0)
|
| 226 |
+
week_labels.append('')
|
| 227 |
+
week_hover.append('')
|
| 228 |
+
else:
|
| 229 |
+
week_spending.append(day_data['spending'])
|
| 230 |
+
week_labels.append(str(day_data['day']))
|
| 231 |
+
|
| 232 |
+
hover_info = f"Day {day_data['day']}<br>"
|
| 233 |
+
hover_info += f"Spending: ${day_data['spending']:.2f}<br>"
|
| 234 |
+
hover_info += f"Income: ${day_data['income']:.2f}<br>"
|
| 235 |
+
hover_info += f"Net: ${day_data['net']:.2f}<br>"
|
| 236 |
+
hover_info += f"Transactions: {day_data['transactions']}"
|
| 237 |
+
week_hover.append(hover_info)
|
| 238 |
+
|
| 239 |
+
spending_values.append(week_spending)
|
| 240 |
+
day_labels.append(week_labels)
|
| 241 |
+
hover_text.append(week_hover)
|
| 242 |
+
|
| 243 |
+
# Create heatmap
|
| 244 |
+
fig = go.Figure(data=go.Heatmap(
|
| 245 |
+
z=spending_values,
|
| 246 |
+
text=day_labels,
|
| 247 |
+
hovertext=hover_text,
|
| 248 |
+
hovertemplate='%{hovertext}<extra></extra>',
|
| 249 |
+
colorscale='Reds',
|
| 250 |
+
showscale=True,
|
| 251 |
+
colorbar=dict(title="Daily Spending ($)")
|
| 252 |
+
))
|
| 253 |
+
|
| 254 |
+
# Add day of week labels
|
| 255 |
+
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
| 256 |
+
|
| 257 |
+
fig.update_layout(
|
| 258 |
+
title=f'Financial Calendar - {calendar.month_name[month]} {year}',
|
| 259 |
+
xaxis=dict(
|
| 260 |
+
tickvals=list(range(7)),
|
| 261 |
+
ticktext=weekdays,
|
| 262 |
+
title='Day of Week'
|
| 263 |
+
),
|
| 264 |
+
yaxis=dict(
|
| 265 |
+
tickvals=list(range(len(calendar_matrix))),
|
| 266 |
+
ticktext=[f'Week {i+1}' for i in range(len(calendar_matrix))],
|
| 267 |
+
title='Week'
|
| 268 |
+
),
|
| 269 |
+
height=400,
|
| 270 |
+
width=600
|
| 271 |
+
)
|
| 272 |
+
|
| 273 |
+
return fig
|
| 274 |
+
|
| 275 |
+
def create_spending_pattern_chart(self, patterns: Dict[str, Any]) -> go.Figure:
|
| 276 |
+
"""Create visualization of spending patterns."""
|
| 277 |
+
|
| 278 |
+
fig = make_subplots(
|
| 279 |
+
rows=2, cols=2,
|
| 280 |
+
subplot_titles=('Busiest Days', 'Highest Spending Days', 'Weekend vs Weekday', 'Daily Average'),
|
| 281 |
+
specs=[[{'type': 'bar'}, {'type': 'bar'}],
|
| 282 |
+
[{'type': 'pie'}, {'type': 'bar'}]]
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
# Busiest days
|
| 286 |
+
if patterns['busiest_days']:
|
| 287 |
+
days = list(patterns['busiest_days'].keys())
|
| 288 |
+
counts = list(patterns['busiest_days'].values())
|
| 289 |
+
|
| 290 |
+
fig.add_trace(go.Bar(
|
| 291 |
+
x=[f"Day {d}" for d in days],
|
| 292 |
+
y=counts,
|
| 293 |
+
name='Transactions',
|
| 294 |
+
marker_color='lightblue'
|
| 295 |
+
), row=1, col=1)
|
| 296 |
+
|
| 297 |
+
# Highest spending days
|
| 298 |
+
if patterns['highest_spending_days']:
|
| 299 |
+
spend_days = list(patterns['highest_spending_days'].keys())
|
| 300 |
+
spend_amounts = list(patterns['highest_spending_days'].values())
|
| 301 |
+
|
| 302 |
+
fig.add_trace(go.Bar(
|
| 303 |
+
x=[f"Day {d}" for d in spend_days],
|
| 304 |
+
y=spend_amounts,
|
| 305 |
+
name='Spending ($)',
|
| 306 |
+
marker_color='lightcoral'
|
| 307 |
+
), row=1, col=2)
|
| 308 |
+
|
| 309 |
+
# Weekend vs Weekday pie chart
|
| 310 |
+
weekend_weekday = patterns['weekend_vs_weekday']
|
| 311 |
+
if weekend_weekday:
|
| 312 |
+
fig.add_trace(go.Pie(
|
| 313 |
+
labels=['Weekend', 'Weekday'],
|
| 314 |
+
values=[weekend_weekday['weekend_total'], weekend_weekday['weekday_total']],
|
| 315 |
+
name='Spending Distribution'
|
| 316 |
+
), row=2, col=1)
|
| 317 |
+
|
| 318 |
+
fig.update_layout(
|
| 319 |
+
height=600,
|
| 320 |
+
showlegend=False,
|
| 321 |
+
title_text="Spending Patterns Analysis"
|
| 322 |
+
)
|
| 323 |
+
|
| 324 |
+
return fig
|
| 325 |
+
|
| 326 |
+
def get_calendar_insights(self, calendar_data: Dict[str, Any]) -> List[str]:
|
| 327 |
+
"""Generate insights from calendar analysis."""
|
| 328 |
+
insights = []
|
| 329 |
+
|
| 330 |
+
patterns = calendar_data['patterns']
|
| 331 |
+
month_stats = calendar_data['month_stats']
|
| 332 |
+
|
| 333 |
+
# Most active day insight
|
| 334 |
+
if month_stats['most_active_day'] != 'N/A':
|
| 335 |
+
insights.append(f"📅 You're most active on {month_stats['most_active_day']}s with financial transactions")
|
| 336 |
+
|
| 337 |
+
# Weekend vs weekday insight
|
| 338 |
+
weekend_data = patterns['weekend_vs_weekday']
|
| 339 |
+
if weekend_data and weekend_data['weekend_preference']:
|
| 340 |
+
weekend_pct = (weekend_data['weekend_total'] / (weekend_data['weekend_total'] + weekend_data['weekday_total'])) * 100
|
| 341 |
+
insights.append(f"🏖️ You spend {weekend_pct:.1f}% of your money on weekends")
|
| 342 |
+
else:
|
| 343 |
+
insights.append(f"💼 You spend more during weekdays than weekends")
|
| 344 |
+
|
| 345 |
+
# High spending days
|
| 346 |
+
if patterns['highest_spending_days']:
|
| 347 |
+
max_day = max(patterns['highest_spending_days'], key=patterns['highest_spending_days'].get)
|
| 348 |
+
max_amount = patterns['highest_spending_days'][max_day]
|
| 349 |
+
insights.append(f"💸 Your highest spending day was day {max_day} with ${max_amount:.2f}")
|
| 350 |
+
|
| 351 |
+
# Spending frequency
|
| 352 |
+
spending_days = month_stats['spending_days']
|
| 353 |
+
total_days_in_month = 31 # Approximate
|
| 354 |
+
spending_frequency = (spending_days / total_days_in_month) * 100
|
| 355 |
+
|
| 356 |
+
if spending_frequency > 80:
|
| 357 |
+
insights.append(f"🛍️ You make purchases almost daily ({spending_frequency:.0f}% of days)")
|
| 358 |
+
elif spending_frequency > 50:
|
| 359 |
+
insights.append(f"🛒 You shop regularly ({spending_frequency:.0f}% of days have transactions)")
|
| 360 |
+
else:
|
| 361 |
+
insights.append(f"💰 You're selective with spending ({spending_frequency:.0f}% of days have purchases)")
|
| 362 |
+
|
| 363 |
+
# Income pattern
|
| 364 |
+
income_days = month_stats['income_days']
|
| 365 |
+
if income_days <= 2:
|
| 366 |
+
insights.append(f"💼 You receive income on {income_days} day(s) per month - consider diversifying income sources")
|
| 367 |
+
|
| 368 |
+
return insights
|
| 369 |
+
|
| 370 |
+
def create_monthly_flow_chart(self, df: pd.DataFrame) -> go.Figure:
|
| 371 |
+
"""Create monthly cash flow visualization."""
|
| 372 |
+
|
| 373 |
+
daily_flow = df.groupby(df['date'].dt.day).agg({
|
| 374 |
+
'amount': lambda x: [x[x > 0].sum(), x[x < 0].sum()]
|
| 375 |
+
})
|
| 376 |
+
|
| 377 |
+
days = daily_flow.index
|
| 378 |
+
income_values = [flow[0] for flow in daily_flow['amount']]
|
| 379 |
+
expense_values = [abs(flow[1]) for flow in daily_flow['amount']]
|
| 380 |
+
net_values = [income - expense for income, expense in zip(income_values, expense_values)]
|
| 381 |
+
|
| 382 |
+
fig = go.Figure()
|
| 383 |
+
|
| 384 |
+
# Income bars
|
| 385 |
+
fig.add_trace(go.Bar(
|
| 386 |
+
x=days,
|
| 387 |
+
y=income_values,
|
| 388 |
+
name='Income',
|
| 389 |
+
marker_color='green',
|
| 390 |
+
opacity=0.7
|
| 391 |
+
))
|
| 392 |
+
|
| 393 |
+
# Expense bars (negative)
|
| 394 |
+
fig.add_trace(go.Bar(
|
| 395 |
+
x=days,
|
| 396 |
+
y=[-exp for exp in expense_values],
|
| 397 |
+
name='Expenses',
|
| 398 |
+
marker_color='red',
|
| 399 |
+
opacity=0.7
|
| 400 |
+
))
|
| 401 |
+
|
| 402 |
+
# Net flow line
|
| 403 |
+
fig.add_trace(go.Scatter(
|
| 404 |
+
x=days,
|
| 405 |
+
y=net_values,
|
| 406 |
+
mode='lines+markers',
|
| 407 |
+
name='Net Flow',
|
| 408 |
+
line=dict(color='blue', width=2),
|
| 409 |
+
marker=dict(size=4)
|
| 410 |
+
))
|
| 411 |
+
|
| 412 |
+
fig.update_layout(
|
| 413 |
+
title='Daily Cash Flow',
|
| 414 |
+
xaxis_title='Day of Month',
|
| 415 |
+
yaxis_title='Amount ($)',
|
| 416 |
+
template='plotly_white',
|
| 417 |
+
height=400,
|
| 418 |
+
barmode='relative'
|
| 419 |
+
)
|
| 420 |
+
|
| 421 |
+
return fig
|
financial_health.py
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import numpy as np
|
| 3 |
+
from datetime import datetime, timedelta
|
| 4 |
+
from typing import Dict, List, Tuple, Any
|
| 5 |
+
import streamlit as st
|
| 6 |
+
|
| 7 |
+
class FinancialHealthAnalyzer:
|
| 8 |
+
"""Calculates personalized financial health scores and provides insights."""
|
| 9 |
+
|
| 10 |
+
def __init__(self):
|
| 11 |
+
self.score_weights = {
|
| 12 |
+
'savings_rate': 0.25,
|
| 13 |
+
'spending_consistency': 0.20,
|
| 14 |
+
'category_balance': 0.15,
|
| 15 |
+
'debt_management': 0.15,
|
| 16 |
+
'income_stability': 0.15,
|
| 17 |
+
'emergency_fund': 0.10
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
def calculate_health_score(self, df: pd.DataFrame) -> Dict[str, Any]:
|
| 21 |
+
"""Calculate comprehensive financial health score (0-100)."""
|
| 22 |
+
scores = {}
|
| 23 |
+
|
| 24 |
+
# 1. Savings Rate Score (25%)
|
| 25 |
+
scores['savings_rate'] = self._calculate_savings_rate_score(df)
|
| 26 |
+
|
| 27 |
+
# 2. Spending Consistency Score (20%)
|
| 28 |
+
scores['spending_consistency'] = self._calculate_consistency_score(df)
|
| 29 |
+
|
| 30 |
+
# 3. Category Balance Score (15%)
|
| 31 |
+
scores['category_balance'] = self._calculate_category_balance_score(df)
|
| 32 |
+
|
| 33 |
+
# 4. Debt Management Score (15%)
|
| 34 |
+
scores['debt_management'] = self._calculate_debt_management_score(df)
|
| 35 |
+
|
| 36 |
+
# 5. Income Stability Score (15%)
|
| 37 |
+
scores['income_stability'] = self._calculate_income_stability_score(df)
|
| 38 |
+
|
| 39 |
+
# 6. Emergency Fund Score (10%)
|
| 40 |
+
scores['emergency_fund'] = self._calculate_emergency_fund_score(df)
|
| 41 |
+
|
| 42 |
+
# Calculate weighted total
|
| 43 |
+
total_score = sum(scores[key] * self.score_weights[key] for key in scores.keys())
|
| 44 |
+
|
| 45 |
+
return {
|
| 46 |
+
'total_score': round(total_score, 1),
|
| 47 |
+
'component_scores': scores,
|
| 48 |
+
'grade': self._get_grade(total_score),
|
| 49 |
+
'insights': self._generate_health_insights(scores, df),
|
| 50 |
+
'improvement_tips': self._generate_improvement_tips(scores)
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
def _calculate_savings_rate_score(self, df: pd.DataFrame) -> float:
|
| 54 |
+
"""Calculate savings rate score based on income vs expenses."""
|
| 55 |
+
monthly_data = df.groupby('month_year').agg({
|
| 56 |
+
'amount': lambda x: [x[x > 0].sum(), x[x < 0].sum()]
|
| 57 |
+
})
|
| 58 |
+
|
| 59 |
+
savings_rates = []
|
| 60 |
+
for month_data in monthly_data['amount']:
|
| 61 |
+
income = month_data[0]
|
| 62 |
+
expenses = abs(month_data[1])
|
| 63 |
+
if income > 0:
|
| 64 |
+
savings_rate = (income - expenses) / income * 100
|
| 65 |
+
savings_rates.append(max(0, savings_rate))
|
| 66 |
+
|
| 67 |
+
if not savings_rates:
|
| 68 |
+
return 50.0
|
| 69 |
+
|
| 70 |
+
avg_savings_rate = np.mean(savings_rates)
|
| 71 |
+
|
| 72 |
+
# Score based on savings rate
|
| 73 |
+
if avg_savings_rate >= 20:
|
| 74 |
+
return 100.0
|
| 75 |
+
elif avg_savings_rate >= 15:
|
| 76 |
+
return 85.0
|
| 77 |
+
elif avg_savings_rate >= 10:
|
| 78 |
+
return 70.0
|
| 79 |
+
elif avg_savings_rate >= 5:
|
| 80 |
+
return 55.0
|
| 81 |
+
elif avg_savings_rate >= 0:
|
| 82 |
+
return 40.0
|
| 83 |
+
else:
|
| 84 |
+
return 20.0
|
| 85 |
+
|
| 86 |
+
def _calculate_consistency_score(self, df: pd.DataFrame) -> float:
|
| 87 |
+
"""Calculate spending consistency score."""
|
| 88 |
+
monthly_expenses = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 89 |
+
|
| 90 |
+
if len(monthly_expenses) < 2:
|
| 91 |
+
return 75.0
|
| 92 |
+
|
| 93 |
+
# Calculate coefficient of variation
|
| 94 |
+
cv = monthly_expenses.std() / monthly_expenses.mean()
|
| 95 |
+
|
| 96 |
+
# Score based on consistency (lower CV = higher score)
|
| 97 |
+
if cv <= 0.1:
|
| 98 |
+
return 100.0
|
| 99 |
+
elif cv <= 0.2:
|
| 100 |
+
return 85.0
|
| 101 |
+
elif cv <= 0.3:
|
| 102 |
+
return 70.0
|
| 103 |
+
elif cv <= 0.5:
|
| 104 |
+
return 55.0
|
| 105 |
+
else:
|
| 106 |
+
return 40.0
|
| 107 |
+
|
| 108 |
+
def _calculate_category_balance_score(self, df: pd.DataFrame) -> float:
|
| 109 |
+
"""Calculate category balance score based on recommended spending ratios."""
|
| 110 |
+
if 'category' not in df.columns:
|
| 111 |
+
return 70.0
|
| 112 |
+
|
| 113 |
+
category_spending = df[df['amount'] < 0].groupby('category')['amount'].sum().abs()
|
| 114 |
+
total_expenses = category_spending.sum()
|
| 115 |
+
|
| 116 |
+
if total_expenses == 0:
|
| 117 |
+
return 70.0
|
| 118 |
+
|
| 119 |
+
# Recommended spending ratios
|
| 120 |
+
recommended_ratios = {
|
| 121 |
+
'Food & Dining': 0.15,
|
| 122 |
+
'Transportation': 0.15,
|
| 123 |
+
'Bills & Utilities': 0.25,
|
| 124 |
+
'Entertainment': 0.05,
|
| 125 |
+
'Shopping': 0.10,
|
| 126 |
+
'Health & Medical': 0.05
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
balance_score = 100.0
|
| 130 |
+
for category, recommended in recommended_ratios.items():
|
| 131 |
+
if category in category_spending:
|
| 132 |
+
actual_ratio = category_spending[category] / total_expenses
|
| 133 |
+
deviation = abs(actual_ratio - recommended)
|
| 134 |
+
# Penalize deviations
|
| 135 |
+
balance_score -= min(30, deviation * 200)
|
| 136 |
+
|
| 137 |
+
return max(40.0, balance_score)
|
| 138 |
+
|
| 139 |
+
def _calculate_debt_management_score(self, df: pd.DataFrame) -> float:
|
| 140 |
+
"""Calculate debt management score."""
|
| 141 |
+
# Look for debt-related transactions
|
| 142 |
+
debt_keywords = ['loan', 'credit card', 'mortgage', 'debt', 'interest']
|
| 143 |
+
debt_transactions = df[df['description'].str.lower().str.contains('|'.join(debt_keywords), na=False)]
|
| 144 |
+
|
| 145 |
+
total_debt_payments = abs(debt_transactions[debt_transactions['amount'] < 0]['amount'].sum())
|
| 146 |
+
total_expenses = abs(df[df['amount'] < 0]['amount'].sum())
|
| 147 |
+
|
| 148 |
+
if total_expenses == 0:
|
| 149 |
+
return 80.0
|
| 150 |
+
|
| 151 |
+
debt_ratio = total_debt_payments / total_expenses
|
| 152 |
+
|
| 153 |
+
# Score based on debt-to-expense ratio
|
| 154 |
+
if debt_ratio <= 0.1:
|
| 155 |
+
return 100.0
|
| 156 |
+
elif debt_ratio <= 0.2:
|
| 157 |
+
return 85.0
|
| 158 |
+
elif debt_ratio <= 0.3:
|
| 159 |
+
return 70.0
|
| 160 |
+
elif debt_ratio <= 0.4:
|
| 161 |
+
return 55.0
|
| 162 |
+
else:
|
| 163 |
+
return 40.0
|
| 164 |
+
|
| 165 |
+
def _calculate_income_stability_score(self, df: pd.DataFrame) -> float:
|
| 166 |
+
"""Calculate income stability score."""
|
| 167 |
+
income_data = df[df['amount'] > 0].groupby('month_year')['amount'].sum()
|
| 168 |
+
|
| 169 |
+
if len(income_data) < 2:
|
| 170 |
+
return 75.0
|
| 171 |
+
|
| 172 |
+
# Calculate coefficient of variation for income
|
| 173 |
+
cv = income_data.std() / income_data.mean()
|
| 174 |
+
|
| 175 |
+
# Score based on income stability
|
| 176 |
+
if cv <= 0.05:
|
| 177 |
+
return 100.0
|
| 178 |
+
elif cv <= 0.1:
|
| 179 |
+
return 85.0
|
| 180 |
+
elif cv <= 0.2:
|
| 181 |
+
return 70.0
|
| 182 |
+
elif cv <= 0.3:
|
| 183 |
+
return 55.0
|
| 184 |
+
else:
|
| 185 |
+
return 40.0
|
| 186 |
+
|
| 187 |
+
def _calculate_emergency_fund_score(self, df: pd.DataFrame) -> float:
|
| 188 |
+
"""Calculate emergency fund score based on savings patterns."""
|
| 189 |
+
# Look for savings-related transactions
|
| 190 |
+
savings_keywords = ['savings', 'emergency', 'fund', 'investment']
|
| 191 |
+
savings_transactions = df[df['description'].str.lower().str.contains('|'.join(savings_keywords), na=False)]
|
| 192 |
+
|
| 193 |
+
monthly_expenses = abs(df[df['amount'] < 0].groupby('month_year')['amount'].sum().mean())
|
| 194 |
+
total_savings = savings_transactions[savings_transactions['amount'] > 0]['amount'].sum()
|
| 195 |
+
|
| 196 |
+
if monthly_expenses == 0:
|
| 197 |
+
return 70.0
|
| 198 |
+
|
| 199 |
+
# Calculate months of expenses covered
|
| 200 |
+
months_covered = total_savings / monthly_expenses
|
| 201 |
+
|
| 202 |
+
# Score based on emergency fund coverage
|
| 203 |
+
if months_covered >= 6:
|
| 204 |
+
return 100.0
|
| 205 |
+
elif months_covered >= 3:
|
| 206 |
+
return 80.0
|
| 207 |
+
elif months_covered >= 1:
|
| 208 |
+
return 60.0
|
| 209 |
+
elif months_covered >= 0.5:
|
| 210 |
+
return 40.0
|
| 211 |
+
else:
|
| 212 |
+
return 20.0
|
| 213 |
+
|
| 214 |
+
def _get_grade(self, score: float) -> str:
|
| 215 |
+
"""Convert numerical score to letter grade."""
|
| 216 |
+
if score >= 90:
|
| 217 |
+
return "A+"
|
| 218 |
+
elif score >= 85:
|
| 219 |
+
return "A"
|
| 220 |
+
elif score >= 80:
|
| 221 |
+
return "B+"
|
| 222 |
+
elif score >= 75:
|
| 223 |
+
return "B"
|
| 224 |
+
elif score >= 70:
|
| 225 |
+
return "C+"
|
| 226 |
+
elif score >= 65:
|
| 227 |
+
return "C"
|
| 228 |
+
elif score >= 60:
|
| 229 |
+
return "D+"
|
| 230 |
+
elif score >= 55:
|
| 231 |
+
return "D"
|
| 232 |
+
else:
|
| 233 |
+
return "F"
|
| 234 |
+
|
| 235 |
+
def _generate_health_insights(self, scores: Dict[str, float], df: pd.DataFrame) -> List[str]:
|
| 236 |
+
"""Generate personalized financial health insights."""
|
| 237 |
+
insights = []
|
| 238 |
+
|
| 239 |
+
# Analyze strongest and weakest areas
|
| 240 |
+
sorted_scores = sorted(scores.items(), key=lambda x: x[1], reverse=True)
|
| 241 |
+
strongest = sorted_scores[0]
|
| 242 |
+
weakest = sorted_scores[-1]
|
| 243 |
+
|
| 244 |
+
insights.append(f"💪 Your strongest area is {strongest[0].replace('_', ' ').title()} ({strongest[1]:.1f}/100)")
|
| 245 |
+
insights.append(f"⚠️ Your weakest area is {weakest[0].replace('_', ' ').title()} ({weakest[1]:.1f}/100)")
|
| 246 |
+
|
| 247 |
+
# Specific insights based on data
|
| 248 |
+
if 'category' in df.columns:
|
| 249 |
+
top_expense = df[df['amount'] < 0].groupby('category')['amount'].sum().abs().idxmax()
|
| 250 |
+
insights.append(f"📊 Your largest expense category is {top_expense}")
|
| 251 |
+
|
| 252 |
+
# Trend insights
|
| 253 |
+
monthly_spending = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 254 |
+
if len(monthly_spending) >= 2:
|
| 255 |
+
trend = "increasing" if monthly_spending.iloc[-1] > monthly_spending.iloc[0] else "decreasing"
|
| 256 |
+
insights.append(f"📈 Your spending trend is {trend} over time")
|
| 257 |
+
|
| 258 |
+
return insights
|
| 259 |
+
|
| 260 |
+
def _generate_improvement_tips(self, scores: Dict[str, float]) -> List[str]:
|
| 261 |
+
"""Generate personalized improvement tips."""
|
| 262 |
+
tips = []
|
| 263 |
+
|
| 264 |
+
for component, score in scores.items():
|
| 265 |
+
if score < 70: # Areas needing improvement
|
| 266 |
+
if component == 'savings_rate':
|
| 267 |
+
tips.append("💡 Try to save at least 20% of your income. Start with the 50/30/20 rule.")
|
| 268 |
+
elif component == 'spending_consistency':
|
| 269 |
+
tips.append("📊 Create a monthly budget to make your spending more predictable.")
|
| 270 |
+
elif component == 'category_balance':
|
| 271 |
+
tips.append("⚖️ Review your spending categories. Consider reducing non-essential expenses.")
|
| 272 |
+
elif component == 'debt_management':
|
| 273 |
+
tips.append("💳 Focus on paying down high-interest debt first to improve your score.")
|
| 274 |
+
elif component == 'income_stability':
|
| 275 |
+
tips.append("💼 Consider diversifying income sources or building a more stable income stream.")
|
| 276 |
+
elif component == 'emergency_fund':
|
| 277 |
+
tips.append("🚨 Build an emergency fund covering 3-6 months of expenses.")
|
| 278 |
+
|
| 279 |
+
if not tips:
|
| 280 |
+
tips.append("🎉 Great job! Your financial health is strong across all areas!")
|
| 281 |
+
|
| 282 |
+
return tips
|
| 283 |
+
|
| 284 |
+
def create_health_score_visualization(self, health_data: Dict[str, Any]):
|
| 285 |
+
"""Create visual representation of financial health score."""
|
| 286 |
+
import plotly.graph_objects as go
|
| 287 |
+
from plotly.subplots import make_subplots
|
| 288 |
+
|
| 289 |
+
# Create gauge chart for overall score
|
| 290 |
+
fig = go.Figure(go.Indicator(
|
| 291 |
+
mode = "gauge+number+delta",
|
| 292 |
+
value = health_data['total_score'],
|
| 293 |
+
domain = {'x': [0, 1], 'y': [0, 1]},
|
| 294 |
+
title = {'text': f"Financial Health Score<br><span style='font-size:0.8em;color:gray'>{health_data['grade']}</span>"},
|
| 295 |
+
delta = {'reference': 75},
|
| 296 |
+
gauge = {
|
| 297 |
+
'axis': {'range': [None, 100]},
|
| 298 |
+
'bar': {'color': "darkblue"},
|
| 299 |
+
'steps': [
|
| 300 |
+
{'range': [0, 50], 'color': "lightgray"},
|
| 301 |
+
{'range': [50, 80], 'color': "yellow"},
|
| 302 |
+
{'range': [80, 100], 'color': "green"}
|
| 303 |
+
],
|
| 304 |
+
'threshold': {
|
| 305 |
+
'line': {'color': "red", 'width': 4},
|
| 306 |
+
'thickness': 0.75,
|
| 307 |
+
'value': 90
|
| 308 |
+
}
|
| 309 |
+
}
|
| 310 |
+
))
|
| 311 |
+
|
| 312 |
+
fig.update_layout(height=300)
|
| 313 |
+
return fig
|
| 314 |
+
|
| 315 |
+
def create_component_scores_chart(self, component_scores: Dict[str, float]):
|
| 316 |
+
"""Create radar chart for component scores."""
|
| 317 |
+
import plotly.graph_objects as go
|
| 318 |
+
|
| 319 |
+
categories = [name.replace('_', ' ').title() for name in component_scores.keys()]
|
| 320 |
+
values = list(component_scores.values())
|
| 321 |
+
|
| 322 |
+
fig = go.Figure()
|
| 323 |
+
|
| 324 |
+
fig.add_trace(go.Scatterpolar(
|
| 325 |
+
r=values,
|
| 326 |
+
theta=categories,
|
| 327 |
+
fill='toself',
|
| 328 |
+
name='Your Scores',
|
| 329 |
+
line_color='rgb(255, 107, 107)'
|
| 330 |
+
))
|
| 331 |
+
|
| 332 |
+
# Add ideal scores for comparison
|
| 333 |
+
ideal_scores = [90] * len(categories)
|
| 334 |
+
fig.add_trace(go.Scatterpolar(
|
| 335 |
+
r=ideal_scores,
|
| 336 |
+
theta=categories,
|
| 337 |
+
fill='toself',
|
| 338 |
+
name='Ideal Scores',
|
| 339 |
+
opacity=0.3,
|
| 340 |
+
line_color='rgb(76, 175, 80)'
|
| 341 |
+
))
|
| 342 |
+
|
| 343 |
+
fig.update_layout(
|
| 344 |
+
polar=dict(
|
| 345 |
+
radialaxis=dict(
|
| 346 |
+
visible=True,
|
| 347 |
+
range=[0, 100]
|
| 348 |
+
)),
|
| 349 |
+
showlegend=True,
|
| 350 |
+
title="Financial Health Components",
|
| 351 |
+
height=400
|
| 352 |
+
)
|
| 353 |
+
|
| 354 |
+
return fig
|
goal_tracker.py
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import numpy as np
|
| 3 |
+
from datetime import datetime, timedelta, date
|
| 4 |
+
from typing import Dict, List, Tuple, Any, Optional
|
| 5 |
+
import streamlit as st
|
| 6 |
+
import plotly.graph_objects as go
|
| 7 |
+
import plotly.express as px
|
| 8 |
+
|
| 9 |
+
class GoalTracker:
|
| 10 |
+
"""Advanced goal tracking and financial recommendations system."""
|
| 11 |
+
|
| 12 |
+
def __init__(self):
|
| 13 |
+
self.goal_types = [
|
| 14 |
+
'Emergency Fund',
|
| 15 |
+
'Vacation/Travel',
|
| 16 |
+
'Home Down Payment',
|
| 17 |
+
'Car Purchase',
|
| 18 |
+
'Debt Payoff',
|
| 19 |
+
'Investment/Retirement',
|
| 20 |
+
'Education Fund',
|
| 21 |
+
'Wedding',
|
| 22 |
+
'Custom Goal'
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
def create_goal(self, name: str, target_amount: float, target_date: date,
|
| 26 |
+
goal_type: str = 'Custom Goal', current_amount: float = 0) -> Dict[str, Any]:
|
| 27 |
+
"""Create a new financial goal."""
|
| 28 |
+
days_remaining = (target_date - date.today()).days
|
| 29 |
+
months_remaining = max(1, days_remaining / 30.44)
|
| 30 |
+
|
| 31 |
+
monthly_savings_needed = max(0, (target_amount - current_amount) / months_remaining)
|
| 32 |
+
|
| 33 |
+
return {
|
| 34 |
+
'name': name,
|
| 35 |
+
'type': goal_type,
|
| 36 |
+
'target_amount': target_amount,
|
| 37 |
+
'current_amount': current_amount,
|
| 38 |
+
'target_date': target_date,
|
| 39 |
+
'days_remaining': days_remaining,
|
| 40 |
+
'months_remaining': months_remaining,
|
| 41 |
+
'monthly_savings_needed': monthly_savings_needed,
|
| 42 |
+
'progress_percentage': (current_amount / target_amount * 100) if target_amount > 0 else 0,
|
| 43 |
+
'status': self._get_goal_status(current_amount, target_amount, days_remaining),
|
| 44 |
+
'created_date': date.today()
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
def analyze_goal_feasibility(self, goal: Dict[str, Any], df: pd.DataFrame) -> Dict[str, Any]:
|
| 48 |
+
"""Analyze if a goal is achievable based on current financial patterns."""
|
| 49 |
+
|
| 50 |
+
# Calculate current financial capacity
|
| 51 |
+
monthly_income = df[df['amount'] > 0].groupby('month_year')['amount'].sum().mean()
|
| 52 |
+
monthly_expenses = abs(df[df['amount'] < 0].groupby('month_year')['amount'].sum().mean())
|
| 53 |
+
current_savings_rate = max(0, (monthly_income - monthly_expenses) / monthly_income) if monthly_income > 0 else 0
|
| 54 |
+
current_monthly_savings = monthly_income * current_savings_rate
|
| 55 |
+
|
| 56 |
+
# Goal requirements
|
| 57 |
+
required_monthly_savings = goal['monthly_savings_needed']
|
| 58 |
+
|
| 59 |
+
# Feasibility analysis
|
| 60 |
+
if current_monthly_savings >= required_monthly_savings:
|
| 61 |
+
feasibility = 'Easy'
|
| 62 |
+
recommendation = "You're already saving enough to reach this goal!"
|
| 63 |
+
elif current_monthly_savings >= required_monthly_savings * 0.8:
|
| 64 |
+
feasibility = 'Achievable'
|
| 65 |
+
shortage = required_monthly_savings - current_monthly_savings
|
| 66 |
+
recommendation = f"You need to save an additional ${shortage:.2f} per month. Consider reducing discretionary spending."
|
| 67 |
+
elif current_monthly_savings >= required_monthly_savings * 0.5:
|
| 68 |
+
feasibility = 'Challenging'
|
| 69 |
+
shortage = required_monthly_savings - current_monthly_savings
|
| 70 |
+
recommendation = f"This goal is challenging. You need ${shortage:.2f} more per month. Consider extending the timeline or reducing the target amount."
|
| 71 |
+
else:
|
| 72 |
+
feasibility = 'Difficult'
|
| 73 |
+
shortage = required_monthly_savings - current_monthly_savings
|
| 74 |
+
recommendation = f"This goal may be unrealistic with current spending. You need ${shortage:.2f} more per month. Consider major budget changes or extending the timeline significantly."
|
| 75 |
+
|
| 76 |
+
return {
|
| 77 |
+
'feasibility': feasibility,
|
| 78 |
+
'current_monthly_savings': current_monthly_savings,
|
| 79 |
+
'required_monthly_savings': required_monthly_savings,
|
| 80 |
+
'monthly_shortage': max(0, required_monthly_savings - current_monthly_savings),
|
| 81 |
+
'recommendation': recommendation,
|
| 82 |
+
'success_probability': min(100, max(10, (current_monthly_savings / required_monthly_savings) * 100))
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
def generate_savings_strategies(self, goal: Dict[str, Any], df: pd.DataFrame) -> List[Dict[str, Any]]:
|
| 86 |
+
"""Generate personalized savings strategies to reach the goal."""
|
| 87 |
+
strategies = []
|
| 88 |
+
|
| 89 |
+
if 'category' not in df.columns:
|
| 90 |
+
return self._get_default_strategies(goal)
|
| 91 |
+
|
| 92 |
+
# Analyze spending categories for optimization opportunities
|
| 93 |
+
category_spending = df[df['amount'] < 0].groupby('category')['amount'].sum().abs()
|
| 94 |
+
total_expenses = category_spending.sum()
|
| 95 |
+
|
| 96 |
+
monthly_shortage = goal['monthly_savings_needed'] - self._calculate_current_savings(df)
|
| 97 |
+
|
| 98 |
+
if monthly_shortage <= 0:
|
| 99 |
+
strategies.append({
|
| 100 |
+
'strategy': 'Stay on Track',
|
| 101 |
+
'description': "You're already saving enough! Keep up the good work.",
|
| 102 |
+
'potential_savings': 0,
|
| 103 |
+
'difficulty': 'Easy',
|
| 104 |
+
'category': 'Maintenance'
|
| 105 |
+
})
|
| 106 |
+
return strategies
|
| 107 |
+
|
| 108 |
+
# Strategy 1: Reduce largest expense categories
|
| 109 |
+
for category, amount in category_spending.head(3).items():
|
| 110 |
+
monthly_amount = amount / max(1, len(df['month_year'].unique()))
|
| 111 |
+
potential_reduction = monthly_amount * 0.15 # 15% reduction
|
| 112 |
+
|
| 113 |
+
if potential_reduction >= monthly_shortage * 0.3: # Could cover 30% of shortage
|
| 114 |
+
strategies.append({
|
| 115 |
+
'strategy': f'Reduce {category} Spending',
|
| 116 |
+
'description': f"Cut {category} spending by 15% to save ${potential_reduction:.2f}/month",
|
| 117 |
+
'potential_savings': potential_reduction,
|
| 118 |
+
'difficulty': 'Medium',
|
| 119 |
+
'category': category
|
| 120 |
+
})
|
| 121 |
+
|
| 122 |
+
# Strategy 2: Target discretionary spending
|
| 123 |
+
discretionary_categories = ['Entertainment', 'Shopping', 'Dining']
|
| 124 |
+
for category in discretionary_categories:
|
| 125 |
+
if category in category_spending:
|
| 126 |
+
monthly_amount = category_spending[category] / max(1, len(df['month_year'].unique()))
|
| 127 |
+
potential_reduction = monthly_amount * 0.25 # 25% reduction
|
| 128 |
+
|
| 129 |
+
strategies.append({
|
| 130 |
+
'strategy': f'Cut {category}',
|
| 131 |
+
'description': f"Reduce {category} by 25% to save ${potential_reduction:.2f}/month",
|
| 132 |
+
'potential_savings': potential_reduction,
|
| 133 |
+
'difficulty': 'Easy' if potential_reduction < 100 else 'Medium',
|
| 134 |
+
'category': category
|
| 135 |
+
})
|
| 136 |
+
|
| 137 |
+
# Strategy 3: Increase income
|
| 138 |
+
current_monthly_income = df[df['amount'] > 0].groupby('month_year')['amount'].sum().mean()
|
| 139 |
+
income_increase_needed = monthly_shortage / 0.7 # Assume 30% goes to taxes/expenses
|
| 140 |
+
|
| 141 |
+
strategies.append({
|
| 142 |
+
'strategy': 'Increase Income',
|
| 143 |
+
'description': f"Increase monthly income by ${income_increase_needed:.2f} through side work or raises",
|
| 144 |
+
'potential_savings': monthly_shortage,
|
| 145 |
+
'difficulty': 'Hard',
|
| 146 |
+
'category': 'Income'
|
| 147 |
+
})
|
| 148 |
+
|
| 149 |
+
# Strategy 4: Combination approach
|
| 150 |
+
if len(strategies) > 1:
|
| 151 |
+
total_potential = sum(s['potential_savings'] for s in strategies[:2])
|
| 152 |
+
if total_potential >= monthly_shortage:
|
| 153 |
+
strategies.append({
|
| 154 |
+
'strategy': 'Combination Approach',
|
| 155 |
+
'description': f"Combine multiple small changes to save ${total_potential:.2f}/month",
|
| 156 |
+
'potential_savings': total_potential,
|
| 157 |
+
'difficulty': 'Medium',
|
| 158 |
+
'category': 'Mixed'
|
| 159 |
+
})
|
| 160 |
+
|
| 161 |
+
# Sort by potential impact and difficulty
|
| 162 |
+
strategies.sort(key=lambda x: (x['potential_savings'], -self._get_difficulty_score(x['difficulty'])), reverse=True)
|
| 163 |
+
|
| 164 |
+
return strategies[:5] # Return top 5 strategies
|
| 165 |
+
|
| 166 |
+
def track_goal_progress(self, goal: Dict[str, Any], transactions_df: pd.DataFrame) -> Dict[str, Any]:
|
| 167 |
+
"""Track progress towards a specific goal."""
|
| 168 |
+
|
| 169 |
+
# Simple progress tracking (in real app, this would link to specific savings transactions)
|
| 170 |
+
current_savings = self._calculate_current_savings(transactions_df)
|
| 171 |
+
|
| 172 |
+
# Calculate if on track
|
| 173 |
+
elapsed_time = (date.today() - goal['created_date']).days
|
| 174 |
+
total_time = (goal['target_date'] - goal['created_date']).days
|
| 175 |
+
expected_progress = (elapsed_time / max(1, total_time)) * 100
|
| 176 |
+
|
| 177 |
+
actual_progress = goal['progress_percentage']
|
| 178 |
+
|
| 179 |
+
return {
|
| 180 |
+
'current_amount': goal['current_amount'],
|
| 181 |
+
'target_amount': goal['target_amount'],
|
| 182 |
+
'progress_percentage': actual_progress,
|
| 183 |
+
'expected_progress': expected_progress,
|
| 184 |
+
'ahead_behind': actual_progress - expected_progress,
|
| 185 |
+
'monthly_savings_needed': goal['monthly_savings_needed'],
|
| 186 |
+
'days_remaining': goal['days_remaining'],
|
| 187 |
+
'projected_completion': self._project_completion_date(goal, current_savings),
|
| 188 |
+
'on_track': abs(actual_progress - expected_progress) <= 10 # Within 10% tolerance
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
def get_goal_recommendations(self, goals: List[Dict[str, Any]], df: pd.DataFrame) -> List[str]:
|
| 192 |
+
"""Get personalized recommendations across all goals."""
|
| 193 |
+
recommendations = []
|
| 194 |
+
|
| 195 |
+
if not goals:
|
| 196 |
+
recommendations.append("💡 Start by setting your first financial goal! Emergency funds are usually a great place to begin.")
|
| 197 |
+
return recommendations
|
| 198 |
+
|
| 199 |
+
# Analyze goal priorities
|
| 200 |
+
urgent_goals = [g for g in goals if g['days_remaining'] < 90]
|
| 201 |
+
large_goals = [g for g in goals if g['target_amount'] > 10000]
|
| 202 |
+
|
| 203 |
+
if urgent_goals:
|
| 204 |
+
recommendations.append(f"⏰ Focus on urgent goals: {', '.join([g['name'] for g in urgent_goals[:2]])}")
|
| 205 |
+
|
| 206 |
+
# Check for conflicting goals
|
| 207 |
+
total_monthly_needed = sum(g['monthly_savings_needed'] for g in goals)
|
| 208 |
+
current_capacity = self._calculate_current_savings(df)
|
| 209 |
+
|
| 210 |
+
if total_monthly_needed > current_capacity * 1.2:
|
| 211 |
+
recommendations.append("⚖️ You have conflicting goals. Consider prioritizing or extending timelines for some goals.")
|
| 212 |
+
|
| 213 |
+
# Emergency fund recommendation
|
| 214 |
+
emergency_goals = [g for g in goals if 'emergency' in g['name'].lower()]
|
| 215 |
+
if not emergency_goals:
|
| 216 |
+
recommendations.append("🚨 Consider adding an emergency fund goal (3-6 months of expenses).")
|
| 217 |
+
|
| 218 |
+
# Diversification recommendation
|
| 219 |
+
goal_types = set(g['type'] for g in goals)
|
| 220 |
+
if len(goal_types) == 1 and len(goals) > 1:
|
| 221 |
+
recommendations.append("🎯 Consider diversifying your goals across different categories (savings, investment, debt payoff).")
|
| 222 |
+
|
| 223 |
+
return recommendations
|
| 224 |
+
|
| 225 |
+
def _get_goal_status(self, current: float, target: float, days_remaining: int) -> str:
|
| 226 |
+
"""Determine goal status."""
|
| 227 |
+
progress = (current / target * 100) if target > 0 else 0
|
| 228 |
+
|
| 229 |
+
if progress >= 100:
|
| 230 |
+
return 'Completed'
|
| 231 |
+
elif days_remaining < 0:
|
| 232 |
+
return 'Overdue'
|
| 233 |
+
elif days_remaining < 30:
|
| 234 |
+
return 'Critical'
|
| 235 |
+
elif progress >= 75:
|
| 236 |
+
return 'On Track'
|
| 237 |
+
elif progress >= 50:
|
| 238 |
+
return 'Behind'
|
| 239 |
+
else:
|
| 240 |
+
return 'Far Behind'
|
| 241 |
+
|
| 242 |
+
def _calculate_current_savings(self, df: pd.DataFrame) -> float:
|
| 243 |
+
"""Calculate current monthly savings capacity."""
|
| 244 |
+
monthly_income = df[df['amount'] > 0].groupby('month_year')['amount'].sum().mean()
|
| 245 |
+
monthly_expenses = abs(df[df['amount'] < 0].groupby('month_year')['amount'].sum().mean())
|
| 246 |
+
return max(0, monthly_income - monthly_expenses)
|
| 247 |
+
|
| 248 |
+
def _get_difficulty_score(self, difficulty: str) -> int:
|
| 249 |
+
"""Convert difficulty to numeric score."""
|
| 250 |
+
scores = {'Easy': 3, 'Medium': 2, 'Hard': 1}
|
| 251 |
+
return scores.get(difficulty, 1)
|
| 252 |
+
|
| 253 |
+
def _project_completion_date(self, goal: Dict[str, Any], current_monthly_savings: float) -> date:
|
| 254 |
+
"""Project when goal will be completed at current savings rate."""
|
| 255 |
+
if current_monthly_savings <= 0:
|
| 256 |
+
return goal['target_date'] # Use original target if no savings
|
| 257 |
+
|
| 258 |
+
remaining_amount = goal['target_amount'] - goal['current_amount']
|
| 259 |
+
months_needed = remaining_amount / current_monthly_savings
|
| 260 |
+
|
| 261 |
+
projected_date = date.today() + timedelta(days=int(months_needed * 30.44))
|
| 262 |
+
return projected_date
|
| 263 |
+
|
| 264 |
+
def _get_default_strategies(self, goal: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 265 |
+
"""Get default strategies when category data is not available."""
|
| 266 |
+
return [
|
| 267 |
+
{
|
| 268 |
+
'strategy': 'Create a Budget',
|
| 269 |
+
'description': 'Track your spending by category to identify saving opportunities',
|
| 270 |
+
'potential_savings': goal['monthly_savings_needed'] * 0.3,
|
| 271 |
+
'difficulty': 'Easy',
|
| 272 |
+
'category': 'Planning'
|
| 273 |
+
},
|
| 274 |
+
{
|
| 275 |
+
'strategy': 'Automate Savings',
|
| 276 |
+
'description': 'Set up automatic transfers to a dedicated savings account',
|
| 277 |
+
'potential_savings': goal['monthly_savings_needed'],
|
| 278 |
+
'difficulty': 'Easy',
|
| 279 |
+
'category': 'Automation'
|
| 280 |
+
},
|
| 281 |
+
{
|
| 282 |
+
'strategy': 'Reduce Discretionary Spending',
|
| 283 |
+
'description': 'Cut back on dining out, entertainment, and non-essential purchases',
|
| 284 |
+
'potential_savings': goal['monthly_savings_needed'] * 0.5,
|
| 285 |
+
'difficulty': 'Medium',
|
| 286 |
+
'category': 'Spending'
|
| 287 |
+
}
|
| 288 |
+
]
|
| 289 |
+
|
| 290 |
+
def create_goal_progress_chart(self, goal: Dict[str, Any]) -> go.Figure:
|
| 291 |
+
"""Create progress visualization for a goal."""
|
| 292 |
+
|
| 293 |
+
fig = go.Figure(go.Indicator(
|
| 294 |
+
mode = "gauge+number",
|
| 295 |
+
value = goal['progress_percentage'],
|
| 296 |
+
domain = {'x': [0, 1], 'y': [0, 1]},
|
| 297 |
+
title = {'text': f"{goal['name']}<br><span style='font-size:0.8em;color:gray'>${goal['current_amount']:,.0f} / ${goal['target_amount']:,.0f}</span>"},
|
| 298 |
+
gauge = {
|
| 299 |
+
'axis': {'range': [None, 100]},
|
| 300 |
+
'bar': {'color': "darkblue"},
|
| 301 |
+
'steps': [
|
| 302 |
+
{'range': [0, 50], 'color': "lightgray"},
|
| 303 |
+
{'range': [50, 80], 'color': "yellow"},
|
| 304 |
+
{'range': [80, 100], 'color': "lightgreen"}
|
| 305 |
+
],
|
| 306 |
+
'threshold': {
|
| 307 |
+
'line': {'color': "red", 'width': 4},
|
| 308 |
+
'thickness': 0.75,
|
| 309 |
+
'value': 90
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
))
|
| 313 |
+
|
| 314 |
+
fig.update_layout(height=300)
|
| 315 |
+
return fig
|
| 316 |
+
|
| 317 |
+
def create_savings_strategy_chart(self, strategies: List[Dict[str, Any]]) -> go.Figure:
|
| 318 |
+
"""Create visualization of savings strategies."""
|
| 319 |
+
|
| 320 |
+
if not strategies:
|
| 321 |
+
return go.Figure()
|
| 322 |
+
|
| 323 |
+
strategy_names = [s['strategy'] for s in strategies[:5]]
|
| 324 |
+
potential_savings = [s['potential_savings'] for s in strategies[:5]]
|
| 325 |
+
difficulties = [s['difficulty'] for s in strategies[:5]]
|
| 326 |
+
|
| 327 |
+
# Color mapping for difficulty
|
| 328 |
+
color_map = {'Easy': 'green', 'Medium': 'orange', 'Hard': 'red'}
|
| 329 |
+
colors = [color_map.get(d, 'blue') for d in difficulties]
|
| 330 |
+
|
| 331 |
+
fig = go.Figure(data=[
|
| 332 |
+
go.Bar(
|
| 333 |
+
x=strategy_names,
|
| 334 |
+
y=potential_savings,
|
| 335 |
+
marker_color=colors,
|
| 336 |
+
text=[f"${x:.0f}" for x in potential_savings],
|
| 337 |
+
textposition='auto',
|
| 338 |
+
)
|
| 339 |
+
])
|
| 340 |
+
|
| 341 |
+
fig.update_layout(
|
| 342 |
+
title='Potential Savings Strategies',
|
| 343 |
+
xaxis_title='Strategy',
|
| 344 |
+
yaxis_title='Potential Monthly Savings ($)',
|
| 345 |
+
template='plotly_white',
|
| 346 |
+
height=400
|
| 347 |
+
)
|
| 348 |
+
|
| 349 |
+
return fig
|
predictive_analytics.py
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import numpy as np
|
| 3 |
+
from datetime import datetime, timedelta, date
|
| 4 |
+
from typing import Dict, List, Tuple, Any
|
| 5 |
+
import plotly.graph_objects as go
|
| 6 |
+
import plotly.express as px
|
| 7 |
+
from plotly.subplots import make_subplots
|
| 8 |
+
|
| 9 |
+
class PredictiveAnalytics:
|
| 10 |
+
"""Advanced predictive analytics for financial forecasting."""
|
| 11 |
+
|
| 12 |
+
def __init__(self):
|
| 13 |
+
pass
|
| 14 |
+
|
| 15 |
+
def predict_future_spending(self, df: pd.DataFrame, months_ahead: int = 3) -> Dict[str, Any]:
|
| 16 |
+
"""Predict future spending patterns using trend analysis."""
|
| 17 |
+
|
| 18 |
+
# Prepare monthly spending data
|
| 19 |
+
monthly_data = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 20 |
+
|
| 21 |
+
if len(monthly_data) < 2:
|
| 22 |
+
return self._default_prediction(months_ahead)
|
| 23 |
+
|
| 24 |
+
# Simple linear trend analysis
|
| 25 |
+
months = list(range(len(monthly_data)))
|
| 26 |
+
spending_values = monthly_data.values
|
| 27 |
+
|
| 28 |
+
# Calculate trend
|
| 29 |
+
trend_slope = np.polyfit(months, spending_values, 1)[0]
|
| 30 |
+
trend_intercept = np.polyfit(months, spending_values, 1)[1]
|
| 31 |
+
|
| 32 |
+
# Generate predictions
|
| 33 |
+
future_months = []
|
| 34 |
+
predictions = []
|
| 35 |
+
last_month_idx = len(monthly_data)
|
| 36 |
+
|
| 37 |
+
for i in range(1, months_ahead + 1):
|
| 38 |
+
future_month_idx = last_month_idx + i
|
| 39 |
+
predicted_value = trend_slope * future_month_idx + trend_intercept
|
| 40 |
+
|
| 41 |
+
# Add seasonal adjustment (simple)
|
| 42 |
+
seasonal_factor = self._get_seasonal_factor(monthly_data, i)
|
| 43 |
+
adjusted_prediction = max(0, predicted_value * seasonal_factor)
|
| 44 |
+
|
| 45 |
+
predictions.append(adjusted_prediction)
|
| 46 |
+
|
| 47 |
+
# Generate future month names
|
| 48 |
+
last_date = monthly_data.index[-1]
|
| 49 |
+
if hasattr(last_date, 'to_timestamp'):
|
| 50 |
+
last_timestamp = last_date.to_timestamp()
|
| 51 |
+
else:
|
| 52 |
+
last_timestamp = pd.to_datetime(str(last_date))
|
| 53 |
+
|
| 54 |
+
future_date = last_timestamp + pd.DateOffset(months=i)
|
| 55 |
+
future_months.append(future_date.strftime('%Y-%m'))
|
| 56 |
+
|
| 57 |
+
return {
|
| 58 |
+
'predictions': predictions,
|
| 59 |
+
'future_months': future_months,
|
| 60 |
+
'trend_direction': 'increasing' if trend_slope > 0 else 'decreasing',
|
| 61 |
+
'monthly_change': abs(trend_slope),
|
| 62 |
+
'confidence_level': self._calculate_confidence(monthly_data, predictions)
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
def predict_category_spending(self, df: pd.DataFrame) -> Dict[str, Any]:
|
| 66 |
+
"""Predict future spending by category."""
|
| 67 |
+
if 'category' not in df.columns:
|
| 68 |
+
return {}
|
| 69 |
+
|
| 70 |
+
category_predictions = {}
|
| 71 |
+
|
| 72 |
+
for category in df['category'].unique():
|
| 73 |
+
category_data = df[(df['category'] == category) & (df['amount'] < 0)]
|
| 74 |
+
monthly_category = category_data.groupby('month_year')['amount'].sum().abs()
|
| 75 |
+
|
| 76 |
+
if len(monthly_category) >= 2:
|
| 77 |
+
# Simple trend prediction
|
| 78 |
+
trend = np.polyfit(range(len(monthly_category)), monthly_category.values, 1)[0]
|
| 79 |
+
last_value = monthly_category.iloc[-1]
|
| 80 |
+
next_month_prediction = max(0, last_value + trend)
|
| 81 |
+
|
| 82 |
+
category_predictions[category] = {
|
| 83 |
+
'predicted_amount': next_month_prediction,
|
| 84 |
+
'trend': 'increasing' if trend > 0 else 'decreasing',
|
| 85 |
+
'confidence': min(100, max(50, 100 - abs(trend) / last_value * 100))
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
return category_predictions
|
| 89 |
+
|
| 90 |
+
def detect_spending_anomalies(self, df: pd.DataFrame) -> List[Dict[str, Any]]:
|
| 91 |
+
"""Detect unusual spending patterns."""
|
| 92 |
+
anomalies = []
|
| 93 |
+
|
| 94 |
+
# Monthly spending anomalies
|
| 95 |
+
monthly_spending = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 96 |
+
|
| 97 |
+
if len(monthly_spending) >= 3:
|
| 98 |
+
mean_spending = monthly_spending.mean()
|
| 99 |
+
std_spending = monthly_spending.std()
|
| 100 |
+
|
| 101 |
+
for month, amount in monthly_spending.items():
|
| 102 |
+
z_score = abs(amount - mean_spending) / std_spending if std_spending > 0 else 0
|
| 103 |
+
|
| 104 |
+
if z_score > 2: # More than 2 standard deviations
|
| 105 |
+
anomalies.append({
|
| 106 |
+
'type': 'monthly_spending',
|
| 107 |
+
'month': str(month),
|
| 108 |
+
'amount': amount,
|
| 109 |
+
'deviation': f"{z_score:.1f} std deviations",
|
| 110 |
+
'severity': 'high' if z_score > 3 else 'medium'
|
| 111 |
+
})
|
| 112 |
+
|
| 113 |
+
# Category spending anomalies
|
| 114 |
+
if 'category' in df.columns:
|
| 115 |
+
for category in df['category'].unique():
|
| 116 |
+
category_data = df[(df['category'] == category) & (df['amount'] < 0)]
|
| 117 |
+
monthly_category = category_data.groupby('month_year')['amount'].sum().abs()
|
| 118 |
+
|
| 119 |
+
if len(monthly_category) >= 3:
|
| 120 |
+
mean_cat = monthly_category.mean()
|
| 121 |
+
std_cat = monthly_category.std()
|
| 122 |
+
|
| 123 |
+
for month, amount in monthly_category.items():
|
| 124 |
+
z_score = abs(amount - mean_cat) / std_cat if std_cat > 0 else 0
|
| 125 |
+
|
| 126 |
+
if z_score > 2.5:
|
| 127 |
+
anomalies.append({
|
| 128 |
+
'type': 'category_spending',
|
| 129 |
+
'category': category,
|
| 130 |
+
'month': str(month),
|
| 131 |
+
'amount': amount,
|
| 132 |
+
'deviation': f"{z_score:.1f} std deviations",
|
| 133 |
+
'severity': 'high' if z_score > 3 else 'medium'
|
| 134 |
+
})
|
| 135 |
+
|
| 136 |
+
return anomalies
|
| 137 |
+
|
| 138 |
+
def forecast_budget_risks(self, df: pd.DataFrame, budgets: Dict[str, float] = None) -> List[Dict[str, Any]]:
|
| 139 |
+
"""Forecast potential budget overruns."""
|
| 140 |
+
risks = []
|
| 141 |
+
|
| 142 |
+
if not budgets:
|
| 143 |
+
# Create default budgets based on historical data
|
| 144 |
+
if 'category' in df.columns:
|
| 145 |
+
monthly_avg = df[df['amount'] < 0].groupby('category')['amount'].sum().abs() / max(1, len(df['month_year'].unique()))
|
| 146 |
+
budgets = {cat: amount * 1.1 for cat, amount in monthly_avg.items()} # 10% buffer
|
| 147 |
+
|
| 148 |
+
if budgets and 'category' in df.columns:
|
| 149 |
+
category_predictions = self.predict_category_spending(df)
|
| 150 |
+
|
| 151 |
+
for category, budget in budgets.items():
|
| 152 |
+
if category in category_predictions:
|
| 153 |
+
predicted = category_predictions[category]['predicted_amount']
|
| 154 |
+
if predicted > budget:
|
| 155 |
+
overage = predicted - budget
|
| 156 |
+
percentage_over = (overage / budget) * 100
|
| 157 |
+
|
| 158 |
+
risks.append({
|
| 159 |
+
'category': category,
|
| 160 |
+
'budget': budget,
|
| 161 |
+
'predicted': predicted,
|
| 162 |
+
'overage': overage,
|
| 163 |
+
'percentage_over': percentage_over,
|
| 164 |
+
'risk_level': 'high' if percentage_over > 20 else 'medium'
|
| 165 |
+
})
|
| 166 |
+
|
| 167 |
+
return risks
|
| 168 |
+
|
| 169 |
+
def _get_seasonal_factor(self, monthly_data: pd.Series, months_ahead: int) -> float:
|
| 170 |
+
"""Calculate simple seasonal adjustment factor."""
|
| 171 |
+
if len(monthly_data) < 12:
|
| 172 |
+
return 1.0 # No seasonal adjustment for insufficient data
|
| 173 |
+
|
| 174 |
+
# Simple seasonal pattern (could be enhanced)
|
| 175 |
+
current_month = datetime.now().month
|
| 176 |
+
future_month = ((current_month + months_ahead - 1) % 12) + 1
|
| 177 |
+
|
| 178 |
+
# Basic seasonal factors (could be data-driven)
|
| 179 |
+
seasonal_factors = {
|
| 180 |
+
1: 0.9, # January (post-holiday)
|
| 181 |
+
2: 0.95, # February
|
| 182 |
+
3: 1.0, # March
|
| 183 |
+
4: 1.05, # April
|
| 184 |
+
5: 1.0, # May
|
| 185 |
+
6: 1.1, # June (summer activities)
|
| 186 |
+
7: 1.15, # July (vacation)
|
| 187 |
+
8: 1.1, # August
|
| 188 |
+
9: 1.0, # September
|
| 189 |
+
10: 1.05, # October
|
| 190 |
+
11: 1.2, # November (holiday prep)
|
| 191 |
+
12: 1.3 # December (holidays)
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
return seasonal_factors.get(future_month, 1.0)
|
| 195 |
+
|
| 196 |
+
def _calculate_confidence(self, historical_data: pd.Series, predictions: List[float]) -> float:
|
| 197 |
+
"""Calculate confidence level for predictions."""
|
| 198 |
+
if len(historical_data) < 3:
|
| 199 |
+
return 60.0
|
| 200 |
+
|
| 201 |
+
# Calculate historical variance
|
| 202 |
+
variance = historical_data.var()
|
| 203 |
+
mean_value = historical_data.mean()
|
| 204 |
+
|
| 205 |
+
if mean_value == 0:
|
| 206 |
+
return 50.0
|
| 207 |
+
|
| 208 |
+
# Confidence based on data consistency
|
| 209 |
+
cv = (variance ** 0.5) / mean_value # Coefficient of variation
|
| 210 |
+
|
| 211 |
+
if cv < 0.1:
|
| 212 |
+
return 90.0
|
| 213 |
+
elif cv < 0.2:
|
| 214 |
+
return 80.0
|
| 215 |
+
elif cv < 0.3:
|
| 216 |
+
return 70.0
|
| 217 |
+
else:
|
| 218 |
+
return 60.0
|
| 219 |
+
|
| 220 |
+
def _default_prediction(self, months_ahead: int) -> Dict[str, Any]:
|
| 221 |
+
"""Return default prediction when insufficient data."""
|
| 222 |
+
return {
|
| 223 |
+
'predictions': [0] * months_ahead,
|
| 224 |
+
'future_months': [],
|
| 225 |
+
'trend_direction': 'stable',
|
| 226 |
+
'monthly_change': 0,
|
| 227 |
+
'confidence_level': 50.0
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
def create_prediction_chart(self, df: pd.DataFrame, prediction_data: Dict[str, Any]) -> go.Figure:
|
| 231 |
+
"""Create visualization for spending predictions."""
|
| 232 |
+
# Historical data
|
| 233 |
+
monthly_spending = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 234 |
+
|
| 235 |
+
fig = go.Figure()
|
| 236 |
+
|
| 237 |
+
# Historical spending
|
| 238 |
+
fig.add_trace(go.Scatter(
|
| 239 |
+
x=[str(month) for month in monthly_spending.index],
|
| 240 |
+
y=monthly_spending.values,
|
| 241 |
+
mode='lines+markers',
|
| 242 |
+
name='Historical Spending',
|
| 243 |
+
line=dict(color='blue', width=2),
|
| 244 |
+
marker=dict(size=6)
|
| 245 |
+
))
|
| 246 |
+
|
| 247 |
+
# Predictions
|
| 248 |
+
if prediction_data['predictions']:
|
| 249 |
+
fig.add_trace(go.Scatter(
|
| 250 |
+
x=prediction_data['future_months'],
|
| 251 |
+
y=prediction_data['predictions'],
|
| 252 |
+
mode='lines+markers',
|
| 253 |
+
name='Predicted Spending',
|
| 254 |
+
line=dict(color='red', width=2, dash='dash'),
|
| 255 |
+
marker=dict(size=6, symbol='diamond')
|
| 256 |
+
))
|
| 257 |
+
|
| 258 |
+
fig.update_layout(
|
| 259 |
+
title='Spending Forecast',
|
| 260 |
+
xaxis_title='Month',
|
| 261 |
+
yaxis_title='Amount ($)',
|
| 262 |
+
template='plotly_white',
|
| 263 |
+
height=400,
|
| 264 |
+
showlegend=True
|
| 265 |
+
)
|
| 266 |
+
|
| 267 |
+
return fig
|
| 268 |
+
|
| 269 |
+
def create_risk_alert_chart(self, risks: List[Dict[str, Any]]) -> go.Figure:
|
| 270 |
+
"""Create visualization for budget risks."""
|
| 271 |
+
if not risks:
|
| 272 |
+
return go.Figure()
|
| 273 |
+
|
| 274 |
+
categories = [risk['category'] for risk in risks]
|
| 275 |
+
budgets = [risk['budget'] for risk in risks]
|
| 276 |
+
predicted = [risk['predicted'] for risk in risks]
|
| 277 |
+
|
| 278 |
+
fig = go.Figure()
|
| 279 |
+
|
| 280 |
+
fig.add_trace(go.Bar(
|
| 281 |
+
x=categories,
|
| 282 |
+
y=budgets,
|
| 283 |
+
name='Budget',
|
| 284 |
+
marker_color='green',
|
| 285 |
+
opacity=0.7
|
| 286 |
+
))
|
| 287 |
+
|
| 288 |
+
fig.add_trace(go.Bar(
|
| 289 |
+
x=categories,
|
| 290 |
+
y=predicted,
|
| 291 |
+
name='Predicted Spending',
|
| 292 |
+
marker_color='red',
|
| 293 |
+
opacity=0.7
|
| 294 |
+
))
|
| 295 |
+
|
| 296 |
+
fig.update_layout(
|
| 297 |
+
title='Budget Risk Analysis',
|
| 298 |
+
xaxis_title='Category',
|
| 299 |
+
yaxis_title='Amount ($)',
|
| 300 |
+
barmode='group',
|
| 301 |
+
template='plotly_white',
|
| 302 |
+
height=400
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
return fig
|
pyproject.toml
ADDED
|
@@ -0,0 +1,1135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "repl-nix-workspace"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Add your description here"
|
| 5 |
+
requires-python = ">=3.11"
|
| 6 |
+
dependencies = [
|
| 7 |
+
"openai>=1.102.0",
|
| 8 |
+
"streamlit>=1.49.1",
|
| 9 |
+
"plotly>=5.17.0",
|
| 10 |
+
"pandas>=2.0.0",
|
| 11 |
+
"numpy>=1.24.0",
|
| 12 |
+
"chromadb>=0.4.0",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[[tool.uv.index]]
|
| 16 |
+
explicit = true
|
| 17 |
+
name = "pytorch-cpu"
|
| 18 |
+
url = "https://download.pytorch.org/whl/cpu"
|
| 19 |
+
|
| 20 |
+
[tool.uv.sources]
|
| 21 |
+
AA-module = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 22 |
+
ABlooper = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 23 |
+
AnalysisG = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 24 |
+
AutoRAG = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 25 |
+
BERTeam = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 26 |
+
BxTorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 27 |
+
Byaldi = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 28 |
+
CALM-Pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 29 |
+
COPEX-high-rate-compression-quality-metrics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 30 |
+
CityLearn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 31 |
+
CoCa-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 32 |
+
CoLT5-attention = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 33 |
+
ComfyUI-EasyNodes = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 34 |
+
Crawl4AI = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 35 |
+
DALL-E = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 36 |
+
DI-toolkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 37 |
+
DatasetRising = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 38 |
+
DeepCache = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 39 |
+
DeepMatter = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 40 |
+
Draugr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 41 |
+
ESRNN = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 42 |
+
En-transformer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 43 |
+
ExpoSeq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 44 |
+
FLAML = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 45 |
+
FSRS-Optimizer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 46 |
+
GANDLF = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 47 |
+
GQLAlchemy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 48 |
+
GhostScan = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 49 |
+
GraKeL = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 50 |
+
HEBO = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 51 |
+
IOPaint = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 52 |
+
ISLP = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 53 |
+
InvokeAI = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 54 |
+
JAEN = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 55 |
+
KapoorLabs-Lightning = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 56 |
+
LightAutoML = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 57 |
+
LingerGRN = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 58 |
+
MMEdu = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 59 |
+
MRzeroCore = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 60 |
+
Modeva = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 61 |
+
NeuralFoil = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 62 |
+
NiMARE = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 63 |
+
NinjaTools = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 64 |
+
OpenHosta = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 65 |
+
OpenNMT-py = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 66 |
+
POT = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 67 |
+
PVNet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 68 |
+
PaLM-rlhf-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 69 |
+
PepperPepper = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 70 |
+
PiML = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 71 |
+
Poutyne = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 72 |
+
QNCP = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 73 |
+
RAGatouille = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 74 |
+
RareGO = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 75 |
+
RealtimeSTT = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 76 |
+
RelevanceAI-Workflows-Core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 77 |
+
Resemblyzer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 78 |
+
ScandEval = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 79 |
+
Simba-UW-tf-dev = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 80 |
+
SwissArmyTransformer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 81 |
+
TPOT = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 82 |
+
TTS = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 83 |
+
TorchCRF = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 84 |
+
TotalSegmentator = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 85 |
+
UtilsRL = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 86 |
+
WhisperSpeech = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 87 |
+
XAISuite = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 88 |
+
a-unet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 89 |
+
a5dev = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 90 |
+
accelerate = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 91 |
+
accelerated-scan = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 92 |
+
accern-xyme = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 93 |
+
achatbot = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 94 |
+
acids-rave = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 95 |
+
actorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 96 |
+
acvl-utils = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 97 |
+
adabelief-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 98 |
+
adam-atan2-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 99 |
+
adan-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 100 |
+
adapters = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 101 |
+
admin-torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 102 |
+
adtoolbox = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 103 |
+
adversarial-robustness-toolbox = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 104 |
+
aeiou = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 105 |
+
aeon = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 106 |
+
africanwhisper = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 107 |
+
ag-llama-api = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 108 |
+
agentdojo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 109 |
+
agilerl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 110 |
+
ai-edge-torch-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 111 |
+
ai-parrot = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 112 |
+
ai-python = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 113 |
+
ai-transform = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 114 |
+
ai2-olmo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 115 |
+
ai2-olmo-core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 116 |
+
ai2-tango = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 117 |
+
aicmder = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 118 |
+
aider-chat = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 119 |
+
aider-chat-x = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 120 |
+
aif360 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 121 |
+
aihwkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 122 |
+
aimodelshare = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 123 |
+
airllm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 124 |
+
airtestProject = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 125 |
+
airunner = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 126 |
+
aisak = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 127 |
+
aislib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 128 |
+
aisquared = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 129 |
+
aistore = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 130 |
+
aithree = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 131 |
+
akasha-terminal = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 132 |
+
alibi = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 133 |
+
alibi-detect = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 134 |
+
alignn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 135 |
+
all-clip = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 136 |
+
allennlp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 137 |
+
allennlp-models = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 138 |
+
allennlp-pvt-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 139 |
+
allophant = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 140 |
+
allosaurus = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 141 |
+
aloy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 142 |
+
alpaca-eval = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 143 |
+
alphafold2-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 144 |
+
alphafold3-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 145 |
+
alphamed-federated = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 146 |
+
alphawave = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 147 |
+
amazon-braket-pennylane-plugin = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 148 |
+
amazon-photos = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 149 |
+
anemoi-graphs = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 150 |
+
anemoi-models = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 151 |
+
anomalib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 152 |
+
apache-beam = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 153 |
+
apache-tvm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 154 |
+
aperturedb = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 155 |
+
aphrodite-engine = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 156 |
+
aqlm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 157 |
+
arcAGI2024 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 158 |
+
archisound = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 159 |
+
argbind = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 160 |
+
arize = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 161 |
+
arm-pytorch-utilities = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 162 |
+
array-api-compat = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 163 |
+
arus = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 164 |
+
assert-llm-tools = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 165 |
+
asteroid = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 166 |
+
asteroid-filterbanks = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 167 |
+
astra-llm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 168 |
+
astrovision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 169 |
+
atomate2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 170 |
+
attacut = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 171 |
+
audio-diffusion-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 172 |
+
audio-encoders-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 173 |
+
audio-separator = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 174 |
+
audiocraft = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 175 |
+
audiolm-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 176 |
+
auralis = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 177 |
+
auraloss = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 178 |
+
auto-gptq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 179 |
+
autoawq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 180 |
+
autoawq-kernels = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 181 |
+
"autogluon.multimodal" = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 182 |
+
"autogluon.tabular" = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 183 |
+
"autogluon.timeseries" = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 184 |
+
autotrain-advanced = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 185 |
+
avdeepfake1m = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 186 |
+
aws-fortuna = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 187 |
+
ax-platform = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 188 |
+
azureml-automl-dnn-vision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 189 |
+
azureml-contrib-automl-dnn-forecasting = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 190 |
+
azureml-evaluate-mlflow = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 191 |
+
azureml-metrics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 192 |
+
azureml-train-automl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 193 |
+
b2bTools = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 194 |
+
backpack-for-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 195 |
+
balrog-nle = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 196 |
+
batch-face = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 197 |
+
batchalign = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 198 |
+
batchgeneratorsv2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 199 |
+
batchtensor = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 200 |
+
bbrl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 201 |
+
benchpots = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 202 |
+
bent = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 203 |
+
bert-score = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 204 |
+
bertopic = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 205 |
+
bertviz = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 206 |
+
bestOf = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 207 |
+
betty-ml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 208 |
+
big-sleep = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 209 |
+
bigdl-core-cpp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 210 |
+
bigdl-core-npu = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 211 |
+
bigdl-llm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 212 |
+
bigdl-nano = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 213 |
+
"bioimageio.core" = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 214 |
+
bitfount = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 215 |
+
bitsandbytes = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 216 |
+
bittensor = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 217 |
+
bittensor-cli = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 218 |
+
blackboxopt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 219 |
+
blanc = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 220 |
+
blindai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 221 |
+
bm25-pt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 222 |
+
boltz = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 223 |
+
botorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 224 |
+
boxmot = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 225 |
+
brainchain = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 226 |
+
braindecode = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 227 |
+
brevitas = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 228 |
+
briton = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 229 |
+
browsergym-visualwebarena = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 230 |
+
buzz-captions = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 231 |
+
byotrack = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 232 |
+
byzerllm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 233 |
+
c4v-py = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 234 |
+
calflops = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 235 |
+
came-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 236 |
+
camel-ai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 237 |
+
camel-tools = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 238 |
+
cannai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 239 |
+
captum = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 240 |
+
carte-ai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 241 |
+
carvekit-colab = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 242 |
+
catalyst = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 243 |
+
causalml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 244 |
+
causalnex = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 245 |
+
causy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 246 |
+
cbrkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 247 |
+
cca-zoo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 248 |
+
cdp-backend = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 249 |
+
cellacdc = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 250 |
+
cellfinder = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 251 |
+
cellpose = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 252 |
+
cellxgene-census = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 253 |
+
chattts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 254 |
+
chemprop = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 255 |
+
chgnet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 256 |
+
chitra = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 257 |
+
circuitsvis = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 258 |
+
cjm-yolox-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 259 |
+
clarinpl-embeddings = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 260 |
+
class-resolver = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 261 |
+
classifier-free-guidance-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 262 |
+
classiq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 263 |
+
classy-core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 264 |
+
clean-fid = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 265 |
+
cleanvision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 266 |
+
clip-anytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 267 |
+
clip-benchmark = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 268 |
+
clip-by-openai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 269 |
+
clip-interrogator = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 270 |
+
clip-retrieval = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 271 |
+
cltk = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 272 |
+
clu = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 273 |
+
clusterops = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 274 |
+
cnocr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 275 |
+
cnstd = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 276 |
+
coba = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 277 |
+
cofi = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 278 |
+
colbert-ai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 279 |
+
colpali-engine = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 280 |
+
compel = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 281 |
+
composabl-ray = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 282 |
+
composabl-ray-dev = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 283 |
+
composabl-train = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 284 |
+
composabl-train-dev = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 285 |
+
composer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 286 |
+
compressai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 287 |
+
compressed-tensors = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 288 |
+
compressed-tensors-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 289 |
+
concrete-python = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 290 |
+
confit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 291 |
+
conformer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 292 |
+
contextualSpellCheck = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 293 |
+
continual-inference = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 294 |
+
controlnet-aux = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 295 |
+
convokit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 296 |
+
coola = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 297 |
+
coqui-tts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 298 |
+
coqui-tts-trainer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 299 |
+
craft-text-detector = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 300 |
+
creme = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 301 |
+
crocodile = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 302 |
+
crowd-kit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 303 |
+
cryoSPHERE = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 304 |
+
csle-common = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 305 |
+
csle-system-identification = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 306 |
+
ctgan = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 307 |
+
curated-transformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 308 |
+
cut-cross-entropy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 309 |
+
cvat-sdk = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 310 |
+
cybertask = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 311 |
+
d3rlpy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 312 |
+
dalle-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 313 |
+
dalle2-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 314 |
+
danila-lib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 315 |
+
danling = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 316 |
+
darts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 317 |
+
darwin-py = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 318 |
+
data-gradients = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 319 |
+
datachain = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 320 |
+
dataclass-array = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 321 |
+
dataeval = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 322 |
+
datarobot-drum = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 323 |
+
datarobotx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 324 |
+
datasets = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 325 |
+
datumaro = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 326 |
+
dctorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 327 |
+
deep-utils = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 328 |
+
deepchecks = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 329 |
+
deepchem = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 330 |
+
deepctr-torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 331 |
+
deepecho = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 332 |
+
deepepochs = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 333 |
+
deepforest = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 334 |
+
deeplabcut = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 335 |
+
deepmd-kit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 336 |
+
deepmultilingualpunctuation = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 337 |
+
deepparse = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 338 |
+
deeprobust = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 339 |
+
deepsparse = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 340 |
+
deepsparse-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 341 |
+
deepspeed = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 342 |
+
denoising-diffusion-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 343 |
+
descript-audio-codec = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 344 |
+
descript-audiotools = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 345 |
+
detecto = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 346 |
+
detoxify = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 347 |
+
dgenerate = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 348 |
+
dghs-imgutils = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 349 |
+
dgl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 350 |
+
dialogy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 351 |
+
dice-ml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 352 |
+
diffgram = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 353 |
+
diffq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 354 |
+
diffusers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 355 |
+
distilabel = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 356 |
+
distrifuser = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 357 |
+
dnikit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 358 |
+
docarray = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 359 |
+
doclayout-yolo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 360 |
+
docling-ibm-models = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 361 |
+
docquery = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 362 |
+
domino-code-assist = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 363 |
+
dreamsim = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 364 |
+
dropblock = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 365 |
+
druida = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 366 |
+
dvclive = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 367 |
+
e2-tts-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 368 |
+
e2cnn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 369 |
+
e3nn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 370 |
+
easyocr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 371 |
+
ebtorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 372 |
+
ecallisto-ng = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 373 |
+
edsnlp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 374 |
+
effdet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 375 |
+
einx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 376 |
+
eir-dl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 377 |
+
eis1600 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 378 |
+
eland = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 379 |
+
ema-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 380 |
+
embedchain = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 381 |
+
enformer-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 382 |
+
entmax = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 383 |
+
esm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 384 |
+
espaloma-charge = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 385 |
+
espnet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 386 |
+
etils = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 387 |
+
etna = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 388 |
+
evadb = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 389 |
+
evalscope = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 390 |
+
evaluate = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 391 |
+
exllamav2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 392 |
+
extractable = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 393 |
+
face-alignment = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 394 |
+
facenet-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 395 |
+
facexlib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 396 |
+
fair-esm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 397 |
+
fairseq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 398 |
+
fairseq2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 399 |
+
fairseq2n = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 400 |
+
faker-file = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 401 |
+
farm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 402 |
+
fast-bert = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 403 |
+
fast-pytorch-kmeans = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 404 |
+
fastai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 405 |
+
fastcore = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 406 |
+
fastestimator-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 407 |
+
fasttreeshap = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 408 |
+
fedml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 409 |
+
felupe = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 410 |
+
femr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 411 |
+
fer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 412 |
+
fft-conv-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 413 |
+
fickling = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 414 |
+
fireworks-ai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 415 |
+
flair = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 416 |
+
flashrag-dev = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 417 |
+
flax = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 418 |
+
flexgen = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 419 |
+
flgo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 420 |
+
flopth = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 421 |
+
flowcept = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 422 |
+
flytekitplugins-kfpytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 423 |
+
flytekitplugins-onnxpytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 424 |
+
fmbench = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 425 |
+
focal-frequency-loss = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 426 |
+
foldedtensor = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 427 |
+
fractal-tasks-core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 428 |
+
freegenius = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 429 |
+
freqtrade = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 430 |
+
fschat = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 431 |
+
funasr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 432 |
+
functorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 433 |
+
funlbm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 434 |
+
funsor = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 435 |
+
galore-torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 436 |
+
garak = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 437 |
+
garf = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 438 |
+
gateloop-transformer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 439 |
+
geffnet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 440 |
+
genutility = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 441 |
+
gfpgan = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 442 |
+
gigagan-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 443 |
+
gin-config = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 444 |
+
glasflow = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 445 |
+
gliner = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 446 |
+
gluonts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 447 |
+
gmft = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 448 |
+
google-cloud-aiplatform = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 449 |
+
gpforecaster = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 450 |
+
gpt3discord = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 451 |
+
gpytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 452 |
+
grad-cam = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 453 |
+
graph-weather = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 454 |
+
graphistry = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 455 |
+
gravitorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 456 |
+
gretel-synthetics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 457 |
+
gsplat = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 458 |
+
guardrails-ai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 459 |
+
guidance = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 460 |
+
gymnasium = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 461 |
+
hanlp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 462 |
+
happytransformer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 463 |
+
hbutils = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 464 |
+
heavyball = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 465 |
+
hezar = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 466 |
+
hf-deepali = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 467 |
+
hf-doc-builder = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 468 |
+
higher = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 469 |
+
hjxdl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 470 |
+
hkkang-utils = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 471 |
+
hordelib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 472 |
+
hpsv2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 473 |
+
huggingface-hub = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 474 |
+
hummingbird-ml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 475 |
+
hvae-backbone = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 476 |
+
hya = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 477 |
+
hypothesis-torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 478 |
+
ibm-metrics-plugin = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 479 |
+
ibm-watson-machine-learning = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 480 |
+
ibm-watsonx-ai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 481 |
+
icetk = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 482 |
+
icevision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 483 |
+
iden = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 484 |
+
idvpackage = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 485 |
+
iglovikov-helper-functions = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 486 |
+
imagededup = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 487 |
+
imagen-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 488 |
+
imaginAIry = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 489 |
+
img2vec-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 490 |
+
incendio = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 491 |
+
inference = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 492 |
+
inference-gpu = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 493 |
+
infinity-emb = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 494 |
+
info-nce-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 495 |
+
infoapps-mlops-sdk = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 496 |
+
instructlab = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 497 |
+
instructlab-dolomite = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 498 |
+
instructlab-eval = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 499 |
+
instructlab-sdg = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 500 |
+
instructlab-training = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 501 |
+
invisible-watermark = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 502 |
+
iobm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 503 |
+
ipex-llm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 504 |
+
iree-turbine = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 505 |
+
irisml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 506 |
+
irisml-tasks-azure-openai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 507 |
+
irisml-tasks-torchvision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 508 |
+
irisml-tasks-training = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 509 |
+
item-matching = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 510 |
+
ivadomed = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 511 |
+
jaqpotpy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 512 |
+
jina = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 513 |
+
judo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 514 |
+
junky = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 515 |
+
k-diffusion = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 516 |
+
k1lib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 517 |
+
k2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 518 |
+
kappadata = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 519 |
+
kappamodules = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 520 |
+
karbonn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 521 |
+
kats = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 522 |
+
kbnf = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 523 |
+
kedro-datasets = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 524 |
+
keybert = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 525 |
+
keytotext = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 526 |
+
khoj = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 527 |
+
kiui = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 528 |
+
konfuzio-sdk = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 529 |
+
kornia = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 530 |
+
kornia-moons = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 531 |
+
kraken = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 532 |
+
kwarray = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 533 |
+
kwimage = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 534 |
+
labml-nn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 535 |
+
lagent = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 536 |
+
laion-clap = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 537 |
+
lale = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 538 |
+
lama-cleaner = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 539 |
+
lancedb = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 540 |
+
langcheck = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 541 |
+
langkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 542 |
+
langroid = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 543 |
+
langtest = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 544 |
+
layoutparser = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 545 |
+
ldp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 546 |
+
leafmap = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 547 |
+
leap-ie = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 548 |
+
leibniz = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 549 |
+
leptonai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 550 |
+
letmedoit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 551 |
+
lhotse = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 552 |
+
lib310 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 553 |
+
libpecos = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 554 |
+
librec-auto = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 555 |
+
libretranslate = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 556 |
+
liger-kernel = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 557 |
+
liger-kernel-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 558 |
+
lightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 559 |
+
lightning = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 560 |
+
lightning-bolts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 561 |
+
lightning-fabric = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 562 |
+
lightning-habana = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 563 |
+
lightning-lite = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 564 |
+
lightrag = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 565 |
+
lightweight-gan = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 566 |
+
lightwood = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 567 |
+
linear-attention-transformer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 568 |
+
linear-operator = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 569 |
+
linformer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 570 |
+
linformer-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 571 |
+
liom-toolkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 572 |
+
lion-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 573 |
+
lit-nlp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 574 |
+
litdata = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 575 |
+
litelama = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 576 |
+
litgpt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 577 |
+
llama-index-embeddings-adapter = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 578 |
+
llama-index-embeddings-clip = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 579 |
+
llama-index-embeddings-instructor = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 580 |
+
llama-index-llms-huggingface = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 581 |
+
llama-index-postprocessor-colbert-rerank = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 582 |
+
llm-blender = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 583 |
+
llm-foundry = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 584 |
+
llm-guard = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 585 |
+
llm-rs = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 586 |
+
llm2vec = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 587 |
+
llmcompressor = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 588 |
+
llmlingua = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 589 |
+
llmvm-cli = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 590 |
+
lm-eval = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 591 |
+
lmdeploy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 592 |
+
lmms-eval = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 593 |
+
local-attention = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 594 |
+
lovely-tensors = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 595 |
+
lpips = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 596 |
+
lycoris-lora = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 597 |
+
mace-torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 598 |
+
magic-pdf = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 599 |
+
magicsoup = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 600 |
+
magvit2-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 601 |
+
maite = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 602 |
+
manga-ocr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 603 |
+
manifest-ml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 604 |
+
manipulation = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 605 |
+
marker-pdf = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 606 |
+
matgl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 607 |
+
med-imagetools = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 608 |
+
medaka = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 609 |
+
medcat = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 610 |
+
medmnist = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 611 |
+
megablocks = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 612 |
+
megatron-energon = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 613 |
+
memos = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 614 |
+
meshgpt-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 615 |
+
metatensor-torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 616 |
+
mflux = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 617 |
+
mia-vgg = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 618 |
+
miditok = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 619 |
+
minari = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 620 |
+
minicons = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 621 |
+
ml2rt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 622 |
+
mlagents = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 623 |
+
mlbench-core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 624 |
+
mlcroissant = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 625 |
+
mlpfile = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 626 |
+
mlx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 627 |
+
mlx-whisper = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 628 |
+
mmaction2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 629 |
+
mmengine = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 630 |
+
mmengine-lite = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 631 |
+
mmocr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 632 |
+
mmpose = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 633 |
+
mmsegmentation = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 634 |
+
modeci-mdf = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 635 |
+
model2vec = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 636 |
+
modelscope = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 637 |
+
modelspec = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 638 |
+
monai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 639 |
+
monai-weekly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 640 |
+
monotonic-alignment-search = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 641 |
+
monty = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 642 |
+
mosaicml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 643 |
+
mosaicml-streaming = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 644 |
+
moshi = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 645 |
+
mteb = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 646 |
+
mtmtrain = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 647 |
+
multi-quantization = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 648 |
+
myhand = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 649 |
+
nGPT-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 650 |
+
naeural-core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 651 |
+
napari = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 652 |
+
napatrackmater = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 653 |
+
nara-wpe = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 654 |
+
natten = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 655 |
+
nbeats-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 656 |
+
nebulae = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 657 |
+
nemo-toolkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 658 |
+
neptune = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 659 |
+
neptune-client = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 660 |
+
nerfacc = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 661 |
+
nerfstudio = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 662 |
+
nessai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 663 |
+
netcal = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 664 |
+
neural-rag = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 665 |
+
neuralforecast = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 666 |
+
neuralnets = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 667 |
+
neuralprophet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 668 |
+
neuspell = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 669 |
+
nevergrad = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 670 |
+
nexfort = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 671 |
+
nimblephysics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 672 |
+
nirtorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 673 |
+
nkululeko = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 674 |
+
nlp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 675 |
+
nlptooltest = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 676 |
+
nnAudio = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 677 |
+
nnodely = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 678 |
+
nnsight = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 679 |
+
nnunetv2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 680 |
+
noisereduce = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 681 |
+
nonebot-plugin-nailongremove = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 682 |
+
nowcasting-dataloader = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 683 |
+
nowcasting-forecast = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 684 |
+
nshtrainer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 685 |
+
nuwa-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 686 |
+
nvflare = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 687 |
+
nvidia-modelopt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 688 |
+
ocf-datapipes = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 689 |
+
ocnn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 690 |
+
ogb = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 691 |
+
ohmeow-blurr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 692 |
+
olive-ai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 693 |
+
omlt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 694 |
+
ommlx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 695 |
+
onediff = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 696 |
+
onediffx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 697 |
+
onnx2pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 698 |
+
onnx2torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 699 |
+
opacus = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 700 |
+
open-clip-torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 701 |
+
open-flamingo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 702 |
+
open-interpreter = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 703 |
+
openbb-terminal-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 704 |
+
openmim = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 705 |
+
openparse = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 706 |
+
openunmix = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 707 |
+
openvino-dev = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 708 |
+
openvino-tokenizers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 709 |
+
openvino-xai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 710 |
+
openwakeword = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 711 |
+
opt-einsum-fx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 712 |
+
optimum = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 713 |
+
optimum-habana = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 714 |
+
optimum-intel = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 715 |
+
optimum-neuron = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 716 |
+
optimum-quanto = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 717 |
+
optree = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 718 |
+
optuna = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 719 |
+
optuna-dashboard = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 720 |
+
optuna-integration = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 721 |
+
oracle-ads = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 722 |
+
orbit-ml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 723 |
+
otx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 724 |
+
outetts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 725 |
+
outlines = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 726 |
+
outlines-core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 727 |
+
paddlenlp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 728 |
+
pai-easycv = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 729 |
+
pandasai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 730 |
+
panns-inference = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 731 |
+
patchwork-cli = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 732 |
+
peft = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 733 |
+
pegasuspy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 734 |
+
pelutils = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 735 |
+
penn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 736 |
+
perforatedai-freemium = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 737 |
+
performer-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 738 |
+
petastorm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 739 |
+
pfio = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 740 |
+
pgmpy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 741 |
+
phenolrs = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 742 |
+
phobos = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 743 |
+
pi-zero-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 744 |
+
pinecone-text = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 745 |
+
piq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 746 |
+
pix2tex = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 747 |
+
pix2text = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 748 |
+
pnnx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 749 |
+
policyengine-us-data = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 750 |
+
polyfuzz = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 751 |
+
pomegranate = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 752 |
+
positional-encodings = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 753 |
+
prefigure = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 754 |
+
product-key-memory = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 755 |
+
ptflops = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 756 |
+
ptwt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 757 |
+
pulser-core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 758 |
+
punctuators = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 759 |
+
py2ls = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 760 |
+
pyabsa = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 761 |
+
"pyannote.audio" = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 762 |
+
pyawd = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 763 |
+
pyclarity = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 764 |
+
pycox = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 765 |
+
pyfemtet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 766 |
+
pyg-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 767 |
+
pygrinder = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 768 |
+
pyhealth = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 769 |
+
pyhf = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 770 |
+
pyiqa = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 771 |
+
pykeen = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 772 |
+
pykeops = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 773 |
+
pylance = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 774 |
+
pylineaGT = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 775 |
+
pymanopt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 776 |
+
pymde = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 777 |
+
pypots = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 778 |
+
pyqlib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 779 |
+
pyqtorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 780 |
+
pyro-ppl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 781 |
+
pysentimiento = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 782 |
+
pyserini = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 783 |
+
pysr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 784 |
+
pythainlp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 785 |
+
python-doctr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 786 |
+
pytorch-fid = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 787 |
+
pytorch-forecasting = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 788 |
+
pytorch-ignite = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 789 |
+
pytorch-kinematics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 790 |
+
pytorch-lightning = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 791 |
+
pytorch-lightning-bolts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 792 |
+
pytorch-metric-learning = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 793 |
+
pytorch-model-summary = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 794 |
+
pytorch-msssim = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 795 |
+
pytorch-pfn-extras = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 796 |
+
pytorch-pretrained-bert = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 797 |
+
pytorch-ranger = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 798 |
+
pytorch-seed = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 799 |
+
pytorch-tabnet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 800 |
+
pytorch-tabular = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 801 |
+
pytorch-toolbelt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 802 |
+
pytorch-transformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 803 |
+
pytorch-transformers-pvt-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 804 |
+
pytorch-triton-rocm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 805 |
+
pytorch-warmup = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 806 |
+
pytorch-wavelets = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 807 |
+
pytorch_optimizer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 808 |
+
pytorch_revgrad = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 809 |
+
pytorchcv = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 810 |
+
pytorchltr2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 811 |
+
pyvene = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 812 |
+
pyvespa = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 813 |
+
qianfan = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 814 |
+
qibo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 815 |
+
qiskit-machine-learning = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 816 |
+
qtorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 817 |
+
quanto = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 818 |
+
quick-anomaly-detector = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 819 |
+
rastervision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 820 |
+
rastervision-pytorch-backend = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 821 |
+
rastervision-pytorch-learner = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 822 |
+
ray-lightning = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 823 |
+
rclip = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 824 |
+
realesrgan = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 825 |
+
recbole = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 826 |
+
recommenders = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 827 |
+
redcat = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 828 |
+
reformer-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 829 |
+
regex-sampler = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 830 |
+
replay-rec = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 831 |
+
rerankers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 832 |
+
research-framework = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 833 |
+
resemble-enhance = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 834 |
+
resnest = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 835 |
+
rf-clip = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 836 |
+
rf-groundingdino = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 837 |
+
rfconv = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 838 |
+
rich-logger = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 839 |
+
ring-attention-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 840 |
+
rltrade-test = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 841 |
+
rotary-embedding-torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 842 |
+
rsp-ml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 843 |
+
rust-circuit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 844 |
+
s2fft = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 845 |
+
s3prl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 846 |
+
s3torchconnector = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 847 |
+
saferx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 848 |
+
safetensors = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 849 |
+
sagemaker-huggingface-inference-toolkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 850 |
+
sagemaker-ssh-helper = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 851 |
+
salesforce-lavis = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 852 |
+
salesforce-merlion = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 853 |
+
samv2 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 854 |
+
scib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 855 |
+
scib-metrics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 856 |
+
scvi-tools = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 857 |
+
sdmetrics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 858 |
+
secretflow = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 859 |
+
segment-anything-hq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 860 |
+
segment-anything-py = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 861 |
+
segmentation-models-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 862 |
+
self-rewarding-lm-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 863 |
+
semantic-kernel = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 864 |
+
semantic-router = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 865 |
+
senselab = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 866 |
+
sent2vec = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 867 |
+
sentence-transformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 868 |
+
sequence-model-train = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 869 |
+
serotiny = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 870 |
+
sevenn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 871 |
+
sglang = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 872 |
+
shap = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 873 |
+
silero-api-server = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 874 |
+
silero-vad = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 875 |
+
silicondiff-npu = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 876 |
+
simclr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 877 |
+
simple-lama-inpainting = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 878 |
+
sinabs = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 879 |
+
sixdrepnet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 880 |
+
skforecast = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 881 |
+
skorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 882 |
+
skrl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 883 |
+
skt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 884 |
+
sktime = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 885 |
+
sktmls = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 886 |
+
slangtorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 887 |
+
smartnoise-synth = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 888 |
+
smashed = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 889 |
+
smplx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 890 |
+
smqtk-descriptors = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 891 |
+
smqtk-detection = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 892 |
+
snntorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 893 |
+
snorkel = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 894 |
+
snowflake-ml-python = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 895 |
+
so-vits-svc-fork = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 896 |
+
sonusai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 897 |
+
sony-custom-layers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 898 |
+
sotopia = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 899 |
+
spacr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 900 |
+
spacy-curated-transformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 901 |
+
spacy-experimental = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 902 |
+
spacy-huggingface-pipelines = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 903 |
+
spacy-llm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 904 |
+
spacy-transformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 905 |
+
span-marker = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 906 |
+
spandrel = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 907 |
+
spandrel-extra-arches = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 908 |
+
sparrow-python = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 909 |
+
spatialdata = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 910 |
+
speechbrain = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 911 |
+
speechtokenizer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 912 |
+
spikeinterface = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 913 |
+
spikingjelly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 914 |
+
spotiflow = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 915 |
+
spotpython = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 916 |
+
spotriver = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 917 |
+
squirrel-core = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 918 |
+
stable-baselines3 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 919 |
+
stable-diffusion-sdkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 920 |
+
stable-ts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 921 |
+
stanford-stk = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 922 |
+
stanfordnlp = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 923 |
+
stanza = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 924 |
+
startorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 925 |
+
streamtasks = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 926 |
+
struct-eqtable = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 927 |
+
stylegan2-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 928 |
+
supar = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 929 |
+
super-gradients = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 930 |
+
super-image = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 931 |
+
superlinked = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 932 |
+
supervisely = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 933 |
+
surya-ocr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 934 |
+
svdiff-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 935 |
+
swarm-models = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 936 |
+
swarmauri = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 937 |
+
swarms-memory = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 938 |
+
swebench = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 939 |
+
syft = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 940 |
+
sympytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 941 |
+
syne-tune = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 942 |
+
synthcity = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 943 |
+
t5 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 944 |
+
tab-transformer-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 945 |
+
tabpfn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 946 |
+
taming-transformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 947 |
+
taming-transformers-rom1504 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 948 |
+
taskwiz = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 949 |
+
tbparse = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 950 |
+
tecton = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 951 |
+
tensor-parallel = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 952 |
+
tensorcircuit-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 953 |
+
tensordict = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 954 |
+
tensordict-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 955 |
+
tensorizer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 956 |
+
tensorrt-llm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 957 |
+
texify = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 958 |
+
text2text = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 959 |
+
textattack = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 960 |
+
tfkit = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 961 |
+
thepipe-api = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 962 |
+
thinc = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 963 |
+
thingsvision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 964 |
+
thirdai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 965 |
+
thop = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 966 |
+
tianshou = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 967 |
+
tidy3d = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 968 |
+
timesfm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 969 |
+
timm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 970 |
+
tipo-kgen = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 971 |
+
tmnt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 972 |
+
toad = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 973 |
+
tomesd = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 974 |
+
top2vec = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 975 |
+
torch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 976 |
+
torch-audiomentations = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 977 |
+
torch-dct = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 978 |
+
torch-delaunay = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 979 |
+
torch-directml = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 980 |
+
torch-ema = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 981 |
+
torch-encoding = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 982 |
+
torch-fidelity = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 983 |
+
torch-geometric = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 984 |
+
torch-geopooling = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 985 |
+
torch-harmonics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 986 |
+
torch-kmeans = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 987 |
+
torch-lr-finder = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 988 |
+
torch-max-mem = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 989 |
+
torch-npu = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 990 |
+
torch-optimi = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 991 |
+
torch-optimizer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 992 |
+
torch-ort = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 993 |
+
torch-pitch-shift = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 994 |
+
torch-ppr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 995 |
+
torch-pruning = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 996 |
+
torch-snippets = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 997 |
+
torch-stoi = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 998 |
+
torch-struct = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 999 |
+
torch-tensorrt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1000 |
+
torchani = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1001 |
+
torchattacks = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1002 |
+
torchaudio = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1003 |
+
torchbiggraph = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1004 |
+
torchcam = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1005 |
+
torchcde = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1006 |
+
torchcfm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1007 |
+
torchcrepe = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1008 |
+
torchdata = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1009 |
+
torchdatasets-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1010 |
+
torchdiffeq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1011 |
+
torchdyn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1012 |
+
torchestra = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1013 |
+
torcheval = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1014 |
+
torcheval-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1015 |
+
torchextractor = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1016 |
+
torchfcpe = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1017 |
+
torchfun = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1018 |
+
torchfunc-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1019 |
+
torchgeo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1020 |
+
torchgeometry = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1021 |
+
torchio = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1022 |
+
torchjpeg = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1023 |
+
torchlayers-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1024 |
+
torchmeta = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1025 |
+
torchmetrics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1026 |
+
torchmocks = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1027 |
+
torchpack = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1028 |
+
torchpippy = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1029 |
+
torchpq = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1030 |
+
torchprofile = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1031 |
+
torchquantlib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1032 |
+
torchrec = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1033 |
+
torchrec-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1034 |
+
torchrec-nightly-cpu = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1035 |
+
torchrl = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1036 |
+
torchrl-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1037 |
+
torchscale = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1038 |
+
torchsde = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1039 |
+
torchseg = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1040 |
+
torchserve = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1041 |
+
torchserve-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1042 |
+
torchsnapshot-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1043 |
+
torchsr = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1044 |
+
torchstain = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1045 |
+
torchsummaryX = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1046 |
+
torchtext = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1047 |
+
torchtnt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1048 |
+
torchtnt-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1049 |
+
torchtyping = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1050 |
+
torchutil = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1051 |
+
torchvinecopulib = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1052 |
+
torchvision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1053 |
+
torchviz = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1054 |
+
torchx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1055 |
+
torchx-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1056 |
+
torchxrayvision = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1057 |
+
totalspineseg = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1058 |
+
tracebloc-package-dev = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1059 |
+
trainer = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1060 |
+
transformer-engine = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1061 |
+
transformer-lens = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1062 |
+
transformer-smaller-training-vocab = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1063 |
+
transformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1064 |
+
transformers-domain-adaptation = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1065 |
+
transfusion-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1066 |
+
transparent-background = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1067 |
+
treescope = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1068 |
+
trolo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1069 |
+
tsai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1070 |
+
tslearn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1071 |
+
ttspod = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1072 |
+
txtai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1073 |
+
tyro = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1074 |
+
u8darts = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1075 |
+
uhg = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1076 |
+
uitestrunner-syberos = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1077 |
+
ultimate-rvc = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1078 |
+
ultralytics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1079 |
+
ultralytics-thop = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1080 |
+
unav = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1081 |
+
unbabel-comet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1082 |
+
underthesea = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1083 |
+
unfoldNd = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1084 |
+
unimernet = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1085 |
+
unitorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1086 |
+
unitxt = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1087 |
+
unsloth = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1088 |
+
unsloth-zoo = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1089 |
+
unstructured = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1090 |
+
unstructured-inference = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1091 |
+
utilsd = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1092 |
+
v-diffusion-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1093 |
+
vIQA = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1094 |
+
vectice = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1095 |
+
vector-quantize-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1096 |
+
vectorhub-nightly = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1097 |
+
versatile-audio-upscaler = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1098 |
+
vertexai = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1099 |
+
vesin = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1100 |
+
vgg-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1101 |
+
video-representations-extractor = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1102 |
+
viser = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1103 |
+
vision-datasets = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1104 |
+
visionmetrics = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1105 |
+
visu3d = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1106 |
+
vit-pytorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1107 |
+
viturka-nn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1108 |
+
vllm = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1109 |
+
vllm-flash-attn = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1110 |
+
vocos = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1111 |
+
vollseg = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1112 |
+
vtorch = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1113 |
+
wavmark = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1114 |
+
wdoc = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1115 |
+
whisper-live = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1116 |
+
whisper-timestamped = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1117 |
+
whisperx = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1118 |
+
wilds = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1119 |
+
wordllama = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1120 |
+
worker-automate-hub = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1121 |
+
wxbtool = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1122 |
+
x-clip = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1123 |
+
x-transformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1124 |
+
xaitk_saliency = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1125 |
+
xformers = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1126 |
+
xgrammar = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1127 |
+
xinference = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1128 |
+
xtts-api-server = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1129 |
+
yolo-poser = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1130 |
+
yolov5 = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1131 |
+
yolov7-package = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1132 |
+
yta-general-utils = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1133 |
+
zensvi = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1134 |
+
zetascale = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
| 1135 |
+
zuko = [{ index = "pytorch-cpu", marker = "platform_system == 'Linux'" }]
|
replit.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AI-Powered Personal Finance Assistant
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
|
| 5 |
+
This project is an AI-powered personal finance assistant built with Streamlit that helps users analyze their financial transactions through natural language queries. The system automatically categorizes expenses using transformer models, enables semantic search over transaction history, and provides intelligent insights through conversational AI. Users can upload bank statements in CSV or Excel format and interact with their financial data using plain English questions to get summaries, trends, and spending analysis.
|
| 6 |
+
|
| 7 |
+
## User Preferences
|
| 8 |
+
|
| 9 |
+
Preferred communication style: Simple, everyday language.
|
| 10 |
+
|
| 11 |
+
## System Architecture
|
| 12 |
+
|
| 13 |
+
### Frontend Architecture
|
| 14 |
+
- **Streamlit Web Application**: Single-page application serving as the main user interface
|
| 15 |
+
- **Interactive Dashboard**: Real-time data visualization with Plotly charts and graphs
|
| 16 |
+
- **File Upload Interface**: Supports CSV and Excel file formats with validation
|
| 17 |
+
- **Chat Interface**: Conversational AI interface for natural language queries
|
| 18 |
+
|
| 19 |
+
### Backend Architecture
|
| 20 |
+
- **Modular Component Design**: Separated into distinct classes for different functionalities
|
| 21 |
+
- `DataProcessor`: Handles file loading and data preprocessing
|
| 22 |
+
- `ExpenseCategorizer`: Automatic expense categorization using transformer models
|
| 23 |
+
- `VectorStore`: Manages vector embeddings and semantic search
|
| 24 |
+
- `ConversationHandler`: Processes natural language queries and generates responses
|
| 25 |
+
- `FinanceVisualizer`: Creates interactive financial visualizations
|
| 26 |
+
|
| 27 |
+
### Data Processing Pipeline
|
| 28 |
+
- **Data Ingestion**: Automatic detection and parsing of CSV/Excel files
|
| 29 |
+
- **Data Cleaning**: Column mapping, standardization, and validation
|
| 30 |
+
- **Expense Categorization**: Zero-shot classification using transformer models with fallback keyword matching
|
| 31 |
+
- **Vector Embedding**: Transaction descriptions converted to embeddings for semantic search
|
| 32 |
+
|
| 33 |
+
### AI and ML Components
|
| 34 |
+
- **Transformer Models**: HuggingFace transformers for zero-shot expense classification
|
| 35 |
+
- **OpenAI Integration**: GPT-5 model for conversational AI and query processing
|
| 36 |
+
- **Vector Search**: ChromaDB for storing and retrieving transaction embeddings
|
| 37 |
+
- **Semantic Search**: Context-aware transaction retrieval based on user queries
|
| 38 |
+
|
| 39 |
+
### Data Storage
|
| 40 |
+
- **In-Memory Vector Database**: ChromaDB configured for in-memory storage
|
| 41 |
+
- **Session State Management**: Streamlit session state for maintaining user data and conversation history
|
| 42 |
+
- **Transaction Memory**: Pandas DataFrames for structured data manipulation
|
| 43 |
+
|
| 44 |
+
### Visualization System
|
| 45 |
+
- **Interactive Charts**: Plotly-based visualizations for spending trends and category breakdowns
|
| 46 |
+
- **Real-time Updates**: Dynamic chart generation based on data filters and user interactions
|
| 47 |
+
- **Multi-format Support**: Pie charts, line graphs, and trend analysis
|
| 48 |
+
|
| 49 |
+
## External Dependencies
|
| 50 |
+
|
| 51 |
+
### AI and ML Services
|
| 52 |
+
- **OpenAI API**: GPT-5 model for conversational AI and natural language processing
|
| 53 |
+
- **HuggingFace Transformers**: Pre-trained models for expense categorization
|
| 54 |
+
- **ChromaDB**: Vector database for semantic search and embeddings storage
|
| 55 |
+
|
| 56 |
+
### Python Libraries
|
| 57 |
+
- **Streamlit**: Web application framework and user interface
|
| 58 |
+
- **Pandas**: Data manipulation and analysis
|
| 59 |
+
- **NumPy**: Numerical computing and array operations
|
| 60 |
+
- **Plotly**: Interactive data visualization and charting
|
| 61 |
+
|
| 62 |
+
### Data Processing
|
| 63 |
+
- **File Format Support**: Native CSV and Excel file processing
|
| 64 |
+
- **Text Processing**: Regular expressions and string manipulation for data cleaning
|
| 65 |
+
- **Date/Time Handling**: DateTime operations for temporal analysis
|
| 66 |
+
|
| 67 |
+
### Infrastructure
|
| 68 |
+
- **Environment Variables**: OpenAI API key configuration
|
| 69 |
+
- **Memory Management**: In-memory data storage for session persistence
|
| 70 |
+
- **Error Handling**: Comprehensive exception handling and user feedback
|
requirements.txt
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Core
|
| 2 |
+
streamlit==1.28.1
|
| 3 |
+
altair==5.2.0
|
| 4 |
+
pandas==2.0.3
|
| 5 |
+
numpy==1.24.3
|
| 6 |
+
|
| 7 |
+
# AI / NLP
|
| 8 |
+
openai==1.12.0
|
| 9 |
+
transformers==4.37.2
|
| 10 |
+
sentence-transformers==2.2.2
|
| 11 |
+
huggingface-hub==0.20.3
|
| 12 |
+
tokenizers==0.15.1
|
| 13 |
+
nltk==3.8.1
|
| 14 |
+
|
| 15 |
+
# Vector DB
|
| 16 |
+
chromadb==0.4.22
|
| 17 |
+
|
| 18 |
+
# ML / Deep Learning (CPU versions for easy install)
|
| 19 |
+
torch==2.1.2+cpu
|
| 20 |
+
torchvision==0.16.2+cpu
|
| 21 |
+
torchaudio==2.1.2+cpu
|
| 22 |
+
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 23 |
+
|
| 24 |
+
# Model runtimes
|
| 25 |
+
onnxruntime==1.16.3
|
| 26 |
+
|
| 27 |
+
# API & Backend
|
| 28 |
+
fastapi==0.109.0
|
| 29 |
+
uvicorn==0.25.0
|
| 30 |
+
typer==0.9.0
|
| 31 |
+
httpx==0.25.2
|
| 32 |
+
|
| 33 |
+
# Logging & Utils
|
| 34 |
+
coloredlogs==15.0.1
|
| 35 |
+
gitpython==3.1.41
|
| 36 |
+
google-auth==2.26.2
|
| 37 |
+
|
| 38 |
+
# JSON & Validation
|
| 39 |
+
jsonschema==4.20.0
|
| 40 |
+
jsonschema-specifications==2023.12.1
|
| 41 |
+
|
| 42 |
+
# Observability
|
| 43 |
+
opentelemetry-sdk==1.22.0
|
| 44 |
+
opentelemetry-semantic-conventions==0.43b0
|
| 45 |
+
opentelemetry-exporter-otlp-proto-grpc==1.22.0
|
| 46 |
+
|
| 47 |
+
# Kubernetes (optional, if deploying)
|
| 48 |
+
kubernetes==28.1.0
|
sample_transactions.csv
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
date,description,amount
|
| 2 |
+
2024-01-15,Grocery Store - Whole Foods,-127.43
|
| 3 |
+
2024-01-16,Coffee Shop - Starbucks,-4.75
|
| 4 |
+
2024-01-17,Gas Station - Shell,-45.20
|
| 5 |
+
2024-01-18,Salary Deposit,2500.00
|
| 6 |
+
2024-01-19,Restaurant - Pizza Palace,-32.50
|
| 7 |
+
2024-01-22,Electric Bill - PG&E,-89.67
|
| 8 |
+
2024-01-23,Amazon Purchase - Electronics,-245.99
|
| 9 |
+
2024-01-24,Uber Ride,-18.50
|
| 10 |
+
2024-01-25,Gym Membership - Planet Fitness,-24.99
|
| 11 |
+
2024-01-26,Grocery Store - Safeway,-98.76
|
| 12 |
+
2024-01-29,Movie Theater - AMC,-27.00
|
| 13 |
+
2024-01-30,Phone Bill - Verizon,-65.43
|
| 14 |
+
2024-02-01,Rent Payment,-1200.00
|
| 15 |
+
2024-02-02,Coffee Shop - Local Cafe,-6.25
|
| 16 |
+
2024-02-05,Gas Station - Chevron,-52.30
|
| 17 |
+
2024-02-06,Restaurant - Thai Express,-28.75
|
| 18 |
+
2024-02-07,Grocery Store - Trader Joes,-76.82
|
| 19 |
+
2024-02-08,Doctor Visit - Medical Center,-150.00
|
| 20 |
+
2024-02-09,Bookstore - Barnes & Noble,-34.99
|
| 21 |
+
2024-02-12,Internet Bill - Comcast,-79.99
|
| 22 |
+
2024-02-13,Uber Eats - Mexican Food,-22.50
|
| 23 |
+
2024-02-14,Valentine's Dinner - Fancy Restaurant,-125.00
|
| 24 |
+
2024-02-15,Salary Deposit,2500.00
|
| 25 |
+
2024-02-16,Gas Station - Shell,-41.75
|
| 26 |
+
2024-02-19,Clothing Store - Target,-67.89
|
| 27 |
+
2024-02-20,Pharmacy - CVS,-23.45
|
| 28 |
+
2024-02-21,Coffee Shop - Starbucks,-5.50
|
| 29 |
+
2024-02-22,Grocery Store - Whole Foods,-134.67
|
| 30 |
+
2024-02-23,Car Insurance - State Farm,-120.00
|
| 31 |
+
2024-02-26,Restaurant - Sushi Place,-89.50
|
| 32 |
+
2024-02-27,Streaming Service - Netflix,-15.99
|
| 33 |
+
2024-02-28,ATM Withdrawal,-100.00
|
| 34 |
+
2024-03-01,Rent Payment,-1200.00
|
| 35 |
+
2024-03-04,Gas Station - Exxon,-48.90
|
| 36 |
+
2024-03-05,Grocery Store - Kroger,-112.34
|
| 37 |
+
2024-03-06,Coffee Shop - Dunkin,-3.99
|
| 38 |
+
2024-03-07,Freelance Work Payment,750.00
|
| 39 |
+
2024-03-08,Restaurant - Italian Bistro,-56.75
|
| 40 |
+
2024-03-11,Electric Bill - PG&E,-94.23
|
| 41 |
+
2024-03-12,Uber Ride to Airport,-35.00
|
| 42 |
+
2024-03-13,Flight Booking - Delta Airlines,-387.50
|
| 43 |
+
2024-03-14,Hotel Stay - Marriott,-189.99
|
| 44 |
+
2024-03-15,Salary Deposit,2500.00
|
| 45 |
+
2024-03-18,Vacation Dinner - Resort Restaurant,-78.50
|
| 46 |
+
2024-03-19,Souvenir Shop - Gift Items,-45.25
|
| 47 |
+
2024-03-20,Return Flight - Delta Airlines,-0.00
|
| 48 |
+
2024-03-21,Uber Ride from Airport,-32.75
|
| 49 |
+
2024-03-22,Grocery Store - Welcome Back Shop,-89.67
|
| 50 |
+
2024-03-25,Phone Bill - Verizon,-65.43
|
| 51 |
+
2024-03-26,Gas Station - Shell,-44.20
|
| 52 |
+
2024-03-27,Restaurant - Local Diner,-19.99
|
| 53 |
+
2024-03-28,Gym Session - Day Pass,-15.00
|
| 54 |
+
2024-03-29,Coffee Shop - New Place,-7.25
|
smart_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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import numpy as np
|
| 3 |
+
from datetime import datetime, timedelta
|
| 4 |
+
from typing import Dict, List, Tuple, Any
|
| 5 |
+
import streamlit as st
|
| 6 |
+
|
| 7 |
+
class SmartAlertsSystem:
|
| 8 |
+
"""AI-powered spending alerts and notifications."""
|
| 9 |
+
|
| 10 |
+
def __init__(self):
|
| 11 |
+
self.alert_thresholds = {
|
| 12 |
+
'spending_spike': 1.5, # 50% above normal
|
| 13 |
+
'budget_warning': 0.8, # 80% of budget used
|
| 14 |
+
'unusual_transaction': 2.0, # 2x std deviation
|
| 15 |
+
'category_overspend': 1.3 # 30% above category average
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
def generate_alerts(self, df: pd.DataFrame, budgets: Dict[str, float] = None) -> List[Dict[str, Any]]:
|
| 19 |
+
"""Generate comprehensive smart alerts."""
|
| 20 |
+
alerts = []
|
| 21 |
+
|
| 22 |
+
# Current month data
|
| 23 |
+
current_month = datetime.now().strftime('%Y-%m')
|
| 24 |
+
current_month_data = df[df['date'].dt.strftime('%Y-%m') == current_month]
|
| 25 |
+
|
| 26 |
+
# 1. Budget alerts
|
| 27 |
+
if budgets:
|
| 28 |
+
alerts.extend(self._check_budget_alerts(current_month_data, budgets))
|
| 29 |
+
|
| 30 |
+
# 2. Spending spike alerts
|
| 31 |
+
alerts.extend(self._check_spending_spikes(df, current_month_data))
|
| 32 |
+
|
| 33 |
+
# 3. Unusual transaction alerts
|
| 34 |
+
alerts.extend(self._check_unusual_transactions(df, current_month_data))
|
| 35 |
+
|
| 36 |
+
# 4. Category overspending alerts
|
| 37 |
+
alerts.extend(self._check_category_overspending(df, current_month_data))
|
| 38 |
+
|
| 39 |
+
# 5. Trend alerts
|
| 40 |
+
alerts.extend(self._check_trend_alerts(df))
|
| 41 |
+
|
| 42 |
+
# 6. Recurring expense alerts
|
| 43 |
+
alerts.extend(self._check_recurring_expense_alerts(df))
|
| 44 |
+
|
| 45 |
+
# Sort by priority
|
| 46 |
+
alerts.sort(key=lambda x: self._get_alert_priority(x['type']), reverse=True)
|
| 47 |
+
|
| 48 |
+
return alerts[:10] # Return top 10 most important alerts
|
| 49 |
+
|
| 50 |
+
def _check_budget_alerts(self, current_data: pd.DataFrame, budgets: Dict[str, float]) -> List[Dict[str, Any]]:
|
| 51 |
+
"""Check for budget-related alerts."""
|
| 52 |
+
alerts = []
|
| 53 |
+
|
| 54 |
+
if 'category' not in current_data.columns:
|
| 55 |
+
return alerts
|
| 56 |
+
|
| 57 |
+
current_spending = current_data[current_data['amount'] < 0].groupby('category')['amount'].sum().abs()
|
| 58 |
+
|
| 59 |
+
for category, budget in budgets.items():
|
| 60 |
+
if category in current_spending:
|
| 61 |
+
spent = current_spending[category]
|
| 62 |
+
percentage_used = (spent / budget) * 100
|
| 63 |
+
|
| 64 |
+
if percentage_used >= 100:
|
| 65 |
+
alerts.append({
|
| 66 |
+
'type': 'budget_exceeded',
|
| 67 |
+
'category': category,
|
| 68 |
+
'message': f"🚨 Budget exceeded! You've spent ${spent:.2f} of your ${budget:.2f} budget for {category}",
|
| 69 |
+
'severity': 'high',
|
| 70 |
+
'amount': spent,
|
| 71 |
+
'budget': budget,
|
| 72 |
+
'percentage': percentage_used
|
| 73 |
+
})
|
| 74 |
+
elif percentage_used >= 80:
|
| 75 |
+
alerts.append({
|
| 76 |
+
'type': 'budget_warning',
|
| 77 |
+
'category': category,
|
| 78 |
+
'message': f"⚠️ Budget warning! You've used {percentage_used:.1f}% of your {category} budget",
|
| 79 |
+
'severity': 'medium',
|
| 80 |
+
'amount': spent,
|
| 81 |
+
'budget': budget,
|
| 82 |
+
'percentage': percentage_used
|
| 83 |
+
})
|
| 84 |
+
|
| 85 |
+
return alerts
|
| 86 |
+
|
| 87 |
+
def _check_spending_spikes(self, df: pd.DataFrame, current_data: pd.DataFrame) -> List[Dict[str, Any]]:
|
| 88 |
+
"""Check for unusual spending spikes."""
|
| 89 |
+
alerts = []
|
| 90 |
+
|
| 91 |
+
# Calculate historical monthly average
|
| 92 |
+
monthly_spending = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 93 |
+
|
| 94 |
+
if len(monthly_spending) < 2:
|
| 95 |
+
return alerts
|
| 96 |
+
|
| 97 |
+
historical_avg = monthly_spending[:-1].mean() # Exclude current month
|
| 98 |
+
current_spending = abs(current_data[current_data['amount'] < 0]['amount'].sum())
|
| 99 |
+
|
| 100 |
+
if current_spending > historical_avg * self.alert_thresholds['spending_spike']:
|
| 101 |
+
increase_percentage = ((current_spending - historical_avg) / historical_avg) * 100
|
| 102 |
+
alerts.append({
|
| 103 |
+
'type': 'spending_spike',
|
| 104 |
+
'message': f"📈 Spending spike detected! This month's spending is {increase_percentage:.1f}% above your average",
|
| 105 |
+
'severity': 'high' if increase_percentage > 100 else 'medium',
|
| 106 |
+
'current_amount': current_spending,
|
| 107 |
+
'average_amount': historical_avg,
|
| 108 |
+
'increase_percentage': increase_percentage
|
| 109 |
+
})
|
| 110 |
+
|
| 111 |
+
return alerts
|
| 112 |
+
|
| 113 |
+
def _check_unusual_transactions(self, df: pd.DataFrame, current_data: pd.DataFrame) -> List[Dict[str, Any]]:
|
| 114 |
+
"""Check for unusually large transactions."""
|
| 115 |
+
alerts = []
|
| 116 |
+
|
| 117 |
+
# Calculate transaction size statistics
|
| 118 |
+
transaction_sizes = abs(df[df['amount'] < 0]['amount'])
|
| 119 |
+
mean_transaction = transaction_sizes.mean()
|
| 120 |
+
std_transaction = transaction_sizes.std()
|
| 121 |
+
|
| 122 |
+
if std_transaction == 0:
|
| 123 |
+
return alerts
|
| 124 |
+
|
| 125 |
+
# Check current month's large transactions
|
| 126 |
+
current_transactions = current_data[current_data['amount'] < 0]
|
| 127 |
+
|
| 128 |
+
for _, transaction in current_transactions.iterrows():
|
| 129 |
+
amount = abs(transaction['amount'])
|
| 130 |
+
z_score = (amount - mean_transaction) / std_transaction
|
| 131 |
+
|
| 132 |
+
if z_score > self.alert_thresholds['unusual_transaction']:
|
| 133 |
+
alerts.append({
|
| 134 |
+
'type': 'unusual_transaction',
|
| 135 |
+
'message': f"💳 Unusual transaction: ${amount:.2f} at {transaction['description']} ({z_score:.1f}x your typical spending)",
|
| 136 |
+
'severity': 'medium',
|
| 137 |
+
'amount': amount,
|
| 138 |
+
'description': transaction['description'],
|
| 139 |
+
'date': transaction['date'].strftime('%Y-%m-%d'),
|
| 140 |
+
'z_score': z_score
|
| 141 |
+
})
|
| 142 |
+
|
| 143 |
+
return alerts
|
| 144 |
+
|
| 145 |
+
def _check_category_overspending(self, df: pd.DataFrame, current_data: pd.DataFrame) -> List[Dict[str, Any]]:
|
| 146 |
+
"""Check for category-specific overspending."""
|
| 147 |
+
alerts = []
|
| 148 |
+
|
| 149 |
+
if 'category' not in df.columns:
|
| 150 |
+
return alerts
|
| 151 |
+
|
| 152 |
+
# Calculate historical category averages
|
| 153 |
+
historical_category_avg = df[df['amount'] < 0].groupby(['category', 'month_year'])['amount'].sum().abs().groupby('category').mean()
|
| 154 |
+
|
| 155 |
+
# Current month category spending
|
| 156 |
+
current_category_spending = current_data[current_data['amount'] < 0].groupby('category')['amount'].sum().abs()
|
| 157 |
+
|
| 158 |
+
for category in current_category_spending.index:
|
| 159 |
+
if category in historical_category_avg:
|
| 160 |
+
current_amount = current_category_spending[category]
|
| 161 |
+
historical_avg = historical_category_avg[category]
|
| 162 |
+
|
| 163 |
+
if current_amount > historical_avg * self.alert_thresholds['category_overspend']:
|
| 164 |
+
increase_percentage = ((current_amount - historical_avg) / historical_avg) * 100
|
| 165 |
+
alerts.append({
|
| 166 |
+
'type': 'category_overspend',
|
| 167 |
+
'category': category,
|
| 168 |
+
'message': f"📊 {category} spending is {increase_percentage:.1f}% above average this month",
|
| 169 |
+
'severity': 'medium',
|
| 170 |
+
'current_amount': current_amount,
|
| 171 |
+
'average_amount': historical_avg,
|
| 172 |
+
'increase_percentage': increase_percentage
|
| 173 |
+
})
|
| 174 |
+
|
| 175 |
+
return alerts
|
| 176 |
+
|
| 177 |
+
def _check_trend_alerts(self, df: pd.DataFrame) -> List[Dict[str, Any]]:
|
| 178 |
+
"""Check for concerning spending trends."""
|
| 179 |
+
alerts = []
|
| 180 |
+
|
| 181 |
+
monthly_spending = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 182 |
+
|
| 183 |
+
if len(monthly_spending) < 3:
|
| 184 |
+
return alerts
|
| 185 |
+
|
| 186 |
+
# Calculate trend
|
| 187 |
+
months = list(range(len(monthly_spending)))
|
| 188 |
+
spending_values = monthly_spending.values
|
| 189 |
+
trend_slope = np.polyfit(months, spending_values, 1)[0]
|
| 190 |
+
|
| 191 |
+
# Check for concerning upward trend
|
| 192 |
+
if trend_slope > monthly_spending.mean() * 0.1: # 10% increase per month
|
| 193 |
+
alerts.append({
|
| 194 |
+
'type': 'upward_trend',
|
| 195 |
+
'message': f"📈 Your spending has been increasing by ${trend_slope:.2f} per month over the last {len(monthly_spending)} months",
|
| 196 |
+
'severity': 'medium',
|
| 197 |
+
'trend_slope': trend_slope,
|
| 198 |
+
'trend_direction': 'increasing'
|
| 199 |
+
})
|
| 200 |
+
|
| 201 |
+
return alerts
|
| 202 |
+
|
| 203 |
+
def _check_recurring_expense_alerts(self, df: pd.DataFrame) -> List[Dict[str, Any]]:
|
| 204 |
+
"""Check for missing or changed recurring expenses."""
|
| 205 |
+
alerts = []
|
| 206 |
+
|
| 207 |
+
# Find potential recurring expenses (same description, similar amounts)
|
| 208 |
+
recurring_candidates = df.groupby('description').agg({
|
| 209 |
+
'amount': ['count', 'std'],
|
| 210 |
+
'date': ['min', 'max']
|
| 211 |
+
}).reset_index()
|
| 212 |
+
|
| 213 |
+
recurring_candidates.columns = ['description', 'count', 'std', 'first_date', 'last_date']
|
| 214 |
+
|
| 215 |
+
# Filter for likely recurring expenses
|
| 216 |
+
recurring_expenses = recurring_candidates[
|
| 217 |
+
(recurring_candidates['count'] >= 3) &
|
| 218 |
+
(recurring_candidates['std'] < 10) # Low variation in amount
|
| 219 |
+
]
|
| 220 |
+
|
| 221 |
+
current_month = datetime.now().strftime('%Y-%m')
|
| 222 |
+
|
| 223 |
+
for _, expense in recurring_expenses.iterrows():
|
| 224 |
+
last_occurrence = expense['last_date']
|
| 225 |
+
days_since = (datetime.now() - last_occurrence).days
|
| 226 |
+
|
| 227 |
+
# Alert if recurring expense is overdue
|
| 228 |
+
if days_since > 35: # More than 35 days (allowing for monthly variation)
|
| 229 |
+
alerts.append({
|
| 230 |
+
'type': 'missing_recurring',
|
| 231 |
+
'message': f"🔄 Missing recurring expense: '{expense['description']}' last seen {days_since} days ago",
|
| 232 |
+
'severity': 'low',
|
| 233 |
+
'description': expense['description'],
|
| 234 |
+
'days_since': days_since,
|
| 235 |
+
'last_occurrence': last_occurrence.strftime('%Y-%m-%d')
|
| 236 |
+
})
|
| 237 |
+
|
| 238 |
+
return alerts
|
| 239 |
+
|
| 240 |
+
def _get_alert_priority(self, alert_type: str) -> int:
|
| 241 |
+
"""Get priority score for alert sorting."""
|
| 242 |
+
priority_scores = {
|
| 243 |
+
'budget_exceeded': 10,
|
| 244 |
+
'spending_spike': 9,
|
| 245 |
+
'budget_warning': 8,
|
| 246 |
+
'unusual_transaction': 7,
|
| 247 |
+
'category_overspend': 6,
|
| 248 |
+
'upward_trend': 5,
|
| 249 |
+
'missing_recurring': 3
|
| 250 |
+
}
|
| 251 |
+
return priority_scores.get(alert_type, 1)
|
| 252 |
+
|
| 253 |
+
def create_alerts_summary(self, alerts: List[Dict[str, Any]]) -> Dict[str, Any]:
|
| 254 |
+
"""Create summary of alerts by severity."""
|
| 255 |
+
summary = {
|
| 256 |
+
'total_alerts': len(alerts),
|
| 257 |
+
'high_severity': len([a for a in alerts if a.get('severity') == 'high']),
|
| 258 |
+
'medium_severity': len([a for a in alerts if a.get('severity') == 'medium']),
|
| 259 |
+
'low_severity': len([a for a in alerts if a.get('severity') == 'low']),
|
| 260 |
+
'alert_types': {}
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
# Count by type
|
| 264 |
+
for alert in alerts:
|
| 265 |
+
alert_type = alert['type']
|
| 266 |
+
if alert_type not in summary['alert_types']:
|
| 267 |
+
summary['alert_types'][alert_type] = 0
|
| 268 |
+
summary['alert_types'][alert_type] += 1
|
| 269 |
+
|
| 270 |
+
return summary
|
| 271 |
+
|
| 272 |
+
def display_alerts(self, alerts: List[Dict[str, Any]]):
|
| 273 |
+
"""Display alerts in Streamlit interface."""
|
| 274 |
+
if not alerts:
|
| 275 |
+
st.success("🎉 No alerts! Your spending looks healthy.")
|
| 276 |
+
return
|
| 277 |
+
|
| 278 |
+
st.subheader(f"🚨 Smart Alerts ({len(alerts)})")
|
| 279 |
+
|
| 280 |
+
# Group by severity
|
| 281 |
+
high_alerts = [a for a in alerts if a.get('severity') == 'high']
|
| 282 |
+
medium_alerts = [a for a in alerts if a.get('severity') == 'medium']
|
| 283 |
+
low_alerts = [a for a in alerts if a.get('severity') == 'low']
|
| 284 |
+
|
| 285 |
+
# Display high severity alerts
|
| 286 |
+
if high_alerts:
|
| 287 |
+
st.error("🔴 High Priority Alerts")
|
| 288 |
+
for alert in high_alerts:
|
| 289 |
+
st.error(alert['message'])
|
| 290 |
+
|
| 291 |
+
# Display medium severity alerts
|
| 292 |
+
if medium_alerts:
|
| 293 |
+
st.warning("🟡 Medium Priority Alerts")
|
| 294 |
+
for alert in medium_alerts:
|
| 295 |
+
st.warning(alert['message'])
|
| 296 |
+
|
| 297 |
+
# Display low severity alerts
|
| 298 |
+
if low_alerts:
|
| 299 |
+
st.info("🔵 Low Priority Alerts")
|
| 300 |
+
for alert in low_alerts:
|
| 301 |
+
st.info(alert['message'])
|
utils.py
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
from typing import Any, Optional, List, Dict
|
| 5 |
+
import re
|
| 6 |
+
from datetime import datetime
|
| 7 |
+
import io
|
| 8 |
+
|
| 9 |
+
def format_currency(amount: float) -> str:
|
| 10 |
+
"""Format amount as currency string."""
|
| 11 |
+
if pd.isna(amount):
|
| 12 |
+
return "$0.00"
|
| 13 |
+
return f"${amount:,.2f}"
|
| 14 |
+
|
| 15 |
+
def format_percentage(value: float) -> str:
|
| 16 |
+
"""Format value as percentage string."""
|
| 17 |
+
if pd.isna(value):
|
| 18 |
+
return "0.0%"
|
| 19 |
+
return f"{value:.1f}%"
|
| 20 |
+
|
| 21 |
+
def validate_file(uploaded_file) -> bool:
|
| 22 |
+
"""Validate uploaded file format and basic structure."""
|
| 23 |
+
if uploaded_file is None:
|
| 24 |
+
return False
|
| 25 |
+
|
| 26 |
+
# Check file extension
|
| 27 |
+
valid_extensions = ['.csv', '.xlsx', '.xls']
|
| 28 |
+
if not any(uploaded_file.name.lower().endswith(ext) for ext in valid_extensions):
|
| 29 |
+
st.error("Please upload a CSV or Excel file.")
|
| 30 |
+
return False
|
| 31 |
+
|
| 32 |
+
# Check file size (limit to 50MB)
|
| 33 |
+
if uploaded_file.size > 50 * 1024 * 1024:
|
| 34 |
+
st.error("File size too large. Please upload a file smaller than 50MB.")
|
| 35 |
+
return False
|
| 36 |
+
|
| 37 |
+
try:
|
| 38 |
+
# Try to read the file to check if it's valid
|
| 39 |
+
if uploaded_file.name.endswith('.csv'):
|
| 40 |
+
df = pd.read_csv(uploaded_file, nrows=5) # Read only first 5 rows for validation
|
| 41 |
+
else:
|
| 42 |
+
df = pd.read_excel(uploaded_file, nrows=5)
|
| 43 |
+
|
| 44 |
+
# Reset file pointer
|
| 45 |
+
uploaded_file.seek(0)
|
| 46 |
+
|
| 47 |
+
# Check if file has minimum required columns
|
| 48 |
+
if len(df.columns) < 3:
|
| 49 |
+
st.error("File must have at least 3 columns (date, description, amount).")
|
| 50 |
+
return False
|
| 51 |
+
|
| 52 |
+
return True
|
| 53 |
+
|
| 54 |
+
except Exception as e:
|
| 55 |
+
st.error(f"Error reading file: {str(e)}")
|
| 56 |
+
return False
|
| 57 |
+
|
| 58 |
+
def clean_amount_string(amount_str: str) -> float:
|
| 59 |
+
"""Clean and convert amount string to float."""
|
| 60 |
+
if pd.isna(amount_str):
|
| 61 |
+
return 0.0
|
| 62 |
+
|
| 63 |
+
# Convert to string and remove common currency symbols and formatting
|
| 64 |
+
cleaned = str(amount_str).strip()
|
| 65 |
+
cleaned = re.sub(r'[^\d.-]', '', cleaned)
|
| 66 |
+
|
| 67 |
+
try:
|
| 68 |
+
return float(cleaned)
|
| 69 |
+
except ValueError:
|
| 70 |
+
return 0.0
|
| 71 |
+
|
| 72 |
+
def parse_date_string(date_str: str) -> Optional[datetime]:
|
| 73 |
+
"""Parse various date string formats."""
|
| 74 |
+
if pd.isna(date_str):
|
| 75 |
+
return None
|
| 76 |
+
|
| 77 |
+
# Common date formats to try
|
| 78 |
+
formats = [
|
| 79 |
+
'%Y-%m-%d',
|
| 80 |
+
'%m/%d/%Y',
|
| 81 |
+
'%d/%m/%Y',
|
| 82 |
+
'%Y/%m/%d',
|
| 83 |
+
'%m-%d-%Y',
|
| 84 |
+
'%d-%m-%Y',
|
| 85 |
+
'%B %d, %Y',
|
| 86 |
+
'%b %d, %Y',
|
| 87 |
+
'%d %B %Y',
|
| 88 |
+
'%d %b %Y'
|
| 89 |
+
]
|
| 90 |
+
|
| 91 |
+
for fmt in formats:
|
| 92 |
+
try:
|
| 93 |
+
return datetime.strptime(str(date_str).strip(), fmt)
|
| 94 |
+
except ValueError:
|
| 95 |
+
continue
|
| 96 |
+
|
| 97 |
+
# If none of the formats work, try pandas to_datetime
|
| 98 |
+
try:
|
| 99 |
+
return pd.to_datetime(date_str)
|
| 100 |
+
except:
|
| 101 |
+
return None
|
| 102 |
+
|
| 103 |
+
def detect_column_types(df: pd.DataFrame) -> Dict[str, str]:
|
| 104 |
+
"""Detect likely column types in the dataframe."""
|
| 105 |
+
column_types = {}
|
| 106 |
+
|
| 107 |
+
for col in df.columns:
|
| 108 |
+
col_lower = col.lower().strip()
|
| 109 |
+
sample_values = df[col].dropna().head(10)
|
| 110 |
+
|
| 111 |
+
# Date detection
|
| 112 |
+
if any(keyword in col_lower for keyword in ['date', 'time', 'when']):
|
| 113 |
+
column_types[col] = 'date'
|
| 114 |
+
elif len(sample_values) > 0:
|
| 115 |
+
# Try to parse a few values as dates
|
| 116 |
+
date_count = 0
|
| 117 |
+
for val in sample_values:
|
| 118 |
+
if parse_date_string(str(val)) is not None:
|
| 119 |
+
date_count += 1
|
| 120 |
+
if date_count >= len(sample_values) * 0.7: # 70% are valid dates
|
| 121 |
+
column_types[col] = 'date'
|
| 122 |
+
|
| 123 |
+
# Amount detection
|
| 124 |
+
if any(keyword in col_lower for keyword in ['amount', 'price', 'cost', 'value', 'debit', 'credit']):
|
| 125 |
+
column_types[col] = 'amount'
|
| 126 |
+
elif len(sample_values) > 0:
|
| 127 |
+
# Check if values look like amounts
|
| 128 |
+
numeric_count = 0
|
| 129 |
+
for val in sample_values:
|
| 130 |
+
try:
|
| 131 |
+
clean_amount_string(str(val))
|
| 132 |
+
numeric_count += 1
|
| 133 |
+
except:
|
| 134 |
+
pass
|
| 135 |
+
if numeric_count >= len(sample_values) * 0.8: # 80% are numeric
|
| 136 |
+
column_types[col] = 'amount'
|
| 137 |
+
|
| 138 |
+
# Description detection
|
| 139 |
+
if any(keyword in col_lower for keyword in ['description', 'desc', 'memo', 'detail', 'merchant']):
|
| 140 |
+
column_types[col] = 'description'
|
| 141 |
+
elif col not in column_types:
|
| 142 |
+
# Check if it's mostly text
|
| 143 |
+
if len(sample_values) > 0 and all(isinstance(val, str) or len(str(val)) > 5 for val in sample_values):
|
| 144 |
+
column_types[col] = 'description'
|
| 145 |
+
|
| 146 |
+
return column_types
|
| 147 |
+
|
| 148 |
+
def get_date_range_options() -> List[Dict[str, Any]]:
|
| 149 |
+
"""Get predefined date range options."""
|
| 150 |
+
now = datetime.now()
|
| 151 |
+
|
| 152 |
+
return [
|
| 153 |
+
{
|
| 154 |
+
'label': 'Last 7 days',
|
| 155 |
+
'start': now - pd.Timedelta(days=7),
|
| 156 |
+
'end': now
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
'label': 'Last 30 days',
|
| 160 |
+
'start': now - pd.Timedelta(days=30),
|
| 161 |
+
'end': now
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
'label': 'Last 3 months',
|
| 165 |
+
'start': now - pd.Timedelta(days=90),
|
| 166 |
+
'end': now
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
'label': 'Last 6 months',
|
| 170 |
+
'start': now - pd.Timedelta(days=180),
|
| 171 |
+
'end': now
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
'label': 'Last year',
|
| 175 |
+
'start': now - pd.Timedelta(days=365),
|
| 176 |
+
'end': now
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
'label': 'Year to date',
|
| 180 |
+
'start': datetime(now.year, 1, 1),
|
| 181 |
+
'end': now
|
| 182 |
+
}
|
| 183 |
+
]
|
| 184 |
+
|
| 185 |
+
def calculate_financial_metrics(df: pd.DataFrame) -> Dict[str, Any]:
|
| 186 |
+
"""Calculate various financial metrics from the transaction data."""
|
| 187 |
+
metrics = {}
|
| 188 |
+
|
| 189 |
+
if len(df) == 0:
|
| 190 |
+
return metrics
|
| 191 |
+
|
| 192 |
+
# Basic metrics
|
| 193 |
+
metrics['total_transactions'] = len(df)
|
| 194 |
+
metrics['total_income'] = df[df['amount'] > 0]['amount'].sum()
|
| 195 |
+
metrics['total_expenses'] = abs(df[df['amount'] < 0]['amount'].sum())
|
| 196 |
+
metrics['net_flow'] = metrics['total_income'] - metrics['total_expenses']
|
| 197 |
+
|
| 198 |
+
# Average metrics
|
| 199 |
+
metrics['avg_income_per_transaction'] = df[df['amount'] > 0]['amount'].mean() if len(df[df['amount'] > 0]) > 0 else 0
|
| 200 |
+
metrics['avg_expense_per_transaction'] = abs(df[df['amount'] < 0]['amount'].mean()) if len(df[df['amount'] < 0]) > 0 else 0
|
| 201 |
+
|
| 202 |
+
# Date range
|
| 203 |
+
if 'date' in df.columns:
|
| 204 |
+
metrics['date_range'] = {
|
| 205 |
+
'start': df['date'].min(),
|
| 206 |
+
'end': df['date'].max(),
|
| 207 |
+
'days': (df['date'].max() - df['date'].min()).days
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
# Monthly averages
|
| 211 |
+
if metrics['date_range']['days'] > 30:
|
| 212 |
+
months = metrics['date_range']['days'] / 30.44 # Average days per month
|
| 213 |
+
metrics['avg_monthly_income'] = metrics['total_income'] / months
|
| 214 |
+
metrics['avg_monthly_expenses'] = metrics['total_expenses'] / months
|
| 215 |
+
|
| 216 |
+
# Category metrics (if available)
|
| 217 |
+
if 'category' in df.columns:
|
| 218 |
+
expense_by_category = df[df['amount'] < 0].groupby('category')['amount'].sum().abs()
|
| 219 |
+
metrics['top_expense_category'] = expense_by_category.idxmax() if len(expense_by_category) > 0 else None
|
| 220 |
+
metrics['top_expense_amount'] = expense_by_category.max() if len(expense_by_category) > 0 else 0
|
| 221 |
+
metrics['category_count'] = df['category'].nunique()
|
| 222 |
+
|
| 223 |
+
return metrics
|
| 224 |
+
|
| 225 |
+
def export_to_csv(df: pd.DataFrame, filename: str = None) -> str:
|
| 226 |
+
"""Export dataframe to CSV string."""
|
| 227 |
+
if filename is None:
|
| 228 |
+
filename = f"financial_data_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
|
| 229 |
+
|
| 230 |
+
return df.to_csv(index=False)
|
| 231 |
+
|
| 232 |
+
def create_sample_data_template() -> pd.DataFrame:
|
| 233 |
+
"""Create a sample data template for users to understand the expected format."""
|
| 234 |
+
sample_data = {
|
| 235 |
+
'date': [
|
| 236 |
+
'2024-01-15',
|
| 237 |
+
'2024-01-16',
|
| 238 |
+
'2024-01-17',
|
| 239 |
+
'2024-01-18',
|
| 240 |
+
'2024-01-19'
|
| 241 |
+
],
|
| 242 |
+
'description': [
|
| 243 |
+
'Grocery Store Purchase',
|
| 244 |
+
'Coffee Shop',
|
| 245 |
+
'Gas Station',
|
| 246 |
+
'Salary Deposit',
|
| 247 |
+
'Restaurant Dinner'
|
| 248 |
+
],
|
| 249 |
+
'amount': [
|
| 250 |
+
-85.50,
|
| 251 |
+
-4.75,
|
| 252 |
+
-45.00,
|
| 253 |
+
2500.00,
|
| 254 |
+
-67.25
|
| 255 |
+
]
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
return pd.DataFrame(sample_data)
|
| 259 |
+
|
| 260 |
+
def sanitize_filename(filename: str) -> str:
|
| 261 |
+
"""Sanitize filename for safe file operations."""
|
| 262 |
+
# Remove or replace invalid characters
|
| 263 |
+
sanitized = re.sub(r'[<>:"/\\|?*]', '_', filename)
|
| 264 |
+
|
| 265 |
+
# Limit length
|
| 266 |
+
if len(sanitized) > 100:
|
| 267 |
+
sanitized = sanitized[:100]
|
| 268 |
+
|
| 269 |
+
return sanitized
|
| 270 |
+
|
| 271 |
+
def format_large_number(number: float) -> str:
|
| 272 |
+
"""Format large numbers with appropriate suffixes."""
|
| 273 |
+
if abs(number) >= 1_000_000:
|
| 274 |
+
return f"${number/1_000_000:.1f}M"
|
| 275 |
+
elif abs(number) >= 1_000:
|
| 276 |
+
return f"${number/1_000:.1f}K"
|
| 277 |
+
else:
|
| 278 |
+
return f"${number:.2f}"
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vector_store.py
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import chromadb
|
| 2 |
+
from chromadb.config import Settings
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import numpy as np
|
| 5 |
+
from typing import List, Dict, Any, Optional
|
| 6 |
+
import streamlit as st
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
import uuid
|
| 9 |
+
import os
|
| 10 |
+
|
| 11 |
+
class VectorStore:
|
| 12 |
+
"""Manages vector storage and semantic search for financial transactions."""
|
| 13 |
+
|
| 14 |
+
def __init__(self):
|
| 15 |
+
self.client = None
|
| 16 |
+
self.collection = None
|
| 17 |
+
self._initialize_chroma()
|
| 18 |
+
|
| 19 |
+
def _initialize_chroma(self):
|
| 20 |
+
"""Initialize ChromaDB client and collection."""
|
| 21 |
+
try:
|
| 22 |
+
# Configure ChromaDB to use in-memory storage for simplicity
|
| 23 |
+
self.client = chromadb.Client(Settings(
|
| 24 |
+
is_persistent=False, # Use in-memory storage
|
| 25 |
+
anonymized_telemetry=False
|
| 26 |
+
))
|
| 27 |
+
|
| 28 |
+
# Create or get collection
|
| 29 |
+
collection_name = "financial_transactions"
|
| 30 |
+
try:
|
| 31 |
+
self.collection = self.client.get_collection(collection_name)
|
| 32 |
+
except Exception:
|
| 33 |
+
self.collection = self.client.create_collection(
|
| 34 |
+
name=collection_name,
|
| 35 |
+
metadata={"description": "Financial transaction embeddings"}
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
st.success("✅ Vector database initialized successfully!")
|
| 39 |
+
|
| 40 |
+
except Exception as e:
|
| 41 |
+
st.error(f"❌ Error initializing vector database: {str(e)}")
|
| 42 |
+
self.client = None
|
| 43 |
+
self.collection = None
|
| 44 |
+
|
| 45 |
+
def add_transactions(self, df: pd.DataFrame) -> bool:
|
| 46 |
+
"""Add transactions to the vector store."""
|
| 47 |
+
if self.collection is None:
|
| 48 |
+
st.error("Vector database not initialized")
|
| 49 |
+
return False
|
| 50 |
+
|
| 51 |
+
try:
|
| 52 |
+
# Clear existing data
|
| 53 |
+
self.collection.delete()
|
| 54 |
+
|
| 55 |
+
# Prepare documents and metadata
|
| 56 |
+
documents = []
|
| 57 |
+
metadatas = []
|
| 58 |
+
ids = []
|
| 59 |
+
|
| 60 |
+
for idx, row in df.iterrows():
|
| 61 |
+
# Create a searchable text representation
|
| 62 |
+
doc_text = self._create_document_text(row)
|
| 63 |
+
documents.append(doc_text)
|
| 64 |
+
|
| 65 |
+
# Prepare metadata
|
| 66 |
+
metadata = {
|
| 67 |
+
"date": row['date'].strftime('%Y-%m-%d'),
|
| 68 |
+
"amount": float(row['amount']),
|
| 69 |
+
"category": str(row.get('category', 'Other')),
|
| 70 |
+
"description": str(row['description']),
|
| 71 |
+
"transaction_type": str(row.get('transaction_type', 'unknown')),
|
| 72 |
+
"month": int(row.get('month', 1)),
|
| 73 |
+
"year": int(row.get('year', 2023))
|
| 74 |
+
}
|
| 75 |
+
metadatas.append(metadata)
|
| 76 |
+
|
| 77 |
+
# Generate unique ID
|
| 78 |
+
ids.append(str(uuid.uuid4()))
|
| 79 |
+
|
| 80 |
+
# Add to collection in batches
|
| 81 |
+
batch_size = 100
|
| 82 |
+
for i in range(0, len(documents), batch_size):
|
| 83 |
+
batch_docs = documents[i:i+batch_size]
|
| 84 |
+
batch_metas = metadatas[i:i+batch_size]
|
| 85 |
+
batch_ids = ids[i:i+batch_size]
|
| 86 |
+
|
| 87 |
+
self.collection.add(
|
| 88 |
+
documents=batch_docs,
|
| 89 |
+
metadatas=batch_metas,
|
| 90 |
+
ids=batch_ids
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
st.success(f"✅ Added {len(documents)} transactions to vector database")
|
| 94 |
+
return True
|
| 95 |
+
|
| 96 |
+
except Exception as e:
|
| 97 |
+
st.error(f"❌ Error adding transactions to vector store: {str(e)}")
|
| 98 |
+
return False
|
| 99 |
+
|
| 100 |
+
def _create_document_text(self, row: pd.Series) -> str:
|
| 101 |
+
"""Create a searchable text representation of a transaction."""
|
| 102 |
+
date_str = row['date'].strftime('%Y-%m-%d %B')
|
| 103 |
+
amount_str = f"${abs(row['amount']):.2f}"
|
| 104 |
+
category = row.get('category', 'Other')
|
| 105 |
+
description = str(row['description'])
|
| 106 |
+
|
| 107 |
+
# Create comprehensive text for better semantic search
|
| 108 |
+
doc_text = f"""
|
| 109 |
+
Transaction on {date_str}
|
| 110 |
+
Amount: {amount_str}
|
| 111 |
+
Category: {category}
|
| 112 |
+
Description: {description}
|
| 113 |
+
Type: {'expense' if row['amount'] < 0 else 'income'}
|
| 114 |
+
"""
|
| 115 |
+
|
| 116 |
+
return doc_text.strip()
|
| 117 |
+
|
| 118 |
+
def search_transactions(self, query: str, n_results: int = 10) -> List[Dict[str, Any]]:
|
| 119 |
+
"""Search for transactions using semantic similarity."""
|
| 120 |
+
if self.collection is None:
|
| 121 |
+
return []
|
| 122 |
+
|
| 123 |
+
try:
|
| 124 |
+
results = self.collection.query(
|
| 125 |
+
query_texts=[query],
|
| 126 |
+
n_results=min(n_results, self.collection.count())
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
# Format results
|
| 130 |
+
formatted_results = []
|
| 131 |
+
if results['documents'] and len(results['documents']) > 0:
|
| 132 |
+
for i, doc in enumerate(results['documents'][0]):
|
| 133 |
+
result = {
|
| 134 |
+
'document': doc,
|
| 135 |
+
'metadata': results['metadatas'][0][i],
|
| 136 |
+
'distance': results['distances'][0][i] if 'distances' in results else 0
|
| 137 |
+
}
|
| 138 |
+
formatted_results.append(result)
|
| 139 |
+
|
| 140 |
+
return formatted_results
|
| 141 |
+
|
| 142 |
+
except Exception as e:
|
| 143 |
+
st.error(f"❌ Error searching transactions: {str(e)}")
|
| 144 |
+
return []
|
| 145 |
+
|
| 146 |
+
def search_by_category(self, category: str, n_results: int = 10) -> List[Dict[str, Any]]:
|
| 147 |
+
"""Search transactions by category."""
|
| 148 |
+
if self.collection is None:
|
| 149 |
+
return []
|
| 150 |
+
|
| 151 |
+
try:
|
| 152 |
+
results = self.collection.query(
|
| 153 |
+
query_texts=[f"category {category} expenses"],
|
| 154 |
+
where={"category": category},
|
| 155 |
+
n_results=n_results
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
return self._format_results(results)
|
| 159 |
+
|
| 160 |
+
except Exception as e:
|
| 161 |
+
st.error(f"❌ Error searching by category: {str(e)}")
|
| 162 |
+
return []
|
| 163 |
+
|
| 164 |
+
def search_by_date_range(self, start_date: str, end_date: str, n_results: int = 50) -> List[Dict[str, Any]]:
|
| 165 |
+
"""Search transactions within a date range."""
|
| 166 |
+
if self.collection is None:
|
| 167 |
+
return []
|
| 168 |
+
|
| 169 |
+
try:
|
| 170 |
+
results = self.collection.query(
|
| 171 |
+
query_texts=[f"transactions between {start_date} and {end_date}"],
|
| 172 |
+
where={
|
| 173 |
+
"$and": [
|
| 174 |
+
{"date": {"$gte": start_date}},
|
| 175 |
+
{"date": {"$lte": end_date}}
|
| 176 |
+
]
|
| 177 |
+
},
|
| 178 |
+
n_results=n_results
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
return self._format_results(results)
|
| 182 |
+
|
| 183 |
+
except Exception as e:
|
| 184 |
+
st.error(f"❌ Error searching by date range: {str(e)}")
|
| 185 |
+
return []
|
| 186 |
+
|
| 187 |
+
def search_by_amount_range(self, min_amount: float, max_amount: float, n_results: int = 20) -> List[Dict[str, Any]]:
|
| 188 |
+
"""Search transactions by amount range."""
|
| 189 |
+
if self.collection is None:
|
| 190 |
+
return []
|
| 191 |
+
|
| 192 |
+
try:
|
| 193 |
+
results = self.collection.query(
|
| 194 |
+
query_texts=[f"transactions between ${min_amount} and ${max_amount}"],
|
| 195 |
+
where={
|
| 196 |
+
"$and": [
|
| 197 |
+
{"amount": {"$gte": min_amount}},
|
| 198 |
+
{"amount": {"$lte": max_amount}}
|
| 199 |
+
]
|
| 200 |
+
},
|
| 201 |
+
n_results=n_results
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
return self._format_results(results)
|
| 205 |
+
|
| 206 |
+
except Exception as e:
|
| 207 |
+
st.error(f"❌ Error searching by amount range: {str(e)}")
|
| 208 |
+
return []
|
| 209 |
+
|
| 210 |
+
def _format_results(self, results: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 211 |
+
"""Format search results consistently."""
|
| 212 |
+
formatted_results = []
|
| 213 |
+
if results['documents'] and len(results['documents']) > 0:
|
| 214 |
+
for i, doc in enumerate(results['documents'][0]):
|
| 215 |
+
result = {
|
| 216 |
+
'document': doc,
|
| 217 |
+
'metadata': results['metadatas'][0][i],
|
| 218 |
+
'distance': results['distances'][0][i] if 'distances' in results else 0
|
| 219 |
+
}
|
| 220 |
+
formatted_results.append(result)
|
| 221 |
+
|
| 222 |
+
return formatted_results
|
| 223 |
+
|
| 224 |
+
def get_statistics(self) -> Dict[str, Any]:
|
| 225 |
+
"""Get statistics about the vector store."""
|
| 226 |
+
if self.collection is None:
|
| 227 |
+
return {}
|
| 228 |
+
|
| 229 |
+
try:
|
| 230 |
+
count = self.collection.count()
|
| 231 |
+
return {
|
| 232 |
+
'total_transactions': count,
|
| 233 |
+
'collection_name': self.collection.name,
|
| 234 |
+
'is_active': True
|
| 235 |
+
}
|
| 236 |
+
except Exception as e:
|
| 237 |
+
return {
|
| 238 |
+
'total_transactions': 0,
|
| 239 |
+
'collection_name': 'N/A',
|
| 240 |
+
'is_active': False,
|
| 241 |
+
'error': str(e)
|
| 242 |
+
}
|
visualizations.py
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import plotly.express as px
|
| 2 |
+
import plotly.graph_objects as go
|
| 3 |
+
from plotly.subplots import make_subplots
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import numpy as np
|
| 6 |
+
from datetime import datetime, timedelta
|
| 7 |
+
from typing import Dict, List, Any
|
| 8 |
+
import streamlit as st
|
| 9 |
+
|
| 10 |
+
class FinanceVisualizer:
|
| 11 |
+
"""Creates interactive visualizations for financial data."""
|
| 12 |
+
|
| 13 |
+
def __init__(self):
|
| 14 |
+
self.color_palette = [
|
| 15 |
+
'#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FECA57',
|
| 16 |
+
'#FF9FF3', '#54A0FF', '#5F27CD', '#00D2D3', '#FF9F43'
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
def create_monthly_trend(self, df: pd.DataFrame) -> go.Figure:
|
| 20 |
+
"""Create a monthly spending trend chart."""
|
| 21 |
+
# Group by month and calculate spending
|
| 22 |
+
monthly_data = df.groupby('month_year').agg({
|
| 23 |
+
'amount': lambda x: x[x < 0].sum() * -1 # Convert negative to positive for expenses
|
| 24 |
+
}).reset_index()
|
| 25 |
+
|
| 26 |
+
monthly_data['month_year_str'] = monthly_data['month_year'].astype(str)
|
| 27 |
+
|
| 28 |
+
fig = go.Figure()
|
| 29 |
+
|
| 30 |
+
fig.add_trace(go.Scatter(
|
| 31 |
+
x=monthly_data['month_year_str'],
|
| 32 |
+
y=monthly_data['amount'],
|
| 33 |
+
mode='lines+markers',
|
| 34 |
+
name='Monthly Spending',
|
| 35 |
+
line=dict(color='#FF6B6B', width=3),
|
| 36 |
+
marker=dict(size=8)
|
| 37 |
+
))
|
| 38 |
+
|
| 39 |
+
fig.update_layout(
|
| 40 |
+
title='Monthly Spending Trend',
|
| 41 |
+
xaxis_title='Month',
|
| 42 |
+
yaxis_title='Amount ($)',
|
| 43 |
+
template='plotly_white',
|
| 44 |
+
height=400
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
return fig
|
| 48 |
+
|
| 49 |
+
def create_category_pie_chart(self, df: pd.DataFrame) -> go.Figure:
|
| 50 |
+
"""Create a pie chart for spending by category."""
|
| 51 |
+
if 'category' not in df.columns:
|
| 52 |
+
return go.Figure()
|
| 53 |
+
|
| 54 |
+
# Calculate spending by category (only expenses)
|
| 55 |
+
category_spending = df[df['amount'] < 0].groupby('category')['amount'].sum().abs()
|
| 56 |
+
|
| 57 |
+
fig = go.Figure(data=[go.Pie(
|
| 58 |
+
labels=category_spending.index,
|
| 59 |
+
values=category_spending.values,
|
| 60 |
+
hole=0.3,
|
| 61 |
+
marker_colors=self.color_palette[:len(category_spending)]
|
| 62 |
+
)])
|
| 63 |
+
|
| 64 |
+
fig.update_layout(
|
| 65 |
+
title='Spending Distribution by Category',
|
| 66 |
+
template='plotly_white',
|
| 67 |
+
height=400
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
return fig
|
| 71 |
+
|
| 72 |
+
def create_spending_vs_income_chart(self, df: pd.DataFrame) -> go.Figure:
|
| 73 |
+
"""Create a chart comparing monthly spending vs income."""
|
| 74 |
+
monthly_data = df.groupby('month_year').agg({
|
| 75 |
+
'amount': [
|
| 76 |
+
lambda x: x[x < 0].sum() * -1, # Expenses (positive)
|
| 77 |
+
lambda x: x[x > 0].sum() # Income
|
| 78 |
+
]
|
| 79 |
+
})
|
| 80 |
+
|
| 81 |
+
monthly_data.columns = ['Expenses', 'Income']
|
| 82 |
+
monthly_data = monthly_data.reset_index()
|
| 83 |
+
monthly_data['month_year_str'] = monthly_data['month_year'].astype(str)
|
| 84 |
+
|
| 85 |
+
fig = go.Figure()
|
| 86 |
+
|
| 87 |
+
fig.add_trace(go.Bar(
|
| 88 |
+
x=monthly_data['month_year_str'],
|
| 89 |
+
y=monthly_data['Income'],
|
| 90 |
+
name='Income',
|
| 91 |
+
marker_color='#4ECDC4'
|
| 92 |
+
))
|
| 93 |
+
|
| 94 |
+
fig.add_trace(go.Bar(
|
| 95 |
+
x=monthly_data['month_year_str'],
|
| 96 |
+
y=monthly_data['Expenses'],
|
| 97 |
+
name='Expenses',
|
| 98 |
+
marker_color='#FF6B6B'
|
| 99 |
+
))
|
| 100 |
+
|
| 101 |
+
fig.update_layout(
|
| 102 |
+
title='Monthly Income vs Expenses',
|
| 103 |
+
xaxis_title='Month',
|
| 104 |
+
yaxis_title='Amount ($)',
|
| 105 |
+
barmode='group',
|
| 106 |
+
template='plotly_white',
|
| 107 |
+
height=400
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
return fig
|
| 111 |
+
|
| 112 |
+
def create_daily_spending_heatmap(self, df: pd.DataFrame) -> go.Figure:
|
| 113 |
+
"""Create a heatmap showing spending patterns by day of week and hour."""
|
| 114 |
+
# Add day of week and hour columns
|
| 115 |
+
df_copy = df.copy()
|
| 116 |
+
df_copy['day_of_week'] = df_copy['date'].dt.day_name()
|
| 117 |
+
df_copy['day_num'] = df_copy['date'].dt.dayofweek
|
| 118 |
+
|
| 119 |
+
# Calculate daily spending
|
| 120 |
+
daily_spending = df_copy[df_copy['amount'] < 0].groupby(['day_num', 'day_of_week'])['amount'].sum().abs().reset_index()
|
| 121 |
+
|
| 122 |
+
# Create pivot table for heatmap
|
| 123 |
+
days_order = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
| 124 |
+
|
| 125 |
+
fig = go.Figure(data=go.Bar(
|
| 126 |
+
x=daily_spending['day_of_week'],
|
| 127 |
+
y=daily_spending['amount'],
|
| 128 |
+
marker_color=self.color_palette[0]
|
| 129 |
+
))
|
| 130 |
+
|
| 131 |
+
fig.update_layout(
|
| 132 |
+
title='Spending by Day of Week',
|
| 133 |
+
xaxis_title='Day',
|
| 134 |
+
yaxis_title='Total Spending ($)',
|
| 135 |
+
template='plotly_white',
|
| 136 |
+
height=400
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
return fig
|
| 140 |
+
|
| 141 |
+
def create_transaction_timeline(self, df: pd.DataFrame, category: str = None) -> go.Figure:
|
| 142 |
+
"""Create a timeline of transactions."""
|
| 143 |
+
df_filtered = df.copy()
|
| 144 |
+
|
| 145 |
+
if category:
|
| 146 |
+
df_filtered = df_filtered[df_filtered['category'] == category]
|
| 147 |
+
|
| 148 |
+
# Sort by date
|
| 149 |
+
df_filtered = df_filtered.sort_values('date')
|
| 150 |
+
|
| 151 |
+
# Create different colors for income vs expenses
|
| 152 |
+
colors = ['green' if x > 0 else 'red' for x in df_filtered['amount']]
|
| 153 |
+
|
| 154 |
+
fig = go.Figure()
|
| 155 |
+
|
| 156 |
+
fig.add_trace(go.Scatter(
|
| 157 |
+
x=df_filtered['date'],
|
| 158 |
+
y=df_filtered['amount'],
|
| 159 |
+
mode='markers',
|
| 160 |
+
marker=dict(
|
| 161 |
+
color=colors,
|
| 162 |
+
size=abs(df_filtered['amount']) / df_filtered['amount'].abs().max() * 20 + 5,
|
| 163 |
+
opacity=0.7
|
| 164 |
+
),
|
| 165 |
+
text=df_filtered['description'],
|
| 166 |
+
hovertemplate='<b>%{text}</b><br>Date: %{x}<br>Amount: $%{y:.2f}<extra></extra>',
|
| 167 |
+
name='Transactions'
|
| 168 |
+
))
|
| 169 |
+
|
| 170 |
+
fig.update_layout(
|
| 171 |
+
title=f'Transaction Timeline{" - " + category if category else ""}',
|
| 172 |
+
xaxis_title='Date',
|
| 173 |
+
yaxis_title='Amount ($)',
|
| 174 |
+
template='plotly_white',
|
| 175 |
+
height=500
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
return fig
|
| 179 |
+
|
| 180 |
+
def create_spending_breakdown_sunburst(self, df: pd.DataFrame) -> go.Figure:
|
| 181 |
+
"""Create a sunburst chart for hierarchical spending breakdown."""
|
| 182 |
+
if 'category' not in df.columns:
|
| 183 |
+
return go.Figure()
|
| 184 |
+
|
| 185 |
+
# Prepare data for sunburst
|
| 186 |
+
spending_data = df[df['amount'] < 0].copy()
|
| 187 |
+
spending_data['amount'] = spending_data['amount'].abs()
|
| 188 |
+
|
| 189 |
+
# Create hierarchical structure
|
| 190 |
+
sunburst_data = []
|
| 191 |
+
|
| 192 |
+
# Add root
|
| 193 |
+
total_spending = spending_data['amount'].sum()
|
| 194 |
+
|
| 195 |
+
# Add categories
|
| 196 |
+
for category in spending_data['category'].unique():
|
| 197 |
+
category_amount = spending_data[spending_data['category'] == category]['amount'].sum()
|
| 198 |
+
sunburst_data.append({
|
| 199 |
+
'ids': category,
|
| 200 |
+
'labels': category,
|
| 201 |
+
'parents': '',
|
| 202 |
+
'values': category_amount
|
| 203 |
+
})
|
| 204 |
+
|
| 205 |
+
# Convert to DataFrame for plotly
|
| 206 |
+
sunburst_df = pd.DataFrame(sunburst_data)
|
| 207 |
+
|
| 208 |
+
fig = go.Figure(go.Sunburst(
|
| 209 |
+
ids=sunburst_df['ids'],
|
| 210 |
+
labels=sunburst_df['labels'],
|
| 211 |
+
parents=sunburst_df['parents'],
|
| 212 |
+
values=sunburst_df['values'],
|
| 213 |
+
branchvalues="total",
|
| 214 |
+
marker=dict(colors=self.color_palette)
|
| 215 |
+
))
|
| 216 |
+
|
| 217 |
+
fig.update_layout(
|
| 218 |
+
title='Spending Breakdown',
|
| 219 |
+
template='plotly_white',
|
| 220 |
+
height=500
|
| 221 |
+
)
|
| 222 |
+
|
| 223 |
+
return fig
|
| 224 |
+
|
| 225 |
+
def create_budget_vs_actual_chart(self, df: pd.DataFrame, budget_dict: Dict[str, float] = None) -> go.Figure:
|
| 226 |
+
"""Create a chart comparing budgeted vs actual spending by category."""
|
| 227 |
+
if 'category' not in df.columns or not budget_dict:
|
| 228 |
+
return go.Figure()
|
| 229 |
+
|
| 230 |
+
# Calculate actual spending by category
|
| 231 |
+
actual_spending = df[df['amount'] < 0].groupby('category')['amount'].sum().abs()
|
| 232 |
+
|
| 233 |
+
# Prepare data for comparison
|
| 234 |
+
categories = list(set(actual_spending.index) | set(budget_dict.keys()))
|
| 235 |
+
actual_values = [actual_spending.get(cat, 0) for cat in categories]
|
| 236 |
+
budget_values = [budget_dict.get(cat, 0) for cat in categories]
|
| 237 |
+
|
| 238 |
+
fig = go.Figure()
|
| 239 |
+
|
| 240 |
+
fig.add_trace(go.Bar(
|
| 241 |
+
x=categories,
|
| 242 |
+
y=budget_values,
|
| 243 |
+
name='Budget',
|
| 244 |
+
marker_color='#4ECDC4',
|
| 245 |
+
opacity=0.7
|
| 246 |
+
))
|
| 247 |
+
|
| 248 |
+
fig.add_trace(go.Bar(
|
| 249 |
+
x=categories,
|
| 250 |
+
y=actual_values,
|
| 251 |
+
name='Actual',
|
| 252 |
+
marker_color='#FF6B6B'
|
| 253 |
+
))
|
| 254 |
+
|
| 255 |
+
fig.update_layout(
|
| 256 |
+
title='Budget vs Actual Spending',
|
| 257 |
+
xaxis_title='Category',
|
| 258 |
+
yaxis_title='Amount ($)',
|
| 259 |
+
barmode='group',
|
| 260 |
+
template='plotly_white',
|
| 261 |
+
height=400
|
| 262 |
+
)
|
| 263 |
+
|
| 264 |
+
return fig
|
| 265 |
+
|
| 266 |
+
def generate_insights(self, df: pd.DataFrame) -> Dict[str, List[str]]:
|
| 267 |
+
"""Generate textual insights from the financial data."""
|
| 268 |
+
insights = {
|
| 269 |
+
'spending': [],
|
| 270 |
+
'trends': [],
|
| 271 |
+
'recommendations': []
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
if len(df) == 0:
|
| 275 |
+
return insights
|
| 276 |
+
|
| 277 |
+
# Spending insights
|
| 278 |
+
if 'category' in df.columns:
|
| 279 |
+
top_category = df[df['amount'] < 0].groupby('category')['amount'].sum().abs().idxmax()
|
| 280 |
+
top_amount = df[df['amount'] < 0].groupby('category')['amount'].sum().abs().max()
|
| 281 |
+
insights['spending'].append(f"Your highest spending category is {top_category} with ${top_amount:.2f}")
|
| 282 |
+
|
| 283 |
+
# Average transaction size
|
| 284 |
+
avg_expense = df[df['amount'] < 0]['amount'].abs().mean()
|
| 285 |
+
insights['spending'].append(f"Your average expense transaction is ${avg_expense:.2f}")
|
| 286 |
+
|
| 287 |
+
# Trend insights
|
| 288 |
+
if 'month_year' in df.columns:
|
| 289 |
+
monthly_spending = df[df['amount'] < 0].groupby('month_year')['amount'].sum().abs()
|
| 290 |
+
if len(monthly_spending) >= 2:
|
| 291 |
+
trend_change = monthly_spending.iloc[-1] - monthly_spending.iloc[-2]
|
| 292 |
+
if trend_change > 0:
|
| 293 |
+
insights['trends'].append(f"Your spending increased by ${trend_change:.2f} last month")
|
| 294 |
+
else:
|
| 295 |
+
insights['trends'].append(f"Your spending decreased by ${abs(trend_change):.2f} last month")
|
| 296 |
+
|
| 297 |
+
# Day of week patterns
|
| 298 |
+
if 'day_of_week' in df.columns:
|
| 299 |
+
daily_spending = df[df['amount'] < 0].groupby('day_of_week')['amount'].sum().abs()
|
| 300 |
+
highest_day = daily_spending.idxmax()
|
| 301 |
+
insights['trends'].append(f"You tend to spend the most on {highest_day}s")
|
| 302 |
+
|
| 303 |
+
return insights
|