How to use the nbc.NaiveBayesClassifier function in nbc

To help you get started, we’ve selected a few nbc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github theeluwin / kata / tasks / Classification - Titanic Survival / main.py View on Github external
def main(method='naive_bayes', cheat=False):
    if method not in available_methods:
        print("available methods: {}".format(', '.join(available_methods)))
        return
    train_x, train_y = read_data('data/train.csv')
    test_x, test_y = read_data('data/test.csv')
    if method == 'naive_bayes':
        nbc = NaiveBayesClassifier(train_x.shape[1])
        nbc.fit(train_x, train_y)
        if cheat:
            nbc.fit(test_x, test_y)
        pred_y = nbc.predict(test_x)
        flush('output_naive_bayes.txt', pred_y)
    elif method == 'random_forest':
        rfc = RandomForestClassifier()
        rfc.fit(train_x, train_y)
        if cheat:
            rfc.fit(test_x, test_y)
        pred_y = rfc.predict(test_x)
        flush('output_random_forest.txt', pred_y)
    evaluate(test_y, pred_y)

nbc

Number Base Converter

MIT
Latest version published 4 years ago

Package Health Score

39 / 100
Full package analysis

Popular nbc functions