To create an interactive Looker Studio dashboard, you must convert the model's inference results into a Google Sheet. This involves several steps:
- Authenticate: Grant Colab access to
spreadsheets and drive scopes. - Configure Specs: Define
BudgetOptimizationSpec (including constraints like min_spend_shift_ratio and max_spend_shift_ratio) and MediaSummarySpec. - Generate Proto: Use
mmm_ui_gen.create_mmm_ui_data_proto to create the UI data proto from the model and your specs. - Convert to Dataframe: Use
dataframe_model_converter.DataFrameModelConverter to turn the proto into dataframes. - Upload: Use
sheets.upload_to_gsheet to push the dataframes to a Google Sheet. - Create URL: Use
url_generator.create_report_url(spreadsheet) to get the Looker Studio link.
Note: This process can take significant time (up to 20 minutes) as it performs multiple inferences based on your configuration.
# Example configuration snippet for dashboard generation
# ... (authentication and setup) ...
budgetOptSpec = budget_optimization_processor.BudgetOptimizationSpec(
start_date=start_date,
end_date=end_date,
optimization_name=optimization_name,
grid_name=grid_name_prefix,
constraints=channel_constraints,
use_optimal_frequency=use_optimal_frequency,
max_frequency=max_frequency,
)
summary_spec = marketing_processor.MediaSummarySpec(
include_non_paid_channels=include_non_paid_channels)
mmm_proto = mmm_ui_gen.create_mmm_ui_data_proto(
mmm=mmm,
specs=[
model_fit_processor.ModelFitSpec(),
marketing_processor.MarketingAnalysisSpec(
media_summary_spec=summary_spec,
),
budgetOptSpec,
],
time_breakdown_generators=time_breakdown_generators,
)
converter = dataframe_model_converter.DataFrameModelConverter(mmm_proto)
dataframes = converter()
spreadsheet = sheets.upload_to_gsheet(dataframes, credentials, spreadsheet_name=spreadsheet_name)
url = url_generator.create_report_url(spreadsheet)