Example #1
0
    def predict(self):
        try:
            prediction = self.decision_tree.predict(self.predict_data)

            XMessage(text='Your model predicts {pred}'.format(pred=prediction), title='Prediction')
        except Exception as e:
            XError(text='Error making prediction!: {}'.format(e))
Example #2
0
    def save_model(self, path, filename):
        try:
            with open(os.path.join(path, filename), 'wb') as stream:
                pickle.dump(self.model, stream)

            self.dismiss_popup()
        except Exception as e:
            self.dismiss_popup()
            XError(text='Error saving model!: {}'.format(e))
Example #3
0
    def load_predict_data(self, path, filename):
        try:
            self.predict_data = pd.read_csv(filename[0]).as_matrix()
            self.dismiss_popup()

            if self.model:
                self.predict_button.disabled = False
        except Exception as e:
            self.dismiss_popup()
            XError(text='Error loading predicting data!: {}'.format(e))
Example #4
0
    def load_training_data(self, path, filename):
        try:
            raw_data = pd.read_csv(filename[0]).as_matrix()
            self.training_data = split_data(raw_data, train_test=self.train_test)

            self.train_button.disabled = False
            self.dismiss_popup()
        except Exception as e:
            self.dismiss_popup()
            XError(text='Error loading training data: {}'.format(e))
Example #5
0
    def load_model(self, path, filename):
        try:
            with open(os.path.join(path, filename[0]), 'rb') as stream:
                self.model = pickle.load(stream)

            if self.predict_data:
                self.predict_button.disabled = False

            self.dismiss_popup()
        except Exception as e:
            self.dismiss_popup()
            XError(text='Error loading model!: {}'.format(e))
Example #6
0
    def train(self, *args):
        lam = self.lam.value
        alpha = self.alpha.value
        epochs = self.epochs.value
        adaptive = self.adaptive.value
        dec_amount = self.dec_amount.value
        hidden_layer_size = self.hidden_layer_size.value

        try:
            self.network = neural_network.NeuralNetwork(hidden_layer_size=int(hidden_layer_size),
                                                        activation_func='sigmoid')

            self.cost, self.costs, self.model = self.network.train(X=self.training_data['X'],
                                                                   y=self.training_data['y'],
                                                                   alpha=alpha,
                                                                   max_epochs=int(epochs),
                                                                   lam=lam,
                                                                   adaptive=adaptive,
                                                                   dec_amount=dec_amount)
            self.loading_pop.dismiss()

            if self.train_test:
                accuracy = self.get_accuracy()

                XMessage(text='Training complete! Your Model\'s accuracy is {acc:.2f}%.'.format(acc=accuracy),
                         title='Your Model Has Been Trained!')
            else:
                XMessage(text='Training complete!', title='Your Model Has Been Trained!')

            if self.predict_data:
                self.predict_button.disabled = False

            self.training_graph_button.disabled = False
            self.draw_network()
        except Exception as e:
            self.loading_pop.dismiss()
            XError(text='Error training model!: {}'.format(e))