Spaces:
Runtime error
Runtime error
File size: 3,973 Bytes
c69ba8c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
"""
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()
|