def test_golden_adapt_CV(self): bw1 = 68.0 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', fixed=False).search(criterion='CV') self.assertAlmostEqual(bw1, bw2)
def test_golden_fixed_BIC(self): bw1 = 279451.43 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', fixed=True).search(criterion='BIC') self.assertAlmostEqual(bw1, bw2)
def test_golden_fixed_CV(self): bw1 = 130406.67 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', fixed=True).search(criterion='CV') self.assertAlmostEqual(bw1, bw2)
def test_golden_fixed_AICc(self): bw1 = 211027.34 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='bisquare', fixed=True).search(criterion='AICc') self.assertAlmostEqual(bw1, bw2)
def test_golden_adapt_AICc(self): bw1 = 93.0 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='bisquare', fixed=False).search(criterion='AICc') self.assertAlmostEqual(bw1, bw2)
def test_FBGWR_AIC(self): bw1 = [157.0, 65.0, 52.0] sel = Sel_BW(self.coords, self.y, self.X, fb=True, kernel='bisquare', constant=False) bw2 = sel.search(tol_fb=1e-03) np.testing.assert_allclose(bw1, bw2) np.testing.assert_allclose(sel.XB, self.XB, atol=1e-05) np.testing.assert_allclose(sel.err, self.err, atol=1e-05)
def test_interval_fixed_AICc(self): bw1 = 211025.0 #211027.00 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='bisquare', fixed=True).search(criterion='AICc', search='interval', bw_min=211001.0, bw_max=211035.0, interval=2) self.assertAlmostEqual(bw1, bw2)
def test_interval_adapt_CV(self): bw1 = 62.0 #68.0 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', fixed=False).search(criterion='CV', search='interval', bw_min=60.0, bw_max=76.0, interval=2) self.assertAlmostEqual(bw1, bw2)
def test_interval_fixed_CV(self): bw1 = 130400.0 #130406.00 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', fixed=True).search(criterion='CV', search='interval', bw_min=130400.0, bw_max=130410.0, interval=1) self.assertAlmostEqual(bw1, bw2)
def test_interval_fixed_BIC(self): bw1 = 279461.0 #279451.00 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', fixed=True).search(criterion='BIC', search='interval', bw_min=279441.0, bw_max=279461.0, interval=2) self.assertAlmostEqual(bw1, bw2)
def test_interval_fixed_AIC(self): bw1 = 76175.0 #76169.00 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', fixed=True).search(criterion='AIC', search='interval', bw_min=76161.0, bw_max=76175.0, interval=1) self.assertAlmostEqual(bw1, bw2)
def test_interval_adapt_AICc(self): bw1 = 93.0 bw2 = Sel_BW(self.coords, self.y, self.X, kernel='bisquare', fixed=False).search(criterion='AICc', search='interval', bw_min=90.0, bw_max=95.0, interval=1) self.assertAlmostEqual(bw1, bw2)
def runGWR(self): w = QtWidgets.QDialog() nd = Ui_runningDialog() nd.setupUi(w) w.show() if not self.preCheckEmptyFields(): err_msg = QtWidgets.QMessageBox.critical( None, "Error", "Please fix inputs in red!") return if not self.loadDataModel(): err_msg = QtWidgets.QMessageBox.critical( None, "Error", "Something wrong when loading variables to model. Please double check you data. No Missing values allowed." ) return self.begin_t = datetime.now() if self.isGWR: self.GLMResult = GLM(self.y, self.X).fit() print("running GWR") self.bw = Sel_BW(self.coords, self.y, self.X, kernel=self.kernel, fixed=self.fixed, constant=False) self.bw = self.bw.search(search=self.search, criterion=self.criterion) self.results = GWR(self.coords, self.y, self.X, self.bw, fixed=self.fixed, kernel=self.kernel, constant=False).fit() self.saveBetasToCSVGWR(self.results) self.end_t = datetime.now() summaryGWR(self) print("Done") msg = QtWidgets.QMessageBox.information(None, "Success", "Running complete!") """ try: ''' __init__(self, coords, y, X_loc, X_glob=None, family=Gaussian(), offset=None, kernel='bisquare', fixed=False, multi=False, constant=True) ''' bw = Sel_BW(self.coords, self.y, self.X, kernel=self.kernel, fixed=self.fixed, constant = False) ''' search(self, search='golden_section', criterion='AICc', bw_min=0.0, bw_max=0.0, interval=0.0, tol=1.0e-6, max_iter=200, init_multi=True, tol_multi=1.0e-5, rss_score=False, max_iter_multi=200) ''' bw = bw.search(search=self.search, criterion=self.criterion) self.results = GWR(self.coords, self.y, self.X, bw, fixed=self.fixed, kernel=self.kernel, constant = False).fit() self.saveBetasToCSVGWR(self.results) self.end_t = datetime.now() summaryGWR(self) except: error_dialog = QtWidgets.QErrorMessage() error_dialog.showMessage('Something went wrong when running GWR Model. Please double check your settings and data.') error_dialog.exec_() """ if self.isMGWR: if 1 == 1: print("running MGWR") self.bw = Sel_BW(self.coords, self.y, self.X, fixed=self.fixed, kernel=self.kernel, multi=True, constant=False) self.bws = self.bw.search(search='golden_section', criterion=self.criterion, tol_multi=self.tol_multi, init_multi=self.init_multi, rss_score=self.isRss_score) XB = self.bw.XB err = self.bw.err self.results = MGWR(self.coords, self.y, self.X, self.bws, XB, err, kernel=self.kernel, fixed=self.fixed, constant=False).fit() self.saveBetasToCSVMGWR(self.results) self.saveProcessToCSVMGWR() self.end_t = datetime.now() summaryMGWR(self) print("Done") msg = QtWidgets.QMessageBox.information( None, "Success", "Running complete!")