_opt Module (Internal Script/Notes)ΒΆ

This file (abacus/driver/_opt.py) appears to contain script snippets or notes demonstrating the process of running budget optimisation, rather than defining reusable functions or classes for the driver workflow.

The snippets illustrate steps such as:

  • Extracting relevant data from a DataToFit object (e.g., extra_features_test_scaled, media_costs_by_row_test_scaled).

  • Defining channel prices (often assumed to be 1 if costs are already monetary).

  • Calculating a total budget for the optimisation period based on historical mean costs.

  • Defining optimisation bounds, potentially based on percentage deviations from historical means (using a helper like _get_lower_and_upper_bounds, assumed to be defined elsewhere).

  • Calling an optimisation function (e.g., find_optimal_budgets, assumed to be defined elsewhere) with the model, data, budget, prices, scalers, and bounds.

  • Processing and comparing the results (optimal allocation vs. previous allocation).

  • Visualising the comparison using a plotting function (e.g., plot.plot_pre_post_budget_allocation_comparison, assumed to be defined elsewhere).

These steps showcase how the optimisation functionality provided by other modules (like abacus.core.opt or model mixins) might be used in practice.