aligning parameters for fistures and tests
This commit is contained in:
parent
dcb364c3ee
commit
eff548dec9
@ -6,8 +6,9 @@
|
|||||||
SELECT cdb_crankshaft._cdb_random_seeds(1234);
|
SELECT cdb_crankshaft._cdb_random_seeds(1234);
|
||||||
|
|
||||||
-- test against PySAL example dataset
|
-- test against PySAL example dataset
|
||||||
SELECT z_score, p_val
|
SELECT z_score, p_value
|
||||||
FROM cdb_crankshaft.CDB_GetisOrdsG(
|
FROM cdb_crankshaft.CDB_GetisOrdsG(
|
||||||
'select * from ppoints2',
|
'select * from getis_data',
|
||||||
'ratio') As cdb_getisordsg(z_score, p_val, p_z_sim)
|
'hr8893', 'knn', 5, 999,
|
||||||
WHERE p_val <= 0.05;
|
'the_geom', 'cartodb_id') As cdb_getisordsg(z_score, p_value, p_z_sim)
|
||||||
|
WHERE p_value <= 0.05;
|
||||||
|
79
src/py/crankshaft/test/fixtures/getis.json
vendored
79
src/py/crankshaft/test/fixtures/getis.json
vendored
@ -1,78 +1 @@
|
|||||||
[[-0.37378594228210338, 0.436, 0.35428178954558454],
|
[[-0.37337341596824414, 0.43099999999999999, 0.35443527112672846], [-0.95217153199599269, 0.091999999999999998, 0.17050499804382691], [-0.69132084390888426, 0.30299999999999999, 0.24468196785399454], [-0.90994823039851658, 0.088999999999999996, 0.18142490623820451], [-1.0132361542216282, 0.129, 0.15547368761207747], [-0.51678782422627401, 0.058999999999999997, 0.30265214024759912], [-0.59887100659663139, 0.13400000000000001, 0.27462945349842682], [-0.65244852117509244, 0.32900000000000001, 0.2570559358979031], [-1.0357808174963727, 0.0070000000000000001, 0.1501522043425858], [-0.77003625124250874, 0.13600000000000001, 0.22063919456432224], [-0.33236541712916268, 0.375, 0.3698066743983055], [-0.16566702930134228, 0.28699999999999998, 0.43420949712949208], [-1.0188721243221961, 0.113, 0.15413183958086896], [-0.58707183737030266, 0.40100000000000002, 0.27857773047946677], [-0.60787539226595488, 0.34100000000000003, 0.27163506072349475], [-0.8363954400004282, 0.20599999999999999, 0.2014662385347713], [-0.27576758055135975, 0.49399999999999999, 0.39136329273990866], [-0.17698658238285753, 0.38100000000000001, 0.42975946445365665], [-0.42301422073305678, 0.48599999999999999, 0.33614244280579275], [-0.81073978385996837, 0.161, 0.20875756070128504], [-0.63838151273605281, 0.107, 0.26161268117180692], [-0.64010006015388854, 0.0040000000000000001, 0.26105377495417703], [-0.62182425813185527, 0.22700000000000001, 0.2670287167605806], [2.6823577629697111, 0.014, 0.0036552616083728173], [-0.53272604021530889, 0.39400000000000002, 0.29711161877609882], [-0.15271881679589203, 0.34699999999999998, 0.43931001058875374], [-0.46563636027021654, 0.48499999999999999, 0.32073790602545205], [-0.67304141220538694, 0.32200000000000001, 0.25046047260054227], [-0.65348653890355268, 0.27000000000000002, 0.25672133238529804], [-0.042046555130192398, 0.36199999999999999, 0.48323079264157687], [-0.50234667391554988, 0.39400000000000002, 0.30771184147044006], [0.20134863894573138, 0.41199999999999998, 0.42021298643169991], [4.7562332747386709, 0.001, 9.8619270438859985e-07], [-0.17060076279397593, 0.44400000000000001, 0.43226884904800156], [2.7291423642735309, 0.02, 0.0031749642026865921], [-1.244478534224277, 0.036999999999999998, 0.10666174742715517], [2.6167445805079668, 0.045999999999999999, 0.0044386370442521805], [-0.81072889481557631, 0.20799999999999999, 0.20876068801239311], [-0.96834418270546307, 0.049000000000000002, 0.16643625291733932], [4.6354616023251367, 0.017000000000000001, 1.7807091640120731e-06], [1.711490849677441, 0.058999999999999997, 0.043495269461387376], [-0.68553064793121166, 0.317, 0.24650456386912545], [-0.10649304409706747, 0.44, 0.45759558701679381], [-0.54248639601227799, 0.29299999999999998, 0.29374173830183614], [0.031677897850072946, 0.311, 0.48736446049996618], [4.5356561799411086, 0.019, 2.8712332330593782e-06], [-1.3116013794941181, 0.01, 0.094827333672427794], [-1.3116013794941181, 0.0089999999999999993, 0.094827333672427794], [4.6393788826674198, 0.002, 1.7472893316661242e-06], [1.4382028801285995, 0.090999999999999998, 0.07518824913828126], [2.8328951008347012, 0.033000000000000002, 0.0023064260400579295], [-0.26084695643627254, 0.46500000000000002, 0.39710526578910033], [-0.78037465160516584, 0.122, 0.21758519184573832], [-0.64208684814893169, 0.307, 0.2604083973990674], [-1.3116013794941181, 0.001, 0.094827333672427794], [-0.57288206029351252, 0.314, 0.28336227604534636], [1.4616922569671136, 0.10000000000000001, 0.071912780017027833], [-0.10796036062141957, 0.38200000000000001, 0.45701356800520454], [0.25084361591996374, 0.29299999999999998, 0.40096750937264047], [-0.15481933481013774, 0.34699999999999998, 0.43848187401104366], [-0.15333330051666849, 0.35699999999999998, 0.43906772057781862], [-0.23163022692856874, 0.41699999999999998, 0.40841261410676866], [-0.34288722316108555, 0.28399999999999997, 0.36584165208609076], [-0.21867005782535454, 0.38200000000000001, 0.41345353745151792], [-0.79939347077393408, 0.215, 0.21203114760123465], [-0.57405515910861116, 0.19800000000000001, 0.28296523788747729], [0.17162418105442584, 0.151, 0.43186649789407894], [-0.45034522396490928, 0.435, 0.3262307674101308], [0.76919536546476719, 0.122, 0.22088867064513418], [0.43251102361572391, 0.14999999999999999, 0.33268502099692632], [0.37645002404345906, 0.155, 0.3532911812599], [-0.34984866752801247, 0.47699999999999998, 0.36322613637735446], [-0.48122747907298502, 0.439, 0.31517741642583419], [0.8295949731100305, 0.16700000000000001, 0.20338390993964683], [0.32735658947745261, 0.24399999999999999, 0.37169909789396838], [-0.30762465422828866, 0.47899999999999998, 0.37918397900139522], [0.50459229844619902, 0.14399999999999999, 0.30692261012051003], [0.7555990768924421, 0.14999999999999999, 0.22494480477952961]]
|
||||||
[-0.95225687055925445, 0.065000000000000002, 0.17048336261993491],
|
|
||||||
[-0.69155363829052829, 0.313, 0.2446088425605718],
|
|
||||||
[-0.91005743729633215, 0.085999999999999993, 0.18139610975939735],
|
|
||||||
[-1.0132869736739361, 0.13200000000000001, 0.1554615538579156],
|
|
||||||
[-0.51711928006609076, 0.058999999999999997, 0.30253644777604194],
|
|
||||||
[-0.59915606178126646, 0.125, 0.27453440990643974],
|
|
||||||
[-0.65270328962244883, 0.314, 0.25697379065855031],
|
|
||||||
[-1.035818892716347, 0.016, 0.15014332094164029],
|
|
||||||
[-0.77022454873249124, 0.14899999999999999, 0.22058335212423197],
|
|
||||||
[-0.33280112478125556, 0.40500000000000003, 0.36964220456990138],
|
|
||||||
[-0.16619696958659569, 0.28000000000000003, 0.43400097210156352],
|
|
||||||
[-1.0189197578270577, 0.114, 0.15412053143437432],
|
|
||||||
[-0.58736356248618182, 0.378, 0.27847978008948393],
|
|
||||||
[-0.60815535737753856, 0.34699999999999998, 0.27154222002447759],
|
|
||||||
[-0.83654622542342216, 0.22, 0.20142384153812443],
|
|
||||||
[-0.27623528229314609, 0.48099999999999998, 0.39118367986278957],
|
|
||||||
[-0.17751012385821857, 0.40600000000000003, 0.42955385691066428],
|
|
||||||
[-0.42339868568527872, 0.499, 0.33600220182364238],
|
|
||||||
[-0.81090507212288232, 0.17000000000000001, 0.2087100936430748],
|
|
||||||
[-0.63864423309742102, 0.089999999999999997, 0.26152719947142589],
|
|
||||||
[-0.64036180904066409, 0.0070000000000000001, 0.2609687028452613],
|
|
||||||
[-0.62209633811403076, 0.217, 0.26693926135549806],
|
|
||||||
[2.6802178678493869, 0.019, 0.0036787128295844296],
|
|
||||||
[-0.53304848636954871, 0.314, 0.29700000849115427],
|
|
||||||
[-0.15325607655300719, 0.33900000000000002, 0.43909816861874729],
|
|
||||||
[-0.46599673142949988, 0.5, 0.32060892008190012],
|
|
||||||
[-0.67328453973424696, 0.34000000000000002, 0.25038314326507338],
|
|
||||||
[-0.65374072057172605, 0.27300000000000002, 0.25663943186717253],
|
|
||||||
[-0.042646376611931783, 0.33900000000000002, 0.48299171295314569],
|
|
||||||
[-0.50268629316736713, 0.36899999999999999, 0.30759242403716802],
|
|
||||||
[0.20061122903056294, 0.41199999999999998, 0.42050128853782709],
|
|
||||||
[4.7529210422438366, 0.002, 1.0024933114749501e-06],
|
|
||||||
[-0.17112791409785774, 0.45500000000000002, 0.43206159366732011],
|
|
||||||
[2.7269760223697093, 0.025000000000000001, 0.0031958841790815651],
|
|
||||||
[-1.2443986350856617, 0.023, 0.1066764425086173],
|
|
||||||
[2.6146417757460672, 0.058999999999999997, 0.0044660540776073621],
|
|
||||||
[-0.81089418923393874, 0.217, 0.20871321876749027],
|
|
||||||
[-0.96842037905996448, 0.051999999999999998, 0.16641723288102916],
|
|
||||||
[4.632217640632744, 0.014999999999999999, 1.8088477418132243e-06],
|
|
||||||
[1.7098997741760702, 0.066000000000000003, 0.043642204110986293],
|
|
||||||
[-0.68576671544237189, 0.30399999999999999, 0.24643011428027894],
|
|
||||||
[-0.10705643473845843, 0.46100000000000002, 0.45737210425657626],
|
|
||||||
[-0.54280332475246651, 0.29499999999999998, 0.29363261191793877],
|
|
||||||
[0.031036400804321389, 0.26000000000000001, 0.48762025500133288],
|
|
||||||
[4.5324686370772209, 0.021999999999999999, 2.9149167000142029e-06],
|
|
||||||
[-1.3114835366024926, 0.0089999999999999993, 0.09484722615634944],
|
|
||||||
[-1.3114835366024926, 0.0080000000000000002, 0.09484722615634944],
|
|
||||||
[4.6361327065826368, 0.001, 1.7749405375466765e-06],
|
|
||||||
[1.4367662910941781, 0.081000000000000003, 0.075392205783569644],
|
|
||||||
[2.8306701087322108, 0.031, 0.0023225301610166893],
|
|
||||||
[-0.26132309263094761, 0.47599999999999998, 0.39692167988511706],
|
|
||||||
[-0.78055710491931951, 0.13400000000000001, 0.21753151443265129],
|
|
||||||
[-0.64234747392787916, 0.33300000000000002, 0.26032379813179585],
|
|
||||||
[-1.3114835366024926, 0.002, 0.09484722615634944],
|
|
||||||
[-0.57318180672306673, 0.26400000000000001, 0.28326080073223758],
|
|
||||||
[1.4602423896649199, 0.085999999999999993, 0.072111734510341252],
|
|
||||||
[-0.10852292180607989, 0.33700000000000002, 0.45679044945885094],
|
|
||||||
[0.25007822707788863, 0.25800000000000001, 0.4012634266959908],
|
|
||||||
[-0.15535540716918589, 0.36799999999999999, 0.43827056859443592],
|
|
||||||
[-0.15387021291338146, 0.34300000000000003, 0.43885603550771368],
|
|
||||||
[-0.23212287899595097, 0.434, 0.40822128763053078],
|
|
||||||
[-0.34331698296028734, 0.255, 0.36568000291448455],
|
|
||||||
[-0.21917003612352226, 0.38300000000000001, 0.41325879787572739],
|
|
||||||
[-0.79956517297385543, 0.20000000000000001, 0.21198138620767248],
|
|
||||||
[-0.57435424239923683, 0.20100000000000001, 0.28286405516217616],
|
|
||||||
[0.17090357402483336, 0.17599999999999999, 0.43214979317279412],
|
|
||||||
[-0.45071423902325392, 0.39500000000000002, 0.32609775926146312],
|
|
||||||
[0.76813695849036678, 0.16500000000000001, 0.22120291089357114],
|
|
||||||
[0.43164294033005113, 0.14899999999999999, 0.33300047214912831],
|
|
||||||
[0.3756136313798501, 0.16, 0.35360207763890095],
|
|
||||||
[-0.35027449210479344, 0.47599999999999998, 0.36306635326063197],
|
|
||||||
[-0.48157903675663827, 0.45500000000000002, 0.31505251051764338],
|
|
||||||
[0.82850242294957743, 0.187, 0.20369301166122333],
|
|
||||||
[0.32654794875356141, 0.23599999999999999, 0.3720049088953894],
|
|
||||||
[-0.30807434754194035, 0.497, 0.37901288012280243],
|
|
||||||
[0.50368346846574807, 0.159, 0.30724191359295261],
|
|
||||||
[0.75454835573966283, 0.13500000000000001, 0.22526001043744448]]
|
|
||||||
|
@ -14,6 +14,25 @@ import crankshaft.pysal_utils as pu
|
|||||||
from crankshaft import random_seeds
|
from crankshaft import random_seeds
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
# Fixture files produced as follows
|
||||||
|
#
|
||||||
|
# import pysal as ps
|
||||||
|
# import numpy as np
|
||||||
|
# f = ps.open(ps.examples.get_path("stl_hom.txt"))
|
||||||
|
# y = np.array(f.by_col['HR8893'])
|
||||||
|
# w = ps.knnW_from_shapefile(ps.examples.get_path("stl_hom.shp"), k=5)
|
||||||
|
#
|
||||||
|
# out = [{"id": index, "neighbors": w.neighbors[index], "value": val}
|
||||||
|
# for index, val in enumerate(y)]
|
||||||
|
# with open('neighbors_getis.json', 'w') as f:
|
||||||
|
# f.write(str(out))
|
||||||
|
#
|
||||||
|
# np.random.seed(1234)
|
||||||
|
# lgstar = ps.esda.getisord.G_Local(y, w, star=True, permutations=999)
|
||||||
|
#
|
||||||
|
# with open('getis_data.json', 'w') as f:
|
||||||
|
# f.write(str(zip(lgstar.z_sim, lgstar.p_sim, lgstar.p_z_sim)))
|
||||||
|
|
||||||
|
|
||||||
class GetisTest(unittest.TestCase):
|
class GetisTest(unittest.TestCase):
|
||||||
"""Testing class for Getis-Ord's G funtion
|
"""Testing class for Getis-Ord's G funtion
|
||||||
|
Loading…
Reference in New Issue
Block a user