def get_state_machine(): """Gets state transition probabilities for items.""" user_stats = get_global_rater_stats() state_transitions = ConditionalFreqDist() for user_data in user_stats: state_transitions.add_counts(user_data['state_machine']) return state_transitions
def _calculated_item_change(response_data): """ Calculates how many items were forgotten and how many were learned. """ fs = ConditionalFreqDist() response_data = [(pid, pt, i, ic) for (i, (pid, pt, ic)) in enumerate(response_data)] response_data.sort() for (pivot_id, pivot_type), responses in groupby(response_data, lambda r: (r[0], r[1])): responses = list(responses) if len(responses) < 2: continue for i in xrange(len(responses) - 1): from_state = responses[i][-1] and 'k' or 'u' to_state = responses[i + 1][-1] and 'k' or 'u' fs[from_state].inc(to_state) return fs