Beispiel #1
0
    def setUp(self):
        # load raw data for analysis
        self.neighbors_data = json.loads(
            open(fixture_file('neighbors_getis.json')).read())

        # load pre-computed/known values
        self.getis_data = json.loads(open(fixture_file('getis.json')).read())
    def setUp(self):
        # load raw data for analysis
        self.neighbors_data = json.loads(
          open(fixture_file('neighbors_getis.json')).read())

        # load pre-computed/known values
        self.getis_data = json.loads(
          open(fixture_file('getis.json')).read())
    def setUp(self):
        """
            fixture packed from canonical GWR georgia dataset using the
            following query:
                SELECT array_agg(x) As x,
                       array_agg(y) As y,
                       array_agg(pctbach) As dep_var,
                       array_agg(pctrural) As attr1,
                       array_agg(pctpov) As attr2,
                       array_agg(pctblack) As attr3,
                       array_agg(areakey) As rowid
                FROM g_utm
                WHERE pctbach is not NULL AND
                      pctrural IS NOT NULL AND
                      pctpov IS NOT NULL AND
                      pctblack IS NOT NULL
        """
        import copy
        # data packed from https://github.com/TaylorOshan/pysal/blob/1d6af33bda46b1d623f70912c56155064463383f/pysal/examples/georgia/GData_utm.csv
        self.data = json.loads(
            open(fixture_file('gwr_packed_data.json')).read())

        # data packed from https://github.com/TaylorOshan/pysal/blob/a44c5541e2e0d10a99ff05edc1b7f81b70f5a82f/pysal/examples/georgia/georgia_BS_NN_listwise.csv
        self.knowns = json.loads(
            open(fixture_file('gwr_packed_knowns.json')).read())

        # data for GWR prediction
        self.data_predict = copy.deepcopy(self.data)
        self.ids_of_unknowns = [13083, 13009, 13281, 13115, 13247, 13169]
        self.idx_ids_of_unknowns = [
            self.data_predict[0]['rowid'].index(idx)
            for idx in self.ids_of_unknowns
        ]

        for idx in self.idx_ids_of_unknowns:
            self.data_predict[0]['dep_var'][idx] = None

        self.predicted_knowns = {
            13009: 10.879,
            13083: 4.5259,
            13115: 9.4022,
            13169: 6.0793,
            13247: 8.1608,
            13281: 13.886
        }

        # params, with ind_vars in same ordering as query above
        self.params = {
            'subquery': 'select * from table',
            'dep_var': 'pctbach',
            'ind_vars': ['pctrural', 'pctpov', 'pctblack'],
            'bw': 90.000,
            'fixed': False,
            'geom_col': 'the_geom',
            'id_col': 'areakey'
        }
Beispiel #4
0
 def setUp(self):
     plpy._reset()
     self.params = {"id_col": "cartodb_id",
                    "attr1": "andy",
                    "attr2": "jay_z",
                    "table": "a_list",
                    "geom_col": "the_geom",
                    "num_ngbrs": 321}
     self.neighbors_data = json.loads(open(fixture_file('neighbors.json')).read())
     self.moran_data = json.loads(open(fixture_file('moran.json')).read())
Beispiel #5
0
 def setUp(self):
     plpy._reset()
     self.params = {"id_col": "cartodb_id",
                    "attr1": "andy",
                    "attr2": "jay_z",
                    "subquery": "SELECT * FROM a_list",
                    "geom_col": "the_geom",
                    "num_ngbrs": 321}
     self.params_markov = {"id_col": "cartodb_id",
                           "time_cols": ["_2013_dec", "_2014_jan", "_2014_feb"],
                           "subquery": "SELECT * FROM a_list",
                           "geom_col": "the_geom",
                           "num_ngbrs": 321}
     self.neighbors_data = json.loads(open(fixture_file('neighbors.json')).read())
     self.moran_data = json.loads(open(fixture_file('moran.json')).read())
 def setUp(self):
     self.params = {
         "id_col": "cartodb_id",
         "attr1": "andy",
         "attr2": "jay_z",
         "subquery": "SELECT * FROM a_list",
         "geom_col": "the_geom",
         "num_ngbrs": 321,
     }
     self.params_markov = {
         "id_col": "cartodb_id",
         "time_cols": ["_2013_dec", "_2014_jan", "_2014_feb"],
         "subquery": "SELECT * FROM a_list",
         "geom_col": "the_geom",
         "num_ngbrs": 321,
     }
     self.neighbors_data = json.loads(open(fixture_file("neighbors.json")).read())
     self.moran_data = json.loads(open(fixture_file("moran.json")).read())
