MaxDiffMixedLogit.apply_intervention#

MaxDiffMixedLogit.apply_intervention(new_task_df, random_seed=None, new_respondents='error', draw_batch_size=None)[source]#

Simulate choices under a counterfactual task design.

Wraps predict_choices() with two conveniences:

  1. Dummy is_best / is_worst columns are auto-generated when both are absent from new_task_df (they are unused during prediction — only the item layout matters).

  2. The result is stored as self.intervention_idata for downstream comparison, matching the convention in the other customer-choice models.

This is the Type 1 intervention (observable attribute / assortment change). All items in new_task_df must already be in the trained pool. To score new items outside the training pool use score_new_items() (part-worths mode only).

Parameters:
new_task_dfpd.DataFrame

Counterfactual task design. Must contain respondent_id, task_id, and item_id columns. is_best / is_worst are optional — dummy flags are auto-added when both are absent.

random_seedRandomState, optional

Passed to predict_choices().

new_respondents{“error”, “population”}, default “error”

Passed to predict_choices().

draw_batch_sizeint, optional

Passed to predict_choices().

Returns:
xr.Dataset

Dataset from predict_choices() with best_pick, worst_pick, p_best, and p_worst.

Raises:
RuntimeError

If the model has not been fitted yet.