MaxDiffArrays#

class pymc_marketing.customer_choice.maxdiff.MaxDiffArrays[source]#

Preprocessed arrays ready for the MaxDiff likelihood.

Attributes:
item_idxnp.ndarray

Shape (T, K_max) int64. Items shown in each task as indices into the item pool, padded with the reference item’s index where mask is False.

masknp.ndarray

Shape (T, K_max) bool. True where the position is a real shown item.

best_posnp.ndarray

Shape (T,) int64. Position (0..K_max-1) of the best-chosen item.

worst_posnp.ndarray

Shape (T,) int64. Position of the worst-chosen item.

resp_idxnp.ndarray

Shape (T,) int64. Respondent index for each task.

n_tasksint

Number of tasks T.

n_respondentsint

Number of unique respondents.

n_itemsint

Size of the full item pool.

k_maxint

Maximum subset size across all tasks.

item_to_idxdict[str, int]

Mapping from item name to integer index.

respondent_to_idxdict[Any, int]

Mapping from respondent identifier to integer index.

Methods

MaxDiffArrays.__init__(*args, **kwargs)

MaxDiffArrays.clear()

MaxDiffArrays.copy()

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.items()

MaxDiffArrays.keys()

MaxDiffArrays.pop(key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

MaxDiffArrays.popitem(/)

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]

MaxDiffArrays.values()

Attributes

item_idx

mask

best_pos

worst_pos

resp_idx

n_tasks

n_respondents

n_items

k_max

item_to_idx

respondent_to_idx