#!/usr/bin/env python3 """ Test script for correlation analysis with plotting """ import subprocess import os import sys def main(): # Get script directory script_dir = os.path.dirname(os.path.abspath(__file__)) # Define paths kpi_file = os.path.join(script_dir, '../../data/lenovo_kpi_filled.csv') scores_file = os.path.join(script_dir, '../../data/lenovo-scores-0603.csv') # Check if files exist if not os.path.exists(kpi_file): print(f"Error: KPI file not found: {kpi_file}") print("Trying alternative path...") kpi_file = os.path.join(script_dir, 'test_kpi.csv') if not os.path.exists(kpi_file): print(f"Error: Alternative KPI file not found: {kpi_file}") sys.exit(1) if not os.path.exists(scores_file): print(f"Error: Scores file not found: {scores_file}") print("Please ensure the scores file exists") sys.exit(1) # Run the analysis with plotting enabled cmd = [ 'python3', os.path.join(script_dir, 'analyze_correlations_v2.py'), '-k', kpi_file, '-s', scores_file, '-o', 'score_corr_with_plots.yaml', '-p' # Enable plotting ] print("Running correlation analysis with plotting...") print(f"Command: {' '.join(cmd)}") try: result = subprocess.run(cmd, capture_output=True, text=True) print("\nOutput:") print(result.stdout) if result.stderr: print("\nErrors:") print(result.stderr) if result.returncode == 0: print("\nSuccess! Check the following files:") print("- score_corr_with_plots.yaml (correlation results)") print("- correlation_plots.png (all plots in one image)") print("- correlation_AC.png (individual plot)") print("- correlation_AD.png (individual plot)") print("- correlation_BC.png (individual plot)") print("- correlation_BD.png (individual plot)") else: print(f"\nError: Process exited with code {result.returncode}") except Exception as e: print(f"\nError running analysis: {e}") if __name__ == "__main__": main()