rename queryrunner to analysisdataprovider
This commit is contained in:
parent
c27ec58948
commit
280a5193ef
@ -3,4 +3,4 @@ import crankshaft.random_seeds
|
||||
import crankshaft.clustering
|
||||
import crankshaft.space_time_dynamics
|
||||
import crankshaft.segmentation
|
||||
import query_runner
|
||||
import analysis_data_provider
|
||||
|
@ -2,7 +2,7 @@
|
||||
import plpy
|
||||
|
||||
|
||||
class QueryRunner:
|
||||
class AnalysisDataProvider:
|
||||
def get_markov(self, query):
|
||||
try:
|
||||
data = plpy.execute(query)
|
@ -1,15 +1,15 @@
|
||||
from sklearn.cluster import KMeans
|
||||
import numpy as np
|
||||
|
||||
from crankshaft.query_runner import QueryRunner
|
||||
from crankshaft.analysis_data_provider import AnalysisDataProvider
|
||||
|
||||
|
||||
class Kmeans:
|
||||
def __init__(self, query_runner=None):
|
||||
if query_runner is None:
|
||||
self.query_runner = QueryRunner()
|
||||
def __init__(self, data_provider=None):
|
||||
if data_provider is None:
|
||||
self.data_provider = AnalysisDataProvider()
|
||||
else:
|
||||
self.query_runner = query_runner
|
||||
self.data_provider = data_provider
|
||||
|
||||
def spatial(self, query, no_clusters, no_init=20):
|
||||
"""
|
||||
@ -23,7 +23,7 @@ class Kmeans:
|
||||
"FROM ({query}) As a "
|
||||
"WHERE the_geom IS NOT NULL").format(query=query)
|
||||
|
||||
data = self.query_runner.get_spatial_kmeans(full_query)
|
||||
data = self.data_provider.get_spatial_kmeans(full_query)
|
||||
|
||||
# Unpack query response
|
||||
xs = data[0]['xs']
|
||||
|
@ -8,7 +8,7 @@ Moran's I geostatistics (global clustering & outliers presence)
|
||||
import pysal as ps
|
||||
import plpy
|
||||
from collections import OrderedDict
|
||||
from crankshaft.query_runner import QueryRunner
|
||||
from crankshaft.analysis_data_provider import AnalysisDataProvider
|
||||
|
||||
# crankshaft module
|
||||
import crankshaft.pysal_utils as pu
|
||||
@ -17,11 +17,11 @@ import crankshaft.pysal_utils as pu
|
||||
|
||||
|
||||
class Moran:
|
||||
def __init__(self, query_runner=None):
|
||||
if query_runner is None:
|
||||
self.query_runner = QueryRunner()
|
||||
def __init__(self, data_provider=None):
|
||||
if data_provider is None:
|
||||
self.data_provider = AnalysisDataProvider()
|
||||
else:
|
||||
self.query_runner = query_runner
|
||||
self.data_provider = data_provider
|
||||
|
||||
def global_stat(self, subquery, attr_name,
|
||||
w_type, num_ngbrs, permutations, geom_col, id_col):
|
||||
@ -39,7 +39,7 @@ class Moran:
|
||||
|
||||
query = pu.construct_neighbor_query(w_type, qvals)
|
||||
|
||||
result = self.query_runner.get_moran(query)
|
||||
result = self.data_provider.get_moran(query)
|
||||
|
||||
# collect attributes
|
||||
attr_vals = pu.get_attributes(result)
|
||||
@ -71,7 +71,7 @@ class Moran:
|
||||
|
||||
query = pu.construct_neighbor_query(w_type, qvals)
|
||||
|
||||
result = self.query_runner.get_moran(query)
|
||||
result = self.data_provider.get_moran(query)
|
||||
|
||||
attr_vals = pu.get_attributes(result)
|
||||
weight = pu.get_weight(result, w_type, num_ngbrs)
|
||||
@ -100,7 +100,7 @@ class Moran:
|
||||
|
||||
query = pu.construct_neighbor_query(w_type, qvals)
|
||||
|
||||
result = self.query_runner.get_moran(query)
|
||||
result = self.data_provider.get_moran(query)
|
||||
|
||||
# collect attributes
|
||||
numer = pu.get_attributes(result, 1)
|
||||
@ -132,7 +132,7 @@ class Moran:
|
||||
|
||||
query = pu.construct_neighbor_query(w_type, qvals)
|
||||
|
||||
result = self.query_runner.get_moran(query)
|
||||
result = self.data_provider.get_moran(query)
|
||||
|
||||
# collect attributes
|
||||
numer = pu.get_attributes(result, 1)
|
||||
@ -165,7 +165,7 @@ class Moran:
|
||||
|
||||
query = pu.construct_neighbor_query(w_type, qvals)
|
||||
|
||||
result = self.query_runner.get_moran(query)
|
||||
result = self.data_provider.get_moran(query)
|
||||
|
||||
# collect attributes
|
||||
attr1_vals = pu.get_attributes(result, 1)
|
||||
|
@ -7,15 +7,15 @@ import numpy as np
|
||||
import pysal as ps
|
||||
import plpy
|
||||
import crankshaft.pysal_utils as pu
|
||||
from crankshaft.query_runner import QueryRunner
|
||||
from crankshaft.analysis_data_provider import AnalysisDataProvider
|
||||
|
||||
|
||||
class Markov:
|
||||
def __init__(self, query_runner=None):
|
||||
if query_runner is None:
|
||||
self.query_runner = QueryRunner()
|
||||
def __init__(self, data_provider=None):
|
||||
if data_provider is None:
|
||||
self.data_provider = AnalysisDataProvider()
|
||||
else:
|
||||
self.query_runner = query_runner
|
||||
self.data_provider = data_provider
|
||||
|
||||
def spatial_trend(self, subquery, time_cols, num_classes=7,
|
||||
w_type='knn', num_ngbrs=5, permutations=0,
|
||||
@ -62,7 +62,7 @@ class Markov:
|
||||
|
||||
query = pu.construct_neighbor_query(w_type, qvals)
|
||||
|
||||
query_result = self.query_runner.get_markov(query)
|
||||
query_result = self.data_provider.get_markov(query)
|
||||
|
||||
# build weight
|
||||
weights = pu.get_weight(query_result, w_type)
|
||||
|
Loading…
Reference in New Issue
Block a user