Source code for gui.core.LocalRMSEPExplore

import numpy as np
from PyQt5 import QtWidgets

from gui.ui.LocalRMSEPExplore import Ui_Form
from gui.util.Modules import Modules
from libpyhat.regression import local_rmsep


[docs] class LocalRMSEPExplore(Ui_Form, Modules):
[docs] def setupUi(self, Form): super().setupUi(Form) Modules.setupUi(self, Form)
[docs] def get_widget(self): return self.groupLayout
[docs] def connectWidgets(self): self.setComboBox(self.chooseDataComboBox, self.datakeys) try: self.comp_label = self.data[ self.chooseDataComboBox.currentText()].comp_label except: self.comp_label = None self.refresh() self.chooseDataComboBox.currentIndexChanged.connect(self.refresh) self.hidefit() self.extrapolate_check.stateChanged.connect(self.hidefit) self.fitall.toggled.connect(self.set_radio_buttons) self.fit_local_min.toggled.connect(self.set_radio_buttons)
[docs] def set_radio_buttons(self): if self.fitall.isChecked(): self.fit_local_min.setChecked(False) if self.fit_local_min.isChecked(): self.fitall.setChecked(False)
[docs] def hidefit(self): if self.extrapolate_check.isChecked(): hide = False else: hide = True self.fitall.setHidden(hide) self.fit_local_min.setHidden(hide) self.xmax.setHidden(hide) self.xmax_label.setHidden(hide)
[docs] def refresh(self): self.changeComboListVars( self.choosecomp, self.get_choices(self.comp_label) ) self.changeComboListVars( self.choosepredict, self.get_choices('predict') )
[docs] def run(self): data = self.data[self.chooseDataComboBox.currentText()] self.comp_label = data.comp_label predictions = data.df[('predict', self.choosepredict.currentText())] actuals = data.df[(self.comp_label, self.choosecomp.currentText())] windowsize = [float(i) for i in self.window_size.text().split(',')] n_neighbors = np.array( [int(i) for i in self.n_neighbors.text().split(',')] ) n_neighbors = n_neighbors[n_neighbors >= 1] sigma = [int(i) for i in self.sigma.text().split(',')] xmax = self.xmax.value() if self.plot_file.text() == '': plot_file = None else: plot_file = self.plot_file.text() extrap = self.extrapolate_check.isChecked() fullfit = self.fitall.isChecked() local_rmsep.local_rmse_explore( predictions, actuals, windowsize=windowsize, min_rmsep_num=n_neighbors, sigma=sigma, plot_file=plot_file, xmax=xmax, outpath=self.outpath, element=self.choosecomp.currentText(), full_fit=fullfit, extrapolate=extrap )
[docs] def get_choices(self, colname): try: choices = self.data[self.chooseDataComboBox.currentText()].df[ colname].columns.values choices = [i for i in choices if 'Unnamed' not in i] # remove unnamed columns from # choices except: choices = ['No matching columns!'] return choices
if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Form = QtWidgets.QWidget() ui = LocalRMSEPExplore() ui.setupUi(Form) Form.show() sys.exit(app.exec_())