Module Expr Str FunctionDef arguments args NameParam NameParam defaults body Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Import alias identifier Assign NameStore Dict Assign NameStore Call AttributeLoad NameLoad attr Num For NameStore NameLoad body Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Str If CompareGt Call NameLoad NameLoad Num body For TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Index Str body If CompareNotIn SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index Str body Assign NameStore BinOpAdd BinOpAdd SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Call NameLoad NameLoad If CompareEq SubscriptLoad SubscriptLoad NameLoad Index Str Index NameLoad Str body If CompareIn NameLoad NameLoad body Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad orelse Assign SubscriptStore NameLoad Index NameLoad ListLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad orelse AugAssignAdd NameStore BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index NameLoad Assign SubscriptStore NameLoad Index NameLoad BinOpAdd Call AttributeLoad NameLoad attr NameLoad Num Num Assign SubscriptStore NameLoad Index SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Str BinOpAdd Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Str Num Num For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body If CompareEq Call NameLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Num body Expr Call AttributeLoad NameLoad attr NameLoad TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr orelse Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str ImportFrom alias Import alias identifier Assign NameStore Call AttributeLoad NameLoad attr Num Assign NameStore Dict Str Str Str ListLoad Num Call NameLoad Assign NameStore Dict Assign TupleStore NameStore NameStore TupleLoad ListLoad ListLoad Assign NameStore Str For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str If CompareEq Call NameLoad NameLoad Num body Expr Call AttributeLoad SubscriptLoad NameLoad Index Str attr Call NameLoad SubscriptLoad NameLoad Slice Num Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Call NameLoad NameLoad orelse If CompareEq Call NameLoad NameLoad Num body If BoolOpAnd CompareNotEq SubscriptLoad NameLoad Index Num NameLoad CompareNotEq NameLoad Str body Assign TupleStore NameStore NameStore Call NameLoad ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore Call NameLoad Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameStore NameStore Num For TupleStore NameStore NameStore NameStore NameLoad body Assign NameStore BinOpAdd NameLoad NameLoad Assign NameStore BinOpAdd BinOpDiv BinOpAdd BinOpMult NameLoad NameLoad BinOpMult NameLoad NameLoad Call NameLoad NameLoad BinOpMult BinOpMult NameLoad NameLoad BinOpPow BinOpDiv BinOpSub NameLoad NameLoad Call NameLoad NameLoad Num Assign NameStore BinOpDiv BinOpAdd BinOpMult NameLoad NameLoad BinOpMult NameLoad NameLoad Call NameLoad NameLoad Assign NameStore NameLoad Assign SubscriptStore NameLoad Index Call NameLoad SubscriptLoad NameLoad Index Num TupleLoad NameLoad BinOpAdd NameLoad Num Assign NameStore SubscriptLoad NameLoad Index Num orelse Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad NameLoad attr NameLoad AugAssignAdd SubscriptStore NameLoad Index Str SubscriptLoad NameLoad Index NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index Str attr NameLoad If CompareGt Call NameLoad NameLoad Num body Assign TupleStore NameStore NameStore Call NameLoad ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore Call NameLoad Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr BinOpAdd NameLoad ListLoad NameLoad keyword AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd NameLoad ListLoad NameLoad keyword AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr BinOpMult AttributeLoad NameLoad attr NameLoad Assign NameStore ListComp BinOpDiv SubscriptLoad NameLoad Index NameLoad Call NameLoad SubscriptLoad NameLoad Index Str comprehension NameStore SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Str Call NameLoad SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr Str SubscriptLoad NameLoad Index Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Import alias identifier Assign NameStore Call AttributeLoad NameLoad attr Num Assign NameStore ListComp NameLoad comprehension TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Index Str CompareEq SubscriptLoad SubscriptLoad NameLoad Index Str Index NameLoad Str Assign NameStore ListComp NameLoad comprehension TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Index Str CompareEq SubscriptLoad SubscriptLoad NameLoad Index Str Index NameLoad Str Assign NameStore IfExp CompareGt Call NameLoad NameLoad Num NameLoad NameLoad Assign NameStore IfExp CompareGt Call NameLoad NameLoad Num NameLoad NameLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Str If CompareGt Call NameLoad NameLoad Num body Assign NameStore IfExp CompareEq SubscriptLoad NameLoad Index Str Num Str SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Str Index Str If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr ListComp IfExp CompareIn SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index Str Num Call NameLoad SubscriptLoad NameLoad Index NameLoad comprehension NameStore NameLoad Assign NameStore BinOpSub NameLoad BinOpMult Num Call AttributeLoad NameLoad attr BinOpAdd Call AttributeLoad NameLoad attr BinOpPow BinOpSub NameLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Num SubscriptLoad SubscriptLoad NameLoad Index Str Index Str SubscriptLoad SubscriptLoad NameLoad Index Str Index Str keyword Num If NameLoad body Assign NameStore BinOpAdd NameLoad Call AttributeLoad NameLoad attr ListComp IfExp CompareIn SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index Str Num Call AttributeLoad SubscriptLoad NameLoad Index Str attr TupleLoad Call NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad Call AttributeLoad NameLoad attr Num comprehension NameStore NameLoad keyword Num Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpSub Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore SubscriptLoad Call NameLoad Call NameLoad NameLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Num Expr Call AttributeLoad NameLoad attr NameLoad TupleLoad NameLoad Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str ImportFrom alias alias ImportFrom alias Assign NameStore Call NameLoad keyword Call NameLoad keyword NameLoad Assign AttributeStore NameLoad attr ListLoad TupleLoad Str Call NameLoad Str keyword SubscriptLoad AttributeLoad NameLoad attr Index Str keyword NameLoad keyword NameLoad TupleLoad Str Call NameLoad Str keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr keyword Str keyword SubscriptLoad AttributeLoad NameLoad attr Index Str Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Return Dict Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Num NameLoad NameLoad body Expr Str ImportFrom alias alias ImportFrom alias alias Import alias identifier TryExcept body Assign NameStore Call NameLoad NameLoad handlers ExceptHandler type NameLoad body Raise Call NameLoad Str If CompareIn Str NameLoad body Assign NameStore Call NameLoad GeneratorExp TupleLoad NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Index Str If CompareLt Call NameLoad SubscriptLoad NameLoad Index Str Num body Print Str Return ListLoad orelse Raise Call NameLoad Str If CompareGt Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Str attr Str Num body Expr Call AttributeLoad NameLoad attr keyword Str For NameStore SubscriptLoad NameLoad Index Str body Assign NameStore ListComp Call AttributeLoad NameLoad attr BinOpAdd TupleLoad NameLoad NameLoad Num comprehension NameStore SubscriptLoad NameLoad Index Str Assign SubscriptStore NameLoad Index NameLoad BinOpSub Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr BinOpAdd Call AttributeLoad NameLoad attr NameLoad BinOpMult NameLoad SubscriptLoad NameLoad Index Str BinOpAdd Call AttributeLoad NameLoad attr NameLoad NameLoad SubscriptLoad NameLoad Index Str Delete SubscriptDel NameLoad Index Str Assign NameStore Call NameLoad keyword Call NameLoad keyword NameLoad Assign AttributeStore NameLoad attr ListLoad TupleLoad Str Call NameLoad Str keyword SubscriptLoad AttributeLoad NameLoad attr Index Str keyword NameLoad keyword NameLoad Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad Expr Call AttributeLoad NameLoad attr keyword Str keyword SubscriptLoad AttributeLoad NameLoad attr Index Str Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Return NameLoad decorator_list
N/A N/A 
Naive Bayes with MapReduce

