示例#1
0
    def predict(self):
        # Let the user chose a file.
        # only allows mat files to be read in
        filename = QFileDialog.getOpenFileName(self,
                                               'Open File',
                                               filter="*.mat")[0]

        if filename:

            # Make sure the user wants to use train.
            choice = QMessageBox.question(
                self, 'Extract!',
                "Are you sure you want to run prediction? If you click yes, the prediction might take a long time to run",
                QMessageBox.Yes | QMessageBox.No)

            if choice == QMessageBox.Yes:
                # User wants to train.
                raw_data = Importer.mat(filename)

                # Make data_raw smaller. (Should be removed in future versions).
                for row in raw_data:
                    raw_data[row] = raw_data[row][:1]

                prediction = self.wrapper.predict(raw_data, verbose=True)
                print(list(prediction))
            else:
                # User don't want to train.
                pass
示例#2
0
def development(filename):
    # Import mat file.
    data_raw = Importer.mat(filename)

    # Make data_raw smaller.
    for row in data_raw:
        data_raw[row] = data_raw[row][:1]

    # Train.
    wrapper.development(data_raw)
示例#3
0
    def train(self):
        # Let the user chose a file.
        # only allows mat files to be read in
        filename = QFileDialog.getOpenFileName(self,
                                               'Open File',
                                               filter="*.mat")[0]

        if filename:

            # Make sure the user wants to use train.
            choice = QMessageBox.question(
                self, 'Train',
                "Are you sure you want to train? If you click yes, the training might take long periods to train.",
                QMessageBox.Yes | QMessageBox.No)

            if choice == QMessageBox.Yes:
                # User wants to train.
                raw_data = Importer.mat(filename)

                # Make data_raw smaller. (Should be removed in future versions).
                for row in raw_data:
                    raw_data[row] = raw_data[row][:1]

                self.wrapper.train(data_raw=raw_data,
                                   shrink_percent=0.0,
                                   verbose=True)

                # Statistics obtained from the data
                global raw_signal
                global filtered_signal
                global chunked_X
                global chunked_Y
                global accuracy
                raw_signal = self.wrapper.bciObject.preprocessor.preprocess_statistics.raw_signal
                filtered_signal = self.wrapper.bciObject.preprocessor.preprocess_statistics.filtered_signal
                chunked_X = self.wrapper.bciObject.preprocessor.preprocess_statistics.chunked_X
                chunked_Y = self.wrapper.bciObject.preprocessor.preprocess_statistics.chunked_Y
                accuracy = self.wrapper.bciObject.prediction_model.model_statistics.accuracy
                #print(accuracy)

                msg = QMessageBox(self)
                msg.resize(500, 400)
                msg.setText("The training accuracy is %.3f" % accuracy)
                msg.show()

            else:
                # User don't want to train.
                pass