Singtel_Use_Case1 / auto_demo.py
cosmoruler
problems fixed
c69ba8c
"""
Auto Demo - Run Enhanced Data Explorer
=====================================
This script automatically demonstrates the enhanced data explorer
"""
from upload import EnhancedDataExplorer, load_and_explore_data
import os
def auto_demo():
"""Automatically run the enhanced data explorer demo"""
print("πŸš€ STARTING AUTO DEMO - ENHANCED DATA EXPLORER")
print("=" * 50)
# First check if CSV file exists
csv_path = "C:/Users/Cosmo/Desktop/NTU Peak Singtel/outsystems_sample_logs_6months.csv"
if not os.path.exists(csv_path):
print(f"❌ CSV file not found at: {csv_path}")
print("πŸ“ Using demo data instead...")
# Create some demo data
import pandas as pd
import numpy as np
demo_data = pd.DataFrame({
'timestamp': pd.date_range('2024-01-01', periods=1000, freq='H'),
'response_time': np.random.exponential(0.5, 1000),
'status_code': np.random.choice([200, 404, 500], 1000, p=[0.8, 0.15, 0.05]),
'user_count': np.random.poisson(10, 1000),
'error_rate': np.random.beta(2, 20, 1000),
'server_id': np.random.choice(['server1', 'server2', 'server3'], 1000)
})
demo_csv_path = "demo_data.csv"
demo_data.to_csv(demo_csv_path, index=False)
print(f"βœ… Demo data created: {demo_csv_path}")
# Update the path for the explorer
csv_path = demo_csv_path
# Initialize the enhanced explorer
print("\nπŸ€– Initializing Enhanced Data Explorer...")
explorer = EnhancedDataExplorer(csv_path)
# Check AI status
if explorer.agent:
print("βœ… AI Agent: Configured and ready!")
ai_status = "Available"
else:
print("⚠️ AI Agent: Not configured (non-AI features still available)")
ai_status = "Not Available"
print(f"\nπŸ“Š DATA ANALYSIS DEMO")
print("=" * 30)
# Step 1: Load data
print("\n1️⃣ Loading and exploring data...")
df = explorer.load_data()
if df is not None:
print(f"βœ… Data loaded successfully!")
# Step 2: Data quality analysis
print("\n2️⃣ Analyzing data quality...")
quality_report = explorer.analyze_data_quality()
# Step 3: Create visualizations
print("\n3️⃣ Creating visualizations...")
try:
explorer.create_visualizations()
except Exception as e:
print(f"⚠️ Visualization skipped: {e}")
# Step 4: AI Analysis (if available)
if explorer.agent:
print("\n4️⃣ Running AI analysis...")
queries = [
"Describe the main characteristics of this dataset",
"What patterns do you see in the data?",
"Are there any data quality issues I should be aware of?"
]
for i, query in enumerate(queries, 1):
print(f"\nπŸ€– AI Query {i}: {query}")
try:
response = explorer.ai_analysis(query)
if response:
print("βœ… AI analysis completed")
else:
print("⚠️ AI analysis returned no response")
except Exception as e:
print(f"❌ AI analysis failed: {e}")
break
else:
print("\n4️⃣ AI Analysis: Skipped (no AI model configured)")
print(f"\nπŸŽ‰ DEMO COMPLETE!")
print("=" * 20)
print(f"πŸ“Š Data Status: {'Loaded' if df is not None else 'Failed'}")
print(f"πŸ€– AI Status: {ai_status}")
print(f"πŸ“ˆ Visualizations: {'Created' if df is not None else 'Skipped'}")
print(f"\nπŸ’‘ To run interactively:")
print(f" python upload.py")
print(f" Choose option 2 for enhanced mode")
if __name__ == "__main__":
auto_demo()