Module ImportFrom alias Import alias identifier Import alias identifier FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Num Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr attr Str Assign NameStore Call AttributeLoad NameLoad attr keyword Num If Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr body Raise Call NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad Num keyword NameLoad Assign SubscriptStore NameLoad Index Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad keyword NameLoad Return Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore BinOpSub Call AttributeLoad Call AttributeLoad NameLoad attr attr keyword Num Call AttributeLoad AttributeLoad NameLoad attr attr TupleLoad NameLoad Num Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr CompareGt NameLoad Num Assign NameStore GeneratorExp SubscriptLoad AttributeLoad NameLoad attr Index Num comprehension TupleStore NameStore NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If UnaryOpNot AttributeLoad AttributeLoad NameLoad attr attr body Raise Call NameLoad Str If UnaryOpNot AttributeLoad AttributeLoad NameLoad attr attr body Raise Call NameLoad Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore BoolOpOr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareLt NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad GeneratorExp Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad keyword NameLoad comprehension NameStore Call NameLoad NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad keyword Str keyword NameLoad keyword TupleLoad Str Str Return NameLoad decorator_list
N/A __future__ division N/A numpy np N/A pandas pd utils_to_probs N/A N/A utils N/A N/A N/A 
    Convert a table of utilities to exponentiated probabilities.

    Parameters
    ----------
    utils : pandas.DataFrame
        Rows should be choosers and columns should be alternatives.

    Returns
    -------
    probs : pandas.DataFrame
        Will have the same index and columns as `utils`.

     N/A prob_min 1e-300 N/A prob_max N/A np inf N/A utils_arr N/A N/A np exp N/A N/A N/A N/A utils as_matrix astype float N/A arr_sum N/A N/A utils_arr sum axis 1 N/A N/A N/A N/A N/A np isinf arr_sum any N/A N/A N/A RuntimeError utilities have infinite values N/A N/A N/A np clip utils_arr prob_min prob_max out utils_arr N/A N/A N/A np divide utils_arr N/A N/A arr_sum reshape N/A len utils_arr 1 out utils_arr N/A N/A utils_arr N/A N/A N/A np isnan utils_arr prob_min N/A N/A N/A np clip utils_arr prob_min prob_max out utils_arr N/A N/A N/A pd DataFrame utils_arr columns N/A utils columns index N/A utils index N/A make_choices N/A N/A probs N/A N/A N/A 
    Make choices for each chooser from among a set of alternatives.

    Parameters
    ----------
    probs : pandas.DataFrame
        Rows for choosers and columns for the alternatives from which they
        are choosing. Values are expected to be valid probabilities across
        each row, e.g. they should sum to 1.

    Returns
    -------
    choices : pandas.Series
        Maps chooser IDs (from `probs` index) to a choice, where the choice
        is an index into the columns of `probs`.

     N/A nchoosers N/A len probs N/A probs_arr N/A N/A N/A N/A N/A probs as_matrix cumsum axis 1 N/A N/A N/A np random random N/A nchoosers 1 N/A N/A rows cols N/A N/A np where N/A probs_arr 0 N/A choices N/A N/A N/A s iat N/A 0 N/A N/A _ s N/A N/A N/A N/A pd Series cols groupby rows N/A N/A N/A pd Series choices index N/A probs index N/A interaction_dataset N/A N/A choosers alternatives sample_size N/A None N/A N/A 
    Combine choosers and alternatives into one table for the purposes
    of creating interaction variables and/or sampling alternatives.

    Parameters
    ----------
    choosers : pandas.DataFrame
    alternatives : pandas.DataFrame
    sample_size : int, optional
        If sampling from alternatives for each chooser, this is
        how many to sample.

    Returns
    -------
    interacted : pandas.DataFrame
        Merged choosers and alternatives with data repeated either
        len(alternatives) or `sample_size` times.

     N/A N/A N/A N/A choosers index is_unique N/A N/A N/A RuntimeError ERROR: choosers index is not unique, sample will not work correctly N/A N/A N/A N/A alternatives index is_unique N/A N/A N/A RuntimeError ERROR: alternatives index is not unique, sample will not work correctly N/A numchoosers N/A len choosers N/A numalts N/A len alternatives N/A sample_size N/A sample_size numalts N/A alts_idx N/A N/A np arange numalts N/A N/A sample_size numalts N/A N/A sample N/A N/A np concatenate N/A tuple N/A N/A N/A N/A np random choice alts_idx sample_size replace False N/A _ N/A range numchoosers N/A N/A sample N/A N/A np tile alts_idx numchoosers N/A alts_sample N/A N/A alternatives take sample N/A N/A alts_sample N/A chooser_idx N/A N/A np repeat N/A N/A choosers index values sample_size N/A alts_sample N/A N/A pd merge alts_sample choosers left_on chooser_idx right_index True suffixes N/A _r N/A alts_sample N/A