add bandwidth column

This commit is contained in:
Taylor Oshan
2016-11-29 13:22:42 -07:00
parent f4ccfe712b
commit 22ce970062
2 changed files with 4 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
CREATE OR REPLACE FUNCTION
CDB_GWR(subquery text, dep_var text, ind_vars text[],
fixed boolean default False, kernel text default 'bisquare')
RETURNS table(coeffs JSON, stand_errs JSON, t_vals JSON, predicted numeric, residuals numeric, r_squared numeric, rowid bigint)
RETURNS table(coeffs JSON, stand_errs JSON, t_vals JSON, predicted numeric, residuals numeric, r_squared numeric, rowid bigint, bandwidth numeric)
AS $$
from crankshaft.regression import gwr_cs

View File

@@ -72,6 +72,7 @@ def gwr(subquery, dep_var, ind_vars,
predicted = model.predy.flatten()
residuals = model.resid_response
r_squared = model.localR2.flatten()
bw = np.repeat(bw, n)
for idx in xrange(n):
coefficients.append(json.dumps({var: model.params[idx, k]
@@ -82,6 +83,6 @@ def gwr(subquery, dep_var, ind_vars,
for k, var in enumerate(ind_vars)}))
plpy.notice(str(zip(coefficients, stand_errs, t_vals,
predicted, residuals, r_squared, rowid)))
predicted, residuals, r_squared, rowid, bw)))
return zip(coefficients, stand_errs, t_vals,
predicted, residuals, r_squared, rowid)
predicted, residuals, r_squared, rowid, bw)