Beispiel #7
0
    def setUp(self):
        plpy._reset()
        self.params = {
            "id_col": "cartodb_id",
            "time_cols": ['dec_2013', 'jan_2014', 'feb_2014'],
            "subquery": "SELECT * FROM a_list",
            "geom_col": "the_geom",
            "num_ngbrs": 321
        }
        self.neighbors_data = json.loads(
            open(fixture_file('neighbors_markov.json')).read())
        self.markov_data = json.loads(open(fixture_file('markov.json')).read())

        self.time_data = np.array(
            [i * np.ones(10, dtype=float) for i in range(10)]).T

        self.transition_matrix = np.array(
            [[[0.96341463, 0.0304878, 0.00609756, 0., 0.],
              [0.06040268, 0.83221477, 0.10738255, 0., 0.],
              [0., 0.14, 0.74, 0.12, 0.],
              [0., 0.03571429, 0.32142857, 0.57142857, 0.07142857],
              [0., 0., 0., 0.16666667, 0.83333333]],
             [[0.79831933, 0.16806723, 0.03361345, 0., 0.],
              [0.0754717, 0.88207547, 0.04245283, 0., 0.],
              [0.00537634, 0.06989247, 0.8655914, 0.05913978, 0.],
              [0., 0., 0.06372549, 0.90196078, 0.03431373],
              [0., 0., 0., 0.19444444, 0.80555556]],
             [[0.84693878, 0.15306122, 0., 0., 0.],
              [0.08133971, 0.78947368, 0.1291866, 0., 0.],
              [0.00518135, 0.0984456, 0.79274611, 0.0984456, 0.00518135],
              [0., 0., 0.09411765, 0.87058824, 0.03529412],
              [0., 0., 0., 0.10204082, 0.89795918]],
             [[0.8852459, 0.09836066, 0., 0.01639344, 0.],
              [0.03875969, 0.81395349, 0.13953488, 0., 0.00775194],
              [0.0049505, 0.09405941, 0.77722772, 0.11881188, 0.0049505],
              [0., 0.02339181, 0.12865497, 0.75438596, 0.09356725],
              [0., 0., 0., 0.09661836, 0.90338164]],
             [[0.33333333, 0.66666667, 0., 0., 0.],
              [0.0483871, 0.77419355, 0.16129032, 0.01612903, 0.],
              [0.01149425, 0.16091954, 0.74712644, 0.08045977, 0.],
              [0., 0.01036269, 0.06217617, 0.89637306, 0.03108808],
              [0., 0., 0., 0.02352941, 0.97647059]]])
    def setUp(self):
        self.params = {"id_col": "cartodb_id",
                       "time_cols": ['dec_2013', 'jan_2014', 'feb_2014'],
                       "subquery": "SELECT * FROM a_list",
                       "geom_col": "the_geom",
                       "num_ngbrs": 321}
        self.neighbors_data = json.loads(
          open(fixture_file('neighbors_markov.json')).read())
        self.markov_data = json.loads(open(fixture_file('markov.json')).read())

        self.time_data = np.array([i * np.ones(10, dtype=float)
                                   for i in range(10)]).T

        self.transition_matrix = np.array([
                [[0.96341463, 0.0304878, 0.00609756, 0., 0.],
                 [0.06040268, 0.83221477, 0.10738255, 0., 0.],
                 [0., 0.14, 0.74, 0.12, 0.],
                 [0., 0.03571429, 0.32142857, 0.57142857, 0.07142857],
                 [0., 0., 0., 0.16666667, 0.83333333]],
                [[0.79831933, 0.16806723, 0.03361345, 0., 0.],
                 [0.0754717, 0.88207547, 0.04245283, 0., 0.],
                 [0.00537634, 0.06989247, 0.8655914, 0.05913978, 0.],
                 [0., 0., 0.06372549, 0.90196078, 0.03431373],
                 [0., 0., 0., 0.19444444, 0.80555556]],
                [[0.84693878, 0.15306122, 0., 0., 0.],
                 [0.08133971, 0.78947368, 0.1291866, 0., 0.],
                 [0.00518135, 0.0984456, 0.79274611, 0.0984456, 0.00518135],
                 [0., 0., 0.09411765, 0.87058824, 0.03529412],
                 [0., 0., 0., 0.10204082, 0.89795918]],
                [[0.8852459, 0.09836066, 0., 0.01639344, 0.],
                 [0.03875969, 0.81395349, 0.13953488, 0., 0.00775194],
                 [0.0049505, 0.09405941, 0.77722772, 0.11881188, 0.0049505],
                 [0., 0.02339181, 0.12865497, 0.75438596, 0.09356725],
                 [0., 0., 0., 0.09661836, 0.90338164]],
                [[0.33333333, 0.66666667, 0., 0., 0.],
                 [0.0483871, 0.77419355, 0.16129032, 0.01612903, 0.],
                 [0.01149425, 0.16091954, 0.74712644, 0.08045977, 0.],
                 [0., 0.01036269, 0.06217617, 0.89637306, 0.03108808],
                 [0., 0., 0., 0.02352941, 0.97647059]]]
                 )
Beispiel #9
0
 def setUp(self):
     self.params = {
         "query": 'SELECT * FROM segmentation_data',
         "variable": 'price',
         "feature_columns": ['m1', 'm2', 'm3', 'm4', 'm5', 'm6'],
         "target_query": 'SELECT * FROM segmentation_result',
         "id_col": 'cartodb_id',
         "model_params": {
             'n_estimators': 1200,
             'max_depth': 3,
             'subsample': 0.5,
             'learning_rate': 0.01,
             'min_samples_leaf': 1
         }
     }
     self.model_data = json.loads(
         open(fixture_file('model_data.json')).read())
     self.data = json.loads(open(fixture_file('data.json')).read())
     self.predict_data = json.loads(
         open(fixture_file('predict_data.json')).read())
     self.result_seg = json.loads(
         open(fixture_file('segmentation_result.json')).read())
     self.true_result = json.loads(
         open(fixture_file('true_result.json')).read())
Beispiel #10
0
 def setUp(self):
     self.cluster_data = json.loads(
         open(fixture_file('kmeans.json')).read())
     self.params = {"subquery": "select * from table", "no_clusters": "10"}
 def setUp(self):
     plpy._reset()
     self.cluster_data = json.loads(open(fixture_file('kmeans.json')).read())
     self.params = {"subquery": "select * from table",
                    "no_clusters": "10"
                    }