πŸ“ sections.vifΒΆ

Builds the VIF section for the report.

This function retrieves configuration for VIF analysis from the report builder, initializes the appropriate analyzer and plotter classes with their parameters, computes the VIF data, generates the corresponding plot, and returns a dictionary containing both the computed data and chart metadata (including a base64-encoded image).

FunctionsΒΆ

owlmix.reporting.sections.vif.build_vif_section(report_builder)ΒΆ
Parameters:

report_builder (ReportBuilderProtocol) – The report builder instance containing the dataframe and configuration.

Returns:

A dictionary with keys:

  • data: The computed VIF results.

  • chart: Metadata and image for the generated plot, including:

    • title: Title of the chart.

    • description: Description of the chart.

    • alt_text: Alternative text for the image.

    • image: Base64-encoded image of the plot.

Return type:

dict

Workflow:

  1. Retrieves the VIF configuration from the report builder.

  2. Fetches the analyzer and plotter classes and their parameter classes from the registries.

  3. Initializes analyzer and plotter parameter objects using the configuration.

  4. Instantiates the analyzer with the DataFrame and parameters, then computes the VIF data.

  5. Instantiates the plotter with the computed data and plot parameters, then generates the plot.

  6. Converts the plot image to a base64 string for embedding in the report.

  7. Returns a dictionary containing both the computed data and chart metadata.

Example Usage:

section = build_vif_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["vif"]: Provides the analyzer class and its parameter class for VIF.

  • PLOTTERS_REGISTRY["vif"]: Provides the plotter class and its parameter class for VIF.

Section RegistrationΒΆ

The function is registered as a report section under the name "vif" using the @register_section decorator.

@register_section("vif")
def build_vif_section(report_builder: ReportBuilderProtocol) -> Dict[str, Any]:
    ...

See AlsoΒΆ

Back to Home