else: X_train = X_train.append(folds[x]) y_train = X_train['class'].values X_train = X_train.drop(['class'], axis=1) nb = NaiveBayes() #initialize Naive Bayes Classifier nb.fit(X_train, y_train) #train model with train data y_pred = nb.predict(X_test) #test model with test set #find error with respect to zero-one loss function error = nb.zero_one_loss_function(y_test, y_pred) printstr = "\nAccuracy of 0-1 loss for fold {0} ::: {1}".format( y, (1 - error)) print_both(file, printstr) accuracy_list.append((1 - error)) #get mean square error acc, precision, recall = nb.confusion_matrix(y_test, y_pred) printstr = "\nCF for fold {0} ::: acc:: {1} :: precision:: {2} :: recall :: {3}".format( y, acc, precision, recall) print_both(file, printstr) CF_accuracy_list.append(acc) CF_precision_list.append(precision) CF_recall_list.append(recall) test_set += 1 #increment test_set to set for the next fold result_set.update({dataset: accuracy_list}) CF_acc_result_set.update({dataset: CF_accuracy_list}) CF_prec_result_set.update({dataset: CF_precision_list}) CF_recall_result_set.update({dataset: CF_recall_list}) #express accuracy in terms of graph result_inorder = sorted(result_set.keys()) #increment x by 2 to get the actual and noise dataset graph for each dataset