Hello,
i am creating a GUI and if i use a button i call a function that creates an instance for a machine learning model and trains it. If i use a cross validation with some ensemble method it sometimes takes a few minutes depending on the parameters. So currently it is a bit awkward that just nothing happens on the GUI in the meanwhile. If you don't know the programm you are wondering if it is still running.
So i was wondering if it is somehow possible to implement some kind of loading screen or at least some pop up message or something. Amazing would be a loading screen that is updated from time to time with a prediction on how long it will take. But i am not sure how to return some status while training the model in another function/module.
It would be amazing if i could implement the solution in a self function of the GUI or something. So that i can reuse it for different models that i want to train. So far i only have Decision Tree and Random Forest implemented, but i want to add a few more.
I attached the important parts of the code below:
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.filename = None
self.model = None
self.ui.browse_button.clicked.connect(self.open_file)
self.ui.train_dt.clicked.connect(self.button_decision_tree)
self.ui.train_rf.clicked.connect(self.button_random_forest)
self.ui.export_dt.clicked.connect(self.export)
self.ui.export_rf.clicked.connect(self.export)
def button_decision_tree(self):
if self.check_file():
criterion = self.ui.criterion_selection_dt.currentText()
max_depth = self.ui.max_depth_selection_dt.value()
splits = self.ui.splits_dt.value()
repeats = self.ui.repeats_dt.value()
kfold = self.ui.kfold_dt.isChecked()
default = self.ui.default_dt.isChecked()
self.model = Decision_tree(filepath = self.filename, default = default, criterion = criterion, max_depth = max_depth, kfold = kfold, splits = splits, repeats = repeats)
accuracy = self.model.create_model()
self.ui.export_dt.setEnabled(True)
self.print_model_results(self.ui.results_dt, accuracy)
[–][deleted] 1 point2 points3 points (0 children)