remove ipython notebook checkpoints
This commit is contained in:
parent
1b969f6735
commit
d7b4eaf110
@ -1,169 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import sys\n",
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd\n",
|
||||
"import pysal as ps\n",
|
||||
"sys.path.append('/Users/toshan/Dropbox/GWR/PyGWRJing/PyGWR/')\n",
|
||||
"from M_FBGWR_May2016 import FBGWR\n",
|
||||
"from M_GWGLM import GWGLM\n",
|
||||
"from M_selection import Band_Sel\n",
|
||||
"import scipy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"path = ps.examples.get_path('GData_utm.csv')\n",
|
||||
"shp = pd.read_csv(path)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Prep data into design matrix and coordinates\n",
|
||||
"\n",
|
||||
"#Dependent variable\n",
|
||||
"y = shp.PctBach.reshape((-1,1))\n",
|
||||
"\n",
|
||||
"#Design matrix - covariates - intercept added automatically\n",
|
||||
"pov = shp.PctPov.reshape((-1,1))\n",
|
||||
"rural = shp.PctRural.reshape((-1,1))\n",
|
||||
"blk = shp.PctBlack.reshape((-1,1))\n",
|
||||
"X = np.hstack([pov, rural, blk])\n",
|
||||
"labels = ['Intercept', 'PctPov', 'PctRural', 'PctBlack']\n",
|
||||
"\n",
|
||||
"#Coordinates for calibration points\n",
|
||||
"u = shp.X\n",
|
||||
"v = shp.Y\n",
|
||||
"coords = zip(u,v)\n",
|
||||
"\n",
|
||||
"coords_dict = {}\n",
|
||||
"for i, x in enumerate(coords):\n",
|
||||
" coords_dict[i] = x"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(60.0, <Kernel.GWR_W object at 0x10b73a450>, [(89.0, 1088.4132720309442), (73.0, 1082.7676645259439), (62.0, 1079.8414440181946), (62.0, 1079.8414440181946), (62.0, 1079.8414440181946), (60.0, 1079.6668177916372), (60.0, 1079.6668177916372), (60.0, 1079.6668177916372)])\n",
|
||||
"CPU times: user 1.75 s, sys: 80.7 ms, total: 1.83 s\n",
|
||||
"Wall time: 1.75 s\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"print Band_Sel(y, None, X, coords_dict)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from pysal.contrib.gwr.sel_bw import Sel_BW\n",
|
||||
"from pysal.contrib.gwr.gwr import GWR"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"60.0\n",
|
||||
"CPU times: user 1.1 s, sys: 3.5 ms, total: 1.11 s\n",
|
||||
"Wall time: 1.1 s\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"print Sel_BW(coords, y, X, [], kernel='bisquare', constant=False).search()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"results = FBGWR(y, X, coords_dict, tolFB=1e-03)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"scrolled": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"sel = Sel_BW(coords, y, X, [], kernel='bisquare', fb=True, constant=False)\n",
|
||||
"results = sel.search(tol_fb=1e-03)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"anaconda-cloud": {},
|
||||
"kernelspec": {
|
||||
"display_name": "Python [fbgwr]",
|
||||
"language": "python",
|
||||
"name": "Python [fbgwr]"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.12"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -1,6 +0,0 @@
|
||||
{
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 1
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
@ -1,571 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import pysal as ps\n",
|
||||
"from pysal.weights.Distance import Kernel\n",
|
||||
"import sys\n",
|
||||
"sys.path.append('/Users/toshan/dev/pysal/pysal/weights')\n",
|
||||
"from Distance import Kernel as kn\n",
|
||||
"from util import full2W as f2w"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"n = 5 #number of observations\n",
|
||||
"m = 3 #number of calibration points"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = np.random.randint(1,1000, n)\n",
|
||||
"y = np.random.randint(1,1000, n)\n",
|
||||
"D1 = zip(x,y)\n",
|
||||
"W1 = kn(D1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = np.random.randint(1,1000, m)\n",
|
||||
"y = np.random.randint(1,1000, m)\n",
|
||||
"D2 = zip(x,y)\n",
|
||||
"W2 = kn(D2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 39,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([[ 0.39894228, 0.1009935 , 0.05619733, 0.04896355, 0.32650695,\n",
|
||||
" 0.37879836, 0.31411809, 0.1073076 ],\n",
|
||||
" [ 0.1009935 , 0.39894228, 0.36195557, 0.36626279, 0.07720723,\n",
|
||||
" 0.11754135, 0.03669346, 0.33721825],\n",
|
||||
" [ 0.05619733, 0.36195557, 0.39894228, 0.39108403, 0.0345001 ,\n",
|
||||
" 0.06151089, 0.02103471, 0.24420603],\n",
|
||||
" [ 0.04896355, 0.36626279, 0.39108403, 0.39894228, 0.0335092 ,\n",
|
||||
" 0.05713611, 0.01604658, 0.26976648],\n",
|
||||
" [ 0.32650695, 0.07720723, 0.0345001 , 0.0335092 , 0.39894228,\n",
|
||||
" 0.37224696, 0.18985479, 0.11774827],\n",
|
||||
" [ 0.37879836, 0.11754135, 0.06151089, 0.05713611, 0.37224696,\n",
|
||||
" 0.39894228, 0.24197075, 0.14519262],\n",
|
||||
" [ 0.31411809, 0.03669346, 0.02103471, 0.01604658, 0.18985479,\n",
|
||||
" 0.24197075, 0.39894228, 0.03119528],\n",
|
||||
" [ 0.1073076 , 0.33721825, 0.24420603, 0.26976648, 0.11774827,\n",
|
||||
" 0.14519262, 0.03119528, 0.39894228]])"
|
||||
]
|
||||
},
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"D3 = np.vstack([D1,D2])\n",
|
||||
"W3 = Kernel(D3, function='gaussian')\n",
|
||||
"W3 = kn(D3, function='gaussian', truncate=False)\n",
|
||||
"\n",
|
||||
"W3.full()[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 40,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n",
|
||||
"a\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"coord_ids = np.arange(n)\n",
|
||||
"points_ids = np.arange(n, n+m)\n",
|
||||
"all_ids = np.arange(n+m)\n",
|
||||
"dists = np.zeros((m,n))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"for i in all_ids:\n",
|
||||
" if i in points_ids:\n",
|
||||
" for j in coord_ids:\n",
|
||||
" if j in W3[j].keys():\n",
|
||||
" if i >= n:\n",
|
||||
" print 'a'\n",
|
||||
" dists[i-n][j] = W3.full()[0][i][j]\n",
|
||||
" elif j >= m:\n",
|
||||
" print 'b'\n",
|
||||
" dists[i][j-m] = W3.full()[0][i][j]\n",
|
||||
" elif (i >= n) & (j >= m):\n",
|
||||
" print 'c'\n",
|
||||
" dists[i-n][j-m] = W3.full()[0][i][j]\n",
|
||||
" else:\n",
|
||||
" print 'd'\n",
|
||||
" dists[i][j] = W3.full()[0][i][j]\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 41,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([[ 0.37879836, 0.11754135, 0.06151089, 0.05713611, 0.37224696],\n",
|
||||
" [ 0.31411809, 0.03669346, 0.02103471, 0.01604658, 0.18985479],\n",
|
||||
" [ 0.1073076 , 0.33721825, 0.24420603, 0.26976648, 0.11774827]])"
|
||||
]
|
||||
},
|
||||
"execution_count": 41,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"dists"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "ValueError",
|
||||
"evalue": "3 is not in list",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-22-3036666a721b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mw\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf2w\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdists\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfull\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||
"\u001b[0;32m//anaconda/lib/python2.7/site-packages/pysal/weights/weights.pyc\u001b[0m in \u001b[0;36mfull\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 952\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 953\u001b[0m \"\"\"\n\u001b[0;32m--> 954\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mutil\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfull\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 955\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 956\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mtowsp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;32m//anaconda/lib/python2.7/site-packages/pysal/weights/util.pyc\u001b[0m in \u001b[0;36mfull\u001b[0;34m(w)\u001b[0m\n\u001b[1;32m 711\u001b[0m \u001b[0mw_i\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mweights\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 712\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mwij\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn_i\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw_i\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 713\u001b[0;31m \u001b[0mc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mkeys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 714\u001b[0m \u001b[0mwfull\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mwij\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 715\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mwfull\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkeys\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;31mValueError\u001b[0m: 3 is not in list"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"w = f2w(dists)\n",
|
||||
"w.full()[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"new_neighbs = {}\n",
|
||||
"new_weights = {}\n",
|
||||
"for each in W2.neighbors:\n",
|
||||
" three = set(W3.neighbors[each])\n",
|
||||
" two = set(W2.neighbors[each])\n",
|
||||
" new_neighbs[each] = list(three.difference(two))\n",
|
||||
" new_weights[each] = {}\n",
|
||||
" for weight in new_neighbs[each]:\n",
|
||||
" new_weights[each][weight] = W3[each][weight]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'\\nfor ids in all_ids:\\n if ids in points_ids:\\n _all = set(W3.neighbors[ids])\\n points = set(W2.neighbors[ids])\\n new_neighbs[ids] = list(_all.difference(points))\\n new_weights[ids] = {}\\n for weight in new_neighbs[ids]:\\n new_weights[ids][weight] = W3[ids][weight]\\n\\n else:\\n new_weights[ids] = {}\\n'"
|
||||
]
|
||||
},
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"coord_ids = W1.id_order\n",
|
||||
"points_ids = W2.id_order\n",
|
||||
"all_ids = W3.id_order\n",
|
||||
"dists = np.zeros((2,3))\n",
|
||||
"\n",
|
||||
"'''\n",
|
||||
"for ids in all_ids:\n",
|
||||
" if ids in points_ids:\n",
|
||||
" _all = set(W3.neighbors[ids])\n",
|
||||
" points = set(W2.neighbors[ids])\n",
|
||||
" new_neighbs[ids] = list(_all.difference(points))\n",
|
||||
" new_weights[ids] = {}\n",
|
||||
" for weight in new_neighbs[ids]:\n",
|
||||
" new_weights[ids][weight] = W3[ids][weight]\n",
|
||||
"\n",
|
||||
" else:\n",
|
||||
" new_weights[ids] = {}\n",
|
||||
"''' \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"3 0\n",
|
||||
"a\n",
|
||||
"3 1\n",
|
||||
"a\n",
|
||||
"3 2\n",
|
||||
"a\n",
|
||||
"4 0\n",
|
||||
"a\n",
|
||||
"4 1\n",
|
||||
"a\n",
|
||||
"4 2\n",
|
||||
"a\n",
|
||||
"5 0\n",
|
||||
"a\n",
|
||||
"5 1\n",
|
||||
"a\n",
|
||||
"5 2\n",
|
||||
"a\n",
|
||||
"6 0\n",
|
||||
"a\n",
|
||||
"6 1\n",
|
||||
"a\n",
|
||||
"6 2\n",
|
||||
"a\n",
|
||||
"7 0\n",
|
||||
"a\n",
|
||||
"7 1\n",
|
||||
"a\n",
|
||||
"7 2\n",
|
||||
"a\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"n = 3 #number of observations\n",
|
||||
"m = 2 #number of \n",
|
||||
"for i in all_ids:\n",
|
||||
" if i in points_ids:\n",
|
||||
" for j in coord_ids:\n",
|
||||
" if j in W3[j].keys():\n",
|
||||
" print i,j\n",
|
||||
" if i >= n:\n",
|
||||
" print 'a'\n",
|
||||
" dists[i-n][j] = W3.full()[0][i][j]\n",
|
||||
" elif j >= m:\n",
|
||||
" print 'b'\n",
|
||||
" dists[i][j-m] = W3.full()[0][i][j]\n",
|
||||
" elif (i >= n) & (j >= m):\n",
|
||||
" print 'c'\n",
|
||||
" dists[i-n][j-m] = W3.full()[0][i][j]\n",
|
||||
" else:\n",
|
||||
" print 'd'\n",
|
||||
" dists[i][j] = W3.full()[0][i][j]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([[ 0. , 0.45118883, 0.85404129],\n",
|
||||
" [ 0.27754126, 0.40233088, 0.20596816],\n",
|
||||
" [ 0. , 0.37941649, 0.6032733 ],\n",
|
||||
" [ 0. , 0. , 0. ],\n",
|
||||
" [ 0.35446728, 0.73305802, 0.50022967]])"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"dists"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[0, 1]"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"points_ids"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"W4 = ps.W(new_neighbs, new_weights)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{0: [3, 4, 5, 6, 7], 1: [3, 4, 5, 6, 7], 2: [3, 4, 5, 6, 7]}"
|
||||
]
|
||||
},
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"W4.neighbors"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{0: {3: -1.0482874068379293,\n",
|
||||
" 4: 0.36696681575222334,\n",
|
||||
" 5: 0.678090925231672,\n",
|
||||
" 6: 0.308555499289517,\n",
|
||||
" 7: -0.620566108018012},\n",
|
||||
" 1: {3: 0.5865615659374835,\n",
|
||||
" 4: -0.8123595700046831,\n",
|
||||
" 5: -0.5633467635255329,\n",
|
||||
" 6: -1.1845906645769202,\n",
|
||||
" 7: 0.42019589403802593},\n",
|
||||
" 2: {3: 0.8005291815217084,\n",
|
||||
" 4: -1.212624893235362,\n",
|
||||
" 5: -0.9337024333901489,\n",
|
||||
" 6: -1.4259607135415542,\n",
|
||||
" 7: 0.009238162970930053}}"
|
||||
]
|
||||
},
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"W4.weights"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[0, 1, 2]"
|
||||
]
|
||||
},
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"W4.id_order"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "ValueError",
|
||||
"evalue": "3 is not in list",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-29-bea43da3bca2>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mW4\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfull\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||
"\u001b[0;32m//anaconda/lib/python2.7/site-packages/pysal/weights/weights.pyc\u001b[0m in \u001b[0;36mfull\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 952\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 953\u001b[0m \"\"\"\n\u001b[0;32m--> 954\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mutil\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfull\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 955\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 956\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mtowsp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;32m//anaconda/lib/python2.7/site-packages/pysal/weights/util.pyc\u001b[0m in \u001b[0;36mfull\u001b[0;34m(w)\u001b[0m\n\u001b[1;32m 711\u001b[0m \u001b[0mw_i\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mweights\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 712\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mwij\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn_i\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw_i\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 713\u001b[0;31m \u001b[0mc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mkeys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 714\u001b[0m \u001b[0mwfull\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mwij\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 715\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mwfull\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkeys\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;31mValueError\u001b[0m: 3 is not in list"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"W4.full()[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 244,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{1: 1}"
|
||||
]
|
||||
},
|
||||
"execution_count": 244,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"W4."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([5])"
|
||||
]
|
||||
},
|
||||
"execution_count": 35,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"np.arange(5,6)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"anaconda-cloud": {},
|
||||
"kernelspec": {
|
||||
"display_name": "Python [Root]",
|
||||
"language": "python",
|
||||
"name": "Python [Root]"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.12"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user