Spaces:
Runtime error
Runtime error
""" | |
Demo script showing how to use the enhanced upload.py with SmoLagent AI | |
================================================================ | |
This script demonstrates the new AI-powered data analysis capabilities | |
""" | |
from upload import EnhancedDataExplorer, load_and_explore_data | |
def demo_enhanced_features(): | |
"""Demonstrate the enhanced features""" | |
print("π ENHANCED DATA EXPLORER DEMO") | |
print("=" * 50) | |
# Initialize the enhanced explorer | |
explorer = EnhancedDataExplorer() | |
print("\n1. Loading data...") | |
explorer.load_data() | |
print("\n2. Analyzing data quality...") | |
quality_report = explorer.analyze_data_quality() | |
print("\n3. Creating visualizations...") | |
explorer.create_visualizations() | |
print("\n4. AI Analysis examples (requires model configuration):") | |
example_queries = [ | |
"What are the main patterns in this dataset?", | |
"Identify any data quality issues", | |
"Suggest preprocessing steps", | |
"Find correlations between variables", | |
"Detect outliers and anomalies" | |
] | |
for i, query in enumerate(example_queries, 1): | |
print(f" {i}. {query}") | |
print("\nπ‘ To enable AI analysis:") | |
print(" 1. Get an API key (OpenAI, Hugging Face, etc.)") | |
print(" 2. Uncomment the appropriate lines in setup_agent() method") | |
print(" 3. Run the interactive menu with option 2") | |
def demo_original_function(): | |
"""Demonstrate the original function (preserved)""" | |
print("π ORIGINAL FUNCTION DEMO") | |
print("=" * 30) | |
df = load_and_explore_data() | |
print(f"\nβ Original function completed. Data shape: {df.shape if df is not None else 'Failed to load'}") | |
if __name__ == "__main__": | |
print("Choose demo mode:") | |
print("1. Enhanced features demo") | |
print("2. Original function demo") | |
print("3. Both") | |
choice = input("Enter choice (1-3): ").strip() | |
if choice == "1": | |
demo_enhanced_features() | |
elif choice == "2": | |
demo_original_function() | |
elif choice == "3": | |
demo_original_function() | |
print("\n" + "="*60 + "\n") | |
demo_enhanced_features() | |
else: | |
print("Invalid choice. Running enhanced demo...") | |
demo_enhanced_features() | |