Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)