def start_predict(self):
        # get predicting parameters
        model_name = str(self.ui.combobox_model.currentText())
        tweets_file = self.ui.textbox_tweets_file.text()
        header_included = self.ui.checkbox_header.isChecked()
        random_tweets = self.ui.spinbox_rand_tweets.value()

        # check for file validity
        try:
            Utils.file_validation(tweets_file, 'Tweet')
        except Exception as ex:
            Utils.show_msg(text=ex.args[0], title="Input Error")
            return

        # reset values of widgets
        self.reset_form()

        # disable all widgets
        self.disable_widgets(True)

        self.model_callback = CallBackMultiPredictNNet(
            self.update_batch_progress, self.update_tweet_progress,
            random_tweets)

        self.predictor = MultiPredictor(model_name, self.model_callback,
                                        tweets_file, header_included,
                                        random_tweets)

        # create a thread for predictor
        self.pred_thread = ModelPredictorThread(self.predictor)
        self.pred_thread.finished.connect(self.on_predict_finished)
        self.pred_thread.start()
Exemple #2
0
    def start_predict(self):
        # get predicting parameters
        model_name = str(self.ui.combobox_model.currentText())
        bot_file = self.ui.textbox_bot_file.text()
        human_file = self.ui.textbox_human_file.text()
        bot_tweets = self.ui.spinbox_bot_tweets.value()
        human_tweets = self.ui.spinbox_human_tweets.value()
        total_tweets = bot_tweets + human_tweets

        # check for file validity
        try:
            Utils.file_validation(bot_file, 'Tweet')
            Utils.file_validation(human_file, 'Tweet')
        except Exception as ex:
            Utils.show_msg(text=ex.args[0], title="Input Error")
            return

        # reset values of widgets
        self.reset_form()

        # disable all widgets
        self.disable_widgets(True)

        self.model_callback = CallBackMultiPredictNNet(
            self.update_batch_progress, self.update_tweet_progress,
            total_tweets)

        self.predictor = ModelTestPredictor(model_name, self.model_callback,
                                            bot_file, human_file, bot_tweets,
                                            human_tweets)

        # create a thread for predictor
        self.pred_thread = ModelPredictorThread(self.predictor)
        self.pred_thread.finished.connect(self.on_predict_finished)
        self.pred_thread.start()
Exemple #3
0
    def start_train(self):
        # get training parameters
        embedding_file = self.ui.textbox_embed.text()
        bot_file = self.ui.textbox_bot.text()
        human_file = self.ui.textbox_human.text()
        train_split = self.ui.slider_train.value() / 100.0
        test_split = 1 - train_split
        val_split = self.ui.slider_val.value() / 100.0
        epoches = self.ui.spinbox_epoches.value()
        batch_size = self.ui.spinbox_batch.value()
        addit_feat_enabled = self.ui.checkbox_additional_feats.isChecked()
        early_stop = self.ui.spinbox_earlystop.value()

        # get dataset config from combobox
        gen_method = str(self.ui.combobox_gen_method.currentText())
        if gen_method == "User Grouping":
            dataset_config = DatasetConfig.USER_STATE
        elif gen_method == "Random Pairing":
            dataset_config = DatasetConfig.RANDOM_STATE

        # Check for early stop validity
        if early_stop > epoches:
            Utils.show_msg(
                text=
                "Can not Insert Early Stop Epochs\nThat Bigger Than Training Epochs Number!",
                title="Input Error")
            return

        # check for files validity
        try:
            Utils.file_validation(embedding_file, 'Embedding')
            Utils.file_validation(bot_file, 'Bot')
            Utils.file_validation(human_file, 'Human')
        except Exception as ex:
            Utils.show_msg(text=ex.args[0], title="Input Error")
            return

        # reset progressbars
        self.ui.progressbar_epoches.setValue(0)
        self.ui.progressbar_batch.setValue(0)

        # reset graphs
        self.reset_graphs()

        # disable unnecessery widgets when starting training
        self.change_widgets_disabled(True)
        self.ui.btn_save.setDisabled(True)

        self.log.write_log("Start pre-training phase...")

        # create model instance with all parameters
        self.custom_callback = CallBackTrainNNet(self.log, self.draw_graphs,
                                                 self.batch_graphs_clear,
                                                 self.update_progressbars,
                                                 self.get_status_stopped,
                                                 self.MAX_BATCH,
                                                 self.update_batch_range)

        self.model = ModelTrainer(logger=self.log,
                                  embedding_file=embedding_file,
                                  bots_file=bot_file,
                                  human_file=human_file,
                                  validation_split=val_split,
                                  test_split=test_split,
                                  batch_size=batch_size,
                                  epochs=epoches,
                                  additional_feats_enabled=addit_feat_enabled,
                                  early_stopping=early_stop,
                                  dataset_config=dataset_config,
                                  custom_callback=self.custom_callback)

        # create a thread for training phase
        self.model_thread = ModelTrainerThread(self.model)
        self.model_thread.finished.connect(self.on_train_finished)
        self.model_thread.start()  # run the thread to start training