Beispiel #1
0
    def on_menu_file_open(self, widget):
        dialog = Gtk.FileChooserDialog("Please choose a file", self,
                                       Gtk.FileChooserAction.OPEN,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                        Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
        self.add_filters(dialog)

        response = dialog.run()

        if response == Gtk.ResponseType.OK:
            # reset
            self.nninfo.reset()
            self.log_refresh()

            print("Open clicked")
            print("File selected: " + dialog.get_filename())
            print(self.traning_testing_rate_sb.get_value() / 100)
            self.dataset.set_file_name(dialog.get_filename())
            self.dataset.open_file()

            # log info
            file_name = dialog.get_filename().split('/')[-1]

            if self.dataset.get_data_size() > 100:
                print("tt rate\t", self.traning_testing_rate_sb.get_value())
                self.training_set = self.dataset.get_data(
                    self.traning_testing_rate_sb.get_value() / 100, approach="func")
                self.training_set = (dp.to_ndata(
                    self.training_set[0]), self.training_set[1])
                self.testing_set = self.dataset.get_data(
                    1 - self.traning_testing_rate_sb.get_value() / 100, approach="func")
                self.testing_set = (dp.to_ndata(
                    self.testing_set[0]), self.testing_set[1])
            else:
                self.training_set = self.dataset.get_data(
                    1, approach="func", is_random=False)
                self.training_set = (dp.to_ndata(
                    self.training_set[0]), self.training_set[1])

                self.testing_set = self.dataset.get_data(1, approach="func")
                self.testing_set = (dp.to_ndata(
                    self.testing_set[0]), self.testing_set[1])
            self.nninfo.traning.Data_set_size = len(self.training_set[1])
            self.nninfo.testing.Data_set_size = len(self.testing_set[1])

            print(self.training_set)

            self.dataset_info_msg_lab.set_text((file_name[0:18] + "..." if len(file_name) > 20 else file_name) + " \n" + self.dataset.get_data_size(
            ).__str__() + " \n" + self.dataset.get_data_dimension().__str__() + " \n" + self.dataset.get_data_classification_num().__str__() + " ")

            # self.traning_draw_paper.resetpaper()
            # self.testing_draw_paper.resetpaper()
        elif response == Gtk.ResponseType.CANCEL:
            print("Cancel clicked")
        #print(self.data, ", ", self.class_table, ", ", tmp_table)
        dialog.destroy()
Beispiel #2
0
 def on_clicked_generate(self, widght):
     if self.dataset.get_data_size() > 100:
         print("tt rate\t", self.traning_testing_rate_sb.get_value())
         self.training_set = self.dataset.get_data(self.traning_testing_rate_sb.get_value() / 100)
         self.training_set = (dp.to_ndata(self.training_set[0]), self.training_set[1])
         self.testing_set = self.dataset.get_data(1 - self.traning_testing_rate_sb.get_value() / 100)
         self.testing_set = (dp.to_ndata(self.testing_set[0]), self.testing_set[1])
     else:
         self.training_set = self.dataset.get_data(1)
         self.training_set = (dp.to_ndata(self.training_set[0]), self.training_set[1])
         self.testing_set = self.dataset.get_data(1)
         self.testing_set = (dp.to_ndata(self.testing_set[0]), self.testing_set[1])
     self.nninfo.traning.Data_set_size = len(self.training_set[1])
     self.nninfo.testing.Data_set_size = len(self.testing_set[1])