adding back filter t-vals lost in commit squash
This commit is contained in:
parent
00567e5272
commit
87890926ad
@ -1,17 +1,19 @@
|
||||
CREATE OR REPLACE FUNCTION
|
||||
CDB_GWR(subquery text, dep_var text, ind_vars text[],
|
||||
bw numeric default null, fixed boolean default False,
|
||||
kernel text default 'bisquare')
|
||||
kernel text default 'bisquare', geom_col text default 'the_geom',
|
||||
id_col text default 'cartodb_id')
|
||||
RETURNS table(coeffs JSON, stand_errs JSON, t_vals JSON,
|
||||
predicted numeric, residuals numeric, r_squared numeric,
|
||||
bandwidth numeric, rowid bigint)
|
||||
filtered_t_vals JSON, predicted numeric,
|
||||
residuals numeric, r_squared numeric, bandwidth numeric,
|
||||
rowid bigint)
|
||||
AS $$
|
||||
|
||||
from crankshaft.regression import GWR
|
||||
|
||||
gwr = GWR()
|
||||
|
||||
return gwr.gwr(subquery, dep_var, ind_vars, bw, fixed, kernel)
|
||||
return gwr.gwr(subquery, dep_var, ind_vars, bw, fixed, kernel, geom_col, id_col)
|
||||
|
||||
$$ LANGUAGE plpythonu;
|
||||
|
||||
|
@ -77,8 +77,11 @@ class GWR:
|
||||
coeffs = []
|
||||
stand_errs = []
|
||||
t_vals = []
|
||||
filtered_t_vals = []
|
||||
|
||||
# extracted model information
|
||||
c_alpha = model.adj_alpha
|
||||
filtered_t = model.filter_tvals(c_alpha[1])
|
||||
predicted = model.predy.flatten()
|
||||
residuals = model.resid_response
|
||||
r_squared = model.localR2.flatten()
|
||||
@ -92,8 +95,10 @@ class GWR:
|
||||
for k, var in enumerate(ind_vars)}))
|
||||
t_vals.append(json.dumps({var: model.tvalues[idx, k]
|
||||
for k, var in enumerate(ind_vars)}))
|
||||
filtered_t_vals.append(json.dumps({var: filtered_t[idx, k]
|
||||
for k, var in enumerate(ind_vars)}))
|
||||
|
||||
return zip(coeffs, stand_errs, t_vals,
|
||||
return zip(coeffs, stand_errs, t_vals, filtered_t_vals,
|
||||
predicted, residuals, r_squared, bw, rowid)
|
||||
|
||||
def gwr_predict(self, subquery, dep_var, ind_vars,
|
||||
|
@ -58,7 +58,7 @@ class GWRTest(unittest.TestCase):
|
||||
fixed=self.params['fixed'])
|
||||
|
||||
# unpack response
|
||||
coeffs, stand_errs, t_vals, predicteds, residuals, r_squareds, bws, rowids = zip(*gwr_resp)
|
||||
coeffs, stand_errs, t_vals, t_vals_filtered, predicteds, residuals, r_squareds, bws, rowids = zip(*gwr_resp)
|
||||
|
||||
# known_coeffs = self.knowns['coeffs']
|
||||
# data packed from https://github.com/TaylorOshan/pysal/blob/a44c5541e2e0d10a99ff05edc1b7f81b70f5a82f/pysal/examples/georgia/georgia_BS_NN_listwise.csv
|
||||
|
Loading…
Reference in New Issue
Block a user