Beispiel #1
0
 def k_nearst_neighbour_classify(self):
     knn = KNNClassifier()
     predictions = knn.predict_classification(self.X_train, self.y_train,
                                              self.X_test)
     accuracy = str(self.main.accuracy(self.y_test, predictions))
     accuracy = accuracy[0:4]
     self.knn_acc_label.setText(accuracy)
Beispiel #2
0
    def classify_custom_input(self, custom_input_vector):
        nb = NaiveBayesClassifier()
        nb.train(self.X_train, self.y_train)
        prediction = nb.predict([custom_input_vector])
        self.custom_text_nb_label.setText(str(prediction[0]))

        knn = KNNClassifier()
        prediction = knn.predict_classification(self.X_train, self.y_train,
                                                [custom_input_vector])
        self.custom_text_knn_label.setText(str(prediction[0]))

        rf = SklearnRandomForest()
        prediction = rf.random_forest(self.X_train, self.y_train,
                                      [custom_input_vector])
        self.custom_text_dt_label.setText(str(prediction[0]))

        dt = SklearnDecisionTree()
        prediction = dt.decision_tree(self.X_train, self.y_train,
                                      [custom_input_vector])
        self.custom_text_rf_label.setText(str(prediction[0]))