econirl.preprocessing.feature_diagnostics

econirl.preprocessing.feature_diagnostics(feature_matrix)[source]

Rank and conditioning of a reward-feature design, raw and action-differenced.

A reward parameter is identified from behavior only if its feature varies across actions within a state. The raw stacked design (S*A, K) can be full rank while a parameter is still unrecoverable from choices, because any feature that is constant across actions differences out of every choice comparison. The action-contrast design phi(s, a) - phi(s, A) is the one that drives identification, so contrast_rank is the check that bites. For example, a gridworld with a state-only step penalty and distance features has raw rank 3 but contrast rank 1.

Parameters:

feature_matrix (numpy.ndarray) – Reward features with shape (S, A, K): states, actions, features.

Returns:

Diagnostics with keys:

  • num_features : number of features K.

  • feature_rank : rank of the raw design (S*A, K).

  • condition_number : condition number of the raw design.

  • contrast_rank : rank of the action-contrast design phi(s, a) - phi(s, A). Compare this to num_features; if it is smaller, some reward parameters are not identified from choices.

  • contrast_condition_number : condition number of the contrast design.

Return type:

dict