add bandwidth column
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user