<jupyter_start><jupyter_text>`mgwr`  Adaptive Bisquare Kernel<jupyter_code>%%time
#Bandwidth searching
opt_bw_adap = Sel_BW(coords,y,X).search(verbose=True)
print("Optimal Bandwidth:",opt_bw_adap)

#Fitting the model with optimal bandwidth
pysal_result_adap=GWR(coords,y,X,opt_bw_adap).fit()
%%time
#Bandwidth searching
opt_bw_fixed = Sel_BW(coords,y,X,fixed=True,kernel="gaussian").search(verbose=True)
print("Optimal Bandwidth:",opt_bw_fixed)

#Fitting the model with optimal bandwidth
pysal_result_fixed=GWR(coords,y,X,opt_bw_fixed,fixed=True,kernel="gaussian").fit()<jupyter_output>Bandwidth:  85088.9 , score:  63401.59
Bandwidth:  137674.41 , score:  63412.23
Bandwidth:  52587.49 , score:  63376.05
Bandwidth:  32501.41 , score:  63319.11
Bandwidth:  20086.84 , score:  63189.10
Bandwidth:  12414.56 , score:  62823.09
Bandwidth:  7672.57 , score:  62284.31
Bandwidth:  4741.99 , score:  61925.83
Bandwidth:  2930.69 , score:  61529.61
Bandwidth:  1811.3 , score:  61093.24
Bandwidth:  1119.44 , score:  61264.26
Bandwidth:  2238.85 , score:  61276.52
Bandwidth:  1547.02 , score:  61014.93
Bandwidth:  1383.71 , score:  61028.14
Bandwidth:  1647.97 , score:  61035.32
Bandwidth:  1484.65 , score:  61012.03
Bandwidth:  1446.09 , score:  61014.87
Bandwidth:  1508.47 , score:  61012.11
Bandwidth:  1469.91 , score:  61012.67
Bandwidth:  1493.74 , score:  61011.91
Bandwidth:  1499.37 , score:  61011.93
Bandwidth:  1490.27 , score:  61011.93
Bandwidth:  1495.89 , score:  61011.91
Bandwidth:  1497.22 , score:  61011.91
Bandwidth:  1495.07 , score:  61011.90
Bandwidth:  1494.56 [...]<jupyter_text>FastGWR  Adaptive Kernel<jupyter_code>#Running FastGWR 1 Processor with auto bandwidth search
!fastgwr run -np 1 -data Zillow-test-dataset/zillow_5k.csv -out results_adap.csv -adaptive -constant
#Running FastGWR 4 Processor
!fastgwr run -np 4 -data Zillow-test-dataset/zillow_5k.csv -out results_adap.csv -adaptive -constant<jupyter_output>------------------------------------------------------------
Starting FastGWR with 4 Processors
Spatial Kernel: Adaptive Bisquare
Data Input Path: Zillow-test-dataset/zillow_5k.csv
Output Result Path: results_adap.csv
Constant: True
Optimal Bandwidth Searching...
Range: 50 5000
BW, AICc 1941.0 62998.99119669126
BW, AICc 3109.0 63155.33894463484
BW, AICc 1218.0 62834.63981029017
BW, AICc 772.0 62623.874889689614
BW, AICc 496.0 62394.91059361154
BW, AICc 326.0 62176.772952292216
BW, AICc 220.0 62010.240832793184
BW, AICc 155.0 61900.34904388847
BW, AICc 115.0 61877.920735056185
BW, AICc 90.0 61928.281301868104
BW, AICc 130.0 61872.717591247
BW, AICc 140.0 61880.08193188456
BW, AICc 125.0 61868.40676858913
BW, AICc 121.0 61867.18296256346
BW, AICc 119.0 61869.75993130282
BW, AICc 123.0 61868.11546142208
Fitting GWR Using Bandwidth: 121.0
Diagnostic Information:
AICc: 61867.18296256346
ENP: 528.2622212380004
R2: 0.7741417970962883
Total Time Elapsed: 12.28 seconds
-------------------------[...]<jupyter_text>Fixed Gaussian kernel<jupyter_code>#Running FastGWR 4 Processor
!fastgwr run -np 4 -data Zillow-test-dataset/zillow_5k.csv -out results_fixed.csv -fixed -constant<jupyter_output>------------------------------------------------------------
Starting FastGWR with 4 Processors
Spatial Kernel: Fixed Gaussian
Data Input Path: Zillow-test-dataset/zillow_5k.csv
Output Result Path: results_fixed.csv
Constant: True
Optimal Bandwidth Searching...
Range: 0.0 222763.307902534
BW, AICc 85088.90071953091 63401.587701945275
BW, AICc 137674.4071830031 63412.23473987967
BW, AICc 52587.49331169169 63376.049939236196
BW, AICc 32501.40740783922 63319.11111531032
BW, AICc 20086.844820266873 63189.09679320165
BW, AICc 12414.562587572345 62823.090184067856
BW, AICc 7672.572115997337 62284.30873222015
BW, AICc 4741.990471575008 61925.82638349446
BW, AICc 2930.692371147503 61529.608314945304
BW, AICc 1811.2981004275057 61093.23641471484
BW, AICc 1119.4365650072116 61264.25581814983
BW, AICc 2238.846990876096 61276.52126845023
BW, AICc 1547.0177653763492 61014.93422823765
BW, AICc 1383.7069156917014 61028.14490111669
BW, AICc 1647.9710955939706 61035.3151728618
BW, AICc 1484.64790448897[...]<jupyter_text>Results validation<jupyter_code>print("Adaptive kernel: pysal AICc - ", pysal_result_adap.aicc)
print("Adaptive kernel: pysal R2 - ",pysal_result_adap.R2)

print("Fixed kernel: pysal AICc - ", pysal_result_fixed.aicc)
print("Fixed kernel: pysal R2 - ",pysal_result_fixed.R2)
fastGWR_result_fixed = pd.read_csv("results_fixed.csv")
fastGWR_result_adap = pd.read_csv("results_adap.csv")
fastGWR_result_adap.head()
#Validate model residual
print(np.allclose(fastGWR_result_fixed.residual,pysal_result_fixed.resid_response.reshape(-1)))
print(np.allclose(fastGWR_result_adap.residual,pysal_result_adap.resid_response.reshape(-1)))
#Validate parameter estimates
print(np.allclose(np.array(fastGWR_result_fixed.iloc[:,3:8]),pysal_result_fixed.params))
print(np.allclose(np.array(fastGWR_result_adap.iloc[:,3:8]),pysal_result_adap.params))
#Validate parameter estimates standard errors
print(np.allclose(np.array(fastGWR_result_adap.iloc[:,8:13]),pysal_result_adap.bse))
print(np.allclose(np.array(fastGWR_result_fixed.iloc[:,8:13]),pysal_result_fixed.bse))<jupyter_output>True
True
{'fraction_non_alphanumeric': 0.1323529411764706, 'fraction_numerical': 0.24369747899159663, 'mean_word_length': 4.985142857142857, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '73158', 'license': 'MIT', 'n_tokens_mistral': 2964, 'n_tokens_neox': 2145, 'n_words': 420, 'path': 'validation notebook/GWR Results Validation against mgwr.ipynb', 'repo_name': 'alexandermichels/FastGWR', 'size': '5236'}