Algorithm calculates multinomial distribution for discrete features and Gaussian distribution for numerical features.
The output of algorithm is consistent with implementation of Naive Bayes classifier in Orange and scikit-learn.

Reference:
MapReduce version of algorithm is proposed by Cheng-Tao Chu; Sang Kyun Kim, Yi-An Lin, YuanYuan Yu, Gary Bradski,
Andrew Ng, and Kunle Olukotun. "Map-Reduce for Machine Learning on Multicore". NIPS 2006.
 simple_init N/A N/A interface params N/A N/A N/A params N/A map_fit N/A N/A interface state label inp N/A N/A N/A 
    Function counts occurrences of feature values for every row in given data chunk. For continuous features it returns
    number of values and it calculates mean and variance for every feature.
    For discrete features it counts occurrences of labels and values for every feature. It returns occurrences of pairs:
    label, feature index, feature values.
     N/A numpy np N/A combiner N/A N/A out N/A N/A interface output 0 N/A row inp N/A N/A row N/A N/A N/A N/A row strip split N/A state N/A delimiter N/A N/A N/A len row 1 N/A N/A N/A i j N/A enumerate N/A state N/A X_indices N/A N/A N/A N/A row N/A j N/A state N/A missing_vals N/A N/A pair N/A N/A N/A row N/A N/A state N/A y_index N/A state N/A delimiter N/A str j N/A N/A N/A N/A state N/A X_meta N/A i c N/A N/A N/A pair combiner N/A N/A N/A N/A N/A combiner N/A pair append N/A N/A np float32 N/A row N/A j N/A N/A N/A combiner N/A pair N/A N/A N/A np float32 N/A row N/A j N/A N/A pair N/A N/A state N/A delimiter N/A row N/A j N/A N/A combiner N/A pair N/A N/A N/A combiner get pair 0 1 N/A N/A combiner N/A N/A row N/A N/A state N/A y_index N/A N/A N/A combiner get N/A row N/A N/A state N/A y_index 0 1 N/A N/A k v N/A N/A combiner iteritems N/A N/A N/A N/A len N/A N/A k split N/A state N/A delimiter 2 N/A N/A N/A N/A out add k N/A N/A N/A np size v N/A N/A np mean v dtype N/A np float32 N/A N/A np var v dtype N/A np float32 N/A N/A N/A N/A out add k v N/A reduce_fit N/A N/A interface state label inp N/A N/A N/A 
    Function separates aggregation of continuous and discrete features.
    For continuous features it aggregates partially calculated means and variances and returns them. For discrete
    features it aggregates pairs and returns them. Pairs with label occurrences are used to calculate prior probabilities
     disco.util kvgroup N/A numpy np N/A out N/A N/A interface output 0 N/A fit_model N/A y_labels y_sum iv N/A 0 N/A set N/A combiner N/A N/A N/A means variances N/A N/A N/A N/A k_prev N/A N/A key value N/A kvgroup inp N/A N/A k_split N/A N/A key split N/A state N/A delimiter N/A N/A N/A len k_split 3 N/A N/A N/A N/A N/A fit_model N/A iv add N/A tuple N/A k_split N/A 1 N/A N/A N/A out add N/A tuple k_split N/A sum value N/A N/A N/A N/A len k_split 2 N/A N/A N/A N/A N/A k_split N/A 0 k_prev N/A k_prev N/A N/A N/A mean var N/A zip N/A N/A combiner N/A key N/A key N/A sorted N/A N/A combiner keys N/A N/A N/A means append mean N/A N/A N/A variances append var N/A n_a mean_a var_a 0 N/A N/A n_b mean_b var_b value N/A N/A n_ab N/A n_a n_b N/A var_a N/A N/A N/A N/A n_a var_a N/A n_b var_b N/A float n_ab N/A N/A n_a n_b N/A N/A N/A mean_b mean_a N/A float n_ab 2 N/A mean_a N/A N/A N/A n_a mean_a N/A n_b mean_b N/A float n_ab N/A n_a n_ab N/A N/A combiner N/A N/A int N/A k_split N/A 1 N/A mean_a N/A var_a 1e-09 N/A k_prev N/A k_split N/A 0 N/A N/A N/A fit_model N/A key N/A N/A np sum value N/A N/A fit_model N/A y_sum N/A fit_model N/A key N/A N/A N/A N/A fit_model N/A y_labels append key N/A N/A N/A len means 0 N/A N/A N/A mean var N/A zip N/A N/A combiner N/A key N/A key N/A sorted N/A N/A combiner keys N/A N/A N/A out add mean N/A N/A np array N/A means N/A mean dtype N/A np float32 N/A variances N/A N/A np array N/A variances N/A var dtype N/A np float32 N/A N/A N/A out add var variances N/A N/A N/A out add var_log N/A N/A np log N/A N/A np pi variances N/A prior N/A N/A N/A fit_model N/A y_label N/A float N/A fit_model N/A y_sum N/A y_label N/A fit_model N/A y_labels N/A N/A N/A out add prior N/A N/A np array prior dtype N/A np float32 N/A N/A N/A out add prior_log N/A N/A np log prior N/A N/A N/A out add iv N/A list N/A fit_model N/A iv N/A N/A N/A out add y_labels N/A fit_model N/A y_labels N/A map_predict N/A N/A interface state label inp N/A N/A N/A 
    Function makes a predictions of samples with given model. It calculates probabilities with multinomial and Gaussian distribution.
     N/A numpy np N/A out N/A N/A interface output 0 N/A continuous N/A j N/A N/A i j N/A enumerate N/A state N/A X_indices N/A N/A N/A state N/A X_meta N/A i c N/A discrete N/A j N/A N/A i j N/A enumerate N/A state N/A X_indices N/A N/A N/A state N/A X_meta N/A i d N/A cont N/A N/A N/A len continuous 0 True False N/A disc N/A N/A N/A len discrete 0 True False N/A row inp N/A N/A row N/A N/A N/A N/A row strip split N/A state N/A delimiter N/A N/A N/A len row 1 N/A N/A x_id N/A N/A N/A state N/A id_index -1 N/A row N/A N/A state N/A id_index N/A probs N/A N/A state N/A fit_model N/A prior_log N/A cont N/A N/A x N/A N/A np array N/A N/A N/A N/A row N/A j N/A state N/A missing_vals 0 N/A float N/A row N/A j N/A j continuous N/A probs N/A probs N/A 0.5 N/A N/A np sum N/A N/A N/A np true_divide N/A N/A x N/A N/A state N/A fit_model N/A mean 2 N/A N/A state N/A fit_model N/A var N/A N/A state N/A fit_model N/A var_log axis 1 N/A disc N/A N/A probs N/A probs N/A N/A np sum N/A N/A N/A N/A row N/A i N/A state N/A missing_vals 0 N/A N/A N/A state N/A fit_model get N/A N/A str i N/A row N/A i N/A N/A np zeros 1 N/A i discrete axis 0 N/A log_prob_x N/A N/A np log N/A N/A np sum N/A N/A np exp probs N/A probs N/A N/A np exp N/A N/A N/A np array probs log_prob_x N/A y_predicted N/A N/A max N/A zip probs N/A N/A state N/A fit_model N/A y_labels N/A 1 N/A N/A N/A out add x_id N/A y_predicted N/A N/A probs tolist N/A fit N/A N/A dataset save_results show N/A True False N/A N/A 
    Function builds a model for Naive Bayes. It executes multiple map functions and one reduce function which aggregates intermediate results and returns a model.

    Parameters
    ----------
    input - dataset object with input urls and other parameters
    save_results - save results to ddfs
    show - show info about job execution

    Returns
    -------
    Urls of fit model results on ddfs
     disco.worker.pipeline.worker Worker Stage disco.core Job N/A job N/A Job worker N/A Worker save_results save_results N/A N/A job pipeline N/A N/A split N/A Stage map input_chain N/A N/A dataset params N/A input_chain init simple_init process map_fit N/A group_all N/A Stage reduce init simple_init process reduce_fit sort True combine True N/A N/A job params N/A dataset params N/A N/A N/A job run name naivebayes_fit input N/A N/A dataset params N/A data_tag N/A fitmodel_url N/A N/A job wait show show N/A N/A naivebayes_fitmodel fitmodel_url N/A predict N/A N/A dataset fitmodel_url m save_results show N/A 1 True False N/A N/A 
    Function starts a job that makes predictions to input data with a given model

    Parameters
    ----------
    input - dataset object with input urls and other parameters
    fitmodel_url - model created in fit phase
    m - m estimate is used with discrete features
    save_results - save results to ddfs
    show - show info about job execution

    Returns
    -------
    Urls of predictions on ddfs
     disco.worker.pipeline.worker Worker Stage disco.core Job result_iterator N/A numpy np N/A N/A N/A m N/A float m N/A N/A N/A ValueError N/A N/A N/A Exception Parameter m should be numerical. N/A N/A naivebayes_fitmodel fitmodel_url N/A N/A fit_model N/A dict N/A N/A k v N/A N/A k v N/A result_iterator N/A fitmodel_url N/A naivebayes_fitmodel N/A N/A N/A len N/A fit_model N/A y_labels 2 N/A N/A There is only one class in training data. N/A N/A N/A N/A N/A Exception Incorrect fit model. N/A N/A N/A N/A N/A N/A dataset params N/A X_meta count d 0 N/A N/A N/A N/A np seterr divide ignore N/A iv N/A fit_model N/A iv N/A N/A dist N/A N/A N/A fit_model pop N/A N/A y iv 0 N/A y N/A fit_model N/A y_labels N/A N/A fit_model N/A iv N/A N/A N/A np nan_to_num N/A N/A np log N/A N/A np true_divide N/A N/A N/A np array dist N/A m N/A fit_model N/A prior N/A N/A N/A np sum dist m N/A fit_model N/A prior_log N/A N/A fit_model N/A iv N/A job N/A Job worker N/A Worker save_results save_results N/A N/A job pipeline N/A N/A split N/A Stage map input_chain N/A N/A dataset params N/A input_chain init simple_init process map_predict N/A N/A job params N/A dataset params N/A N/A N/A job params N/A fit_model fit_model N/A N/A N/A job run name naivebayes_predict input N/A N/A dataset params N/A data_tag N/A results N/A N/A job wait show show N/A results N/A