Plot Input (`sketch.plot_input`)
This module provides input-data visualisation helpers for metrics, correlation structure, and target-over-time views.
Import style:
from sketch.plot_input import plot_all_metrics, plot_correlation_matrix, plot_all_media_spend# Compatibility form in some environments:# from src.sketch.plot_input import ...plot_all_metrics(input_data, output_dir, suffix)
Section titled “plot_all_metrics(input_data, output_dir, suffix)”Plots all media volumes/costs, extra features, and target in a multi-panel Matplotlib figure.
Saved artefact:
metrics_{suffix}.png→10_pre_diagnostics/
The function persists via save_figure(..., stage=STAGE_PRE_DIAGNOSTICS).
plot_correlation_matrix(input_data, per_observation_df)
Section titled “plot_correlation_matrix(input_data, per_observation_df)”Returns a Plotly heatmap and correlation DataFrame for volume columns plus target.
- Returns:
(fig, corr_df) - No automatic file save.
If you want persistence, save manually into your chosen stage directory (for example 10_pre_diagnostics/) with Plotly I/O methods.
plot_all_media_spend(input_data, per_observation_df)
Section titled “plot_all_media_spend(input_data, per_observation_df)”Returns a Plotly line chart of target over time.
- Returns:
fig - No automatic file save.
As above, save manually if needed.
Usage example
Section titled “Usage example”from sketch.plot_input import plot_all_metrics, plot_correlation_matrix
plot_all_metrics(input_data, output_dir=results_dir, suffix="raw")
corr_fig, corr_df = plot_correlation_matrix(input_data, per_observation_df)# Optional manual save:# corr_fig.write_html(f"{results_dir}/10_pre_diagnostics/correlation_matrix.html")