Overview
TheReportGenerator creates comprehensive, publication-ready Markdown reports at the end of an autopilot run. It uses a single Gemini API call for narrative sections and locally builds structured sections like tables and metadata.
Key Features
- Single Gemini call for all narrative sections (efficient API usage)
- Complete fallback report if Gemini fails (template-only)
- Locally-built structured sections (tables, statistics)
- Saves report with timestamped filename
- Includes visualizations, appendices, and full experiment history
- Professional, technical tone suitable for data science audiences
Class Definition
Constructor
Shared
GeminiClient instance for API calls.Methods
generate
Generate the final experiment report.Parameters
Complete experiment state after all iterations, containing:
experiments(list[ExperimentResult]): All experiment resultsdata_profile(Optional[DataProfile]): Dataset profileconfig(Config): Configuration including task type, constraints, primary metricbest_metric(Optional[float]): Best metric value achievedbest_experiment(Optional[str]): Name of best experimentcurrent_iteration(int): Total iterations runtermination_reason(Optional[str]): Why the session endedsession_id(str): Unique session identifier
Base output directory. Reports are saved to
output_dir/reports/ with timestamped filenames.Optional list of paths to generated visualization PNG files. These are referenced in the report’s Visualizations section.
Returns
Path to the generated Markdown report file, formatted as:
output_dir/reports/report_{dataset_name}_{timestamp}.mdExample: output_dir/reports/report_housing_20260302_143022.mdReport Structure
The generated report includes the following sections:1. Executive Summary
One concise paragraph (3-5 sentences) covering:- The problem and approach
- Total experiments conducted
- Key finding and best result
- Improvement over baseline
2. Dataset Overview
Markdown table with dataset statistics:- Rows and columns
- Numeric and categorical features
- Target column and type
- Missing values summary
- Target statistics (if available)
3. Methodology
2-3 paragraphs describing:- Iterative hypothesis-driven approach
- Models explored
- Preprocessing strategies tried
- Termination reason
4. Experiment Results
Performance Summary
Markdown table of all experiments:- Iteration number
- Experiment name
- Model type
- Primary metric value
- Status (OK/FAILED)
- Hypothesis (truncated)
Best Model
Detailed information about the best-performing model:- Model type and experiment name
- Iteration number
- Primary metric value
- All metrics table
- Hyperparameters table
- Hypothesis
5. Key Insights
3-5 bullet points with substantive observations:- Connection between experimental choices and outcomes
- Patterns discovered across iterations
- Specific metric references
6. Visualizations (if provided)
Embedded images with references to plot files:- Metric progression over iterations
- Model comparison charts
- Other generated visualizations
7. Recommendations
3-5 actionable bullet points for future work:- Based on experiment findings
- Quick wins and longer-term suggestions
- Model refinement opportunities
8. Appendix
Detailed per-experiment logs:- Experiment name, model, hypothesis
- Success status and metrics
- Error messages (if failed)
- Execution time
- Reasoning (truncated)
9. Run Metadata
Session information footer:- Generator attribution
- Session ID
- Date and time
- Total runtime
Gemini-Generated vs Local Sections
Gemini-Generated Narrative
- Executive Summary
- Methodology
- Key Insights
- Recommendations
Locally-Built Structured
- Dataset Overview
- Performance Summary table
- Best Model details
- Visualizations
- Appendix
- Run Metadata
System Prompt
The generator uses a comprehensive system prompt that guides Gemini to:- Write in professional, technical tone for data science audiences
- Be specific with metric values, model names, and iteration numbers
- Explain WHY approaches worked or failed, not just WHAT happened
- Connect insights across experiments for a coherent narrative
- Provide actionable recommendations based on evidence
Usage Examples
Basic Report Generation
With Visualizations
Complete Autopilot Integration
Custom Output Directory
Reading Generated Report
Error Handling and Fallback
Accessing Report Sections Programmatically
Multi-Session Reporting
Metric Direction Handling
The generator correctly interprets metric improvements:Lower is Better
- RMSE, MSE, MAE, log_loss, error
Higher is Better
- accuracy, f1, r2, precision, recall, AUC
Fallback Report
When Gemini is unavailable, the generator creates a complete template-based report with:- Basic executive summary with session statistics
- Methodology description of the autopilot approach
- Generic but accurate insights based on results
- Standard recommendations for model refinement
- All structured sections (tables, stats) fully populated
File Naming Convention
Reports are saved with the following naming pattern:dataset_name: Extracted fromconfig.data_pathfilename stemtimestamp: FormatYYYYMMDD_HHMMSS
report_housing_20260302_143022.mdreport_iris_20260302_150033.mdreport_california_housing_20260302_163045.md
See Also
- GeminiClient - Underlying API client
- ResultsAnalyzer - Provides analysis data for reports
- HypothesisGenerator - Provides hypothesis history
- ExperimentDesigner - Provides experiment specifications