Naive Bayes unable to detect preprocessing techniques from data

I'm testing out different preprocessing techniques on mulit-class classification problems. I've used multiple algorithms, but the only algorithm that giving me trouble is Naive Bayes.

        
    def NB(self):
        
        #Import Classifier
        
        from sklearn.naive_bayes import MultinomialNB, GaussianNB

        accuracy = 0 
        speed = 0
        percision = 0
        f1 = 0
        recall = 0
        
        for count in range(5):

            nb = Pipeline([('vect', CountVectorizer()),
                        ('tfidf', TfidfTransformer()),
                        ('clf', MultinomialNB()),
                       ])
                        
        # There are two options for average: macro or weighted
        # We are going with Macro since we have a balanced dataset
            
            nb.fit(self.X_train, self.y_train)
            y_pred = nb.predict(self.X_test)
            accuracy += accuracy_score(y_pred, self.y_test)
            percision += precision_score(self.y_test, y_pred, labels = my_tags, average=macro)
            f1 += f1_score(self.y_test, y_pred, labels = my_tags, average=macro)
            recall += recall_score(self.y_test, y_pred, labels = my_tags, average=macro)
        
        #create confusion matrix and classification files (Set for only base)
        
        if self.functionName == 'base' or self.functionName == 'rm_punctuation':

            algorithm = 'Naive Bayes'
            plots = Plots(algorithm, self.functionName)
            plots.picOfConfusion(nb, self.y_test, y_pred)
            plots.classification_report_plot(classification_report(self.y_test, y_pred, output_dict=True),self.functionName)

        #Puts accuracy and speed into dictionary for later
#         accuracy/5, speed/5, percision/5, f1/5, recall/5, roc_score/5
                                
        NB_results[self.functionName] = [accuracy/5, speed/5, percision/5, f1/5, recall/5]

I give it different proprocessed data, but it gives me the exact same accuracy, recall, precision, and f1. I could conclude that Naive Bayes isn't able to detect these changes in the data whereas other algorithms such as random tree and decision tree can due to their sensitivity to data.

Topic naive-bayes-algorithim preprocessing naive-bayes-classifier machine-learning

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.