π sections.correlationΒΆ
Builds the correlation analysis section for the report.
This function retrieves configuration for correlation analysis from the report builder, initializes the appropriate analyzer and plotter classes with their parameters, computes the correlation matrix and lagged correlations, generates the corresponding plots, and returns a dictionary containing both the computed data and chart metadata (including base64-encoded images).
FunctionsΒΆ
- owlmix.reporting.sections.correlation.build_correlation_section(report_builder)ΒΆ
- Parameters:
report_builder (
ReportBuilderProtocol) β The report builder instance containing the dataframe and configuration.- Returns:
A dictionary with keys:
data: The computed correlation results.chart: Metadata and images for the generated plots, including:title: Title of the chart.description: Description of the chart.alt_text: Alternative text for the images.images: Dictionary with base64-encoded images for:correlation_matrix: Correlation matrix plot.lagged_correlation_matrix: Lagged correlation matrix plot.
- Return type:
dict
Workflow:
Retrieves the correlation configuration from the report builder.
Fetches the analyzer and plotter classes and their parameter classes from the registries.
Initializes analyzer and plotter parameter objects using the configuration.
Instantiates the analyzer with the DataFrame and parameters, then computes the correlation data.
Instantiates the plotter with the computed data and plot parameters, then generates the plots.
Converts the plot images to base64 strings for embedding in the report.
Returns a dictionary containing both the computed data and chart metadata.
Example Usage:
section = build_correlation_section(report_builder)
data = section["data"]
chart = section["chart"]
DependenciesΒΆ
os: For file path operations.register_section,ANALYZERS_REGISTRY,PLOTTERS_REGISTRY: For section registration and dynamic class retrieval.ReportBuilderProtocol: Protocol for the report builder object.
RegistriesΒΆ
ANALYZERS_REGISTRY["correlation"]: Provides the analyzer class and its parameter class for correlation.PLOTTERS_REGISTRY["correlation"]: Provides the plotter class and its parameter class for correlation.
Section RegistrationΒΆ
The function is registered as a report section under the name "correlation" using the @register_section decorator.
@register_section("correlation")
def build_correlation_section(report_builder: ReportBuilderProtocol) -> Dict[str, Any]:
...