src.llm_interpreter.analysis.insights¶
Insights combiner for AMMM analysis.
This module combines quantitative summaries and rule-based diagnostics into structured insights ready for LLM processing or direct reporting.
Author: AMMM Team Created: 2025-04-10 Last Modified: 2025-04-10
Module Contents¶
- class src.llm_interpreter.analysis.insights.StructuredInsights¶
Structured insights combining summaries and diagnostics.
This is the primary output of the analysis engine, providing evidence-backed insights ready for LLM narrative generation.
- classmethod from_csv_data(csv_data: dict[str, list]) StructuredInsights¶
Create structured insights from loaded CSV data.
- Parameters:
csv_data – Dictionary mapping CSV names to lists of dataclass instances
- Returns:
StructuredInsights with all analysis results
- get_executive_summary_data() dict[str, Any]¶
Extract key data points for executive summary.
- Returns:
Dictionary with executive summary data points
- get_data_quality_insights() dict[str, Any]¶
Extract data quality insights.
- Returns:
Dictionary with data quality metrics and issues
- get_model_fit_insights() dict[str, Any]¶
Extract model fit insights.
- Returns:
Dictionary with model fit metrics and issues
- get_media_insights() dict[str, Any]¶
Extract media performance insights.
- Returns:
Dictionary with media performance data
- get_budget_optimization_insights() dict[str, Any]¶
Extract budget optimization insights.
- Returns:
Dictionary with budget scenario analysis
- to_dict() dict[str, Any]¶
Convert insights to dictionary for JSON serialization or LLM processing.
- Returns:
Complete insights as dictionary
- src.llm_interpreter.analysis.insights.analyze_csv_data(csv_data: dict[str, list]) StructuredInsights¶
Main entry point for analyzing CSV data.
This is the primary function to call from external code.
- Parameters:
csv_data – Dictionary mapping CSV names to lists of dataclass instances
- Returns:
StructuredInsights with complete analysis
Example
>>> from src.llm_interpreter.inputs import load_all_csvs >>> from src.llm_interpreter.analysis import analyze_csv_data >>> >>> csv_data = load_all_csvs("results/csv") >>> insights = analyze_csv_data(csv_data) >>> >>> print(f"Found {len(insights.critical_findings)} critical issues") >>> print(f"Top channel: {insights.summary.media_performance.top_performer}")