def naive_bayes(features, labels):
    ''' compute the naive bayes learner '''
    # count number each label for prior
    neginds = (labels == 0.0).nonzero()[0]
    posinds = (labels >= 1.0).nonzero()[0]

    a1 = len(neginds)/len(labels)
    a2 = len(posinds)/len(labels)
    label_counts = np.array([a1, a2]).flatten()
    label_prob = np.log(label_counts)
    
    # dividing the feature data into pos and neg 
    aux_neg = features[neginds, :]
    aux_pos = features[posinds, :]
    
    # summing over for each document (first field)
    # adding smoothing, log to prevent overflow
    param_neg = np.log((1 + aux_neg.sum(0)) / (1+aux_neg.sum(0)).sum())
    param_pos = np.log((1 + aux_pos.sum(0)) / (1+aux_pos.sum(0)).sum())
    pn = np.squeeze(np.asarray(param_neg))
    pp = np.squeeze(np.asarray(param_pos))
    params = [pn, pp]
    
    return label_prob, params
dataset/ETHPy150Open bt3gl/Advanced-Machine-Learning/naive_bayes_vs_logistic_regression/nb.py/naive_bayes/operator `==` -> `>=`