コード例 #1
0
 def classify_button_multiple(self):
     address = self.address_display.get()
     if len(address) < 1:
         messagebox.showinfo("Error", "Please choose a dataset")
     else:
         importObject = ImportAndClean()
         simple_predictor = KNNClassifier()
         # Check User Input
         file_name = "sample_input.txt"
         self.output.delete(0.0, END)
         result = simple_predictor.buffer_for_prediction(
             importObject.clean_for_prediction(address, True))
         self.save_results(result)
         self.output.insert(0.0, result)
コード例 #2
0
 def classify_button_single(self):
     entered_text = self.textentry.get()
     # print(entered_text)
     if len(entered_text) < 1:
         messagebox.showinfo("Error", "Please enter a headline")
     else:
         self.output.delete(0.0, END)
         importObject = ImportAndClean()
         simple_predictor = KNNClassifier()
         # Check User Input
         # test_string = "Justin Bieber arrested after concert"
         result = simple_predictor.buffer_for_prediction(
             importObject.clean_for_prediction(entered_text, False))
         self.save_results(result)
         self.output.insert(0.0, result)
    def train_button(self):
        entered_text = self.textentry.get()
        # print(entered_text)

        if len(entered_text) == 0:
            messagebox.showinfo("Error", "Please enter a relevant value")
        elif float(entered_text) > 0.31:
            messagebox.showinfo("Error", "Enter a value smaller than 0.3")
        else:
            self.output.delete(0.0, END)
            if len(self.address_display.get()) < 1:
                messagebox.showinfo("Error", "Please choose a dataset")
            else:
                importObject = ImportAndClean(self.address_display.get())
                text_column = importObject.get_text_column()
                numeric_column = importObject.get_label_column()
                trainer = NBModelBuilder(text_column, numeric_column,
                                         float(entered_text))
                self.output.insert(END, trainer.train())
コード例 #4
0
from Classifier_Code.back_import_clean import ImportAndClean
from Classifier_Code.back_train_get_accuracy_multinaivebayes import NBModelBuilder
from Classifier_Code.back_classify_multinaivebayes import NBClassifier
from Classifier_Code.back_train_get_accuracy_knn import KNNModelBuilder
from Classifier_Code.back_classify_knn import KNNClassifier

if __name__ == '__main__':

    # Check User Input
    # test_string = "Justin Bieber arrested after concert"
    test_string = "All the Times Ryan Reynolds And Blake Lively Roasted Each Other"
    # file_name = "sample_input.txt"

    # KNN
    # KNN Train
    importObject = ImportAndClean()
    text_column = importObject.get_text_column()
    numeric_column = importObject.get_label_column()

    # KNN Training and Testing
    knn_object_train = KNNModelBuilder(text_column, numeric_column, 0.1)
    print(knn_object_train.train())

    # KNN Classify
    # knn_object_classify = KNNClassifier()
    # print(knn_object_classify.buffer_for_prediction(
    #     importObject.clean_for_prediction(test_string, False)))

    # print(knn_object_classify.buffer_for_prediction(
    #     importObject.clean_for_prediction(file_name, True)))