MaxDiffArrays#
- class pymc_marketing.customer_choice.maxdiff.MaxDiffArrays[source]#
Preprocessed arrays ready for the MaxDiff likelihood.
- Attributes:
- item_idx
np.ndarray Shape
(T, K_max)int64. Items shown in each task as indices into the item pool, padded with the reference item’s index wheremaskis False.- mask
np.ndarray Shape
(T, K_max)bool. True where the position is a real shown item.- best_pos
np.ndarray Shape
(T,)int64. Position (0..K_max-1) of the best-chosen item.- worst_pos
np.ndarray Shape
(T,)int64. Position of the worst-chosen item.- resp_idx
np.ndarray Shape
(T,)int64. Respondent index for each task.- n_tasks
int Number of tasks
T.- n_respondents
int Number of unique respondents.
- n_items
int Size of the full item pool.
- k_max
int Maximum subset size across all tasks.
- item_to_idx
dict[str,int] Mapping from item name to integer index.
- respondent_to_idx
dict[Any,int] Mapping from respondent identifier to integer index.
- item_idx
Methods
MaxDiffArrays.__init__(*args, **kwargs)MaxDiffArrays.fromkeys(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
MaxDiffArrays.get(key[, default])Return the value for key if key is in the dictionary, else default.
MaxDiffArrays.pop(key[, default])If the key is not found, return the default if given; otherwise, raise a KeyError.
Remove and return a (key, value) pair as a 2-tuple.
MaxDiffArrays.setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
MaxDiffArrays.update([E, ]**F)If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
Attributes
item_idxmaskbest_posworst_posresp_idxn_tasksn_respondentsn_itemsk_maxitem_to_idxrespondent_to_idx