This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ | |
"@babel/preset-env", | |
] | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 25 columns, instead of 22 in line 2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geometry,county_id,apn,land_use_type_id,res_type,land_value,improvement_value,year_assessed,year_built,building_sqft,non_residential_sqft,residential_units,stories,tax_exempt,condo_identifier,imputation_flag,development_type_id,calc_area,parcel_id,zone_id,general_plan_name,city,priority,x,y | |
"POLYGON ((-122.3990274713002 37.79395382339768, -122.3993259511759 37.79391578933188, -122.3993538562597 37.79405130905006, -122.3990561343018 37.79408924715813, -122.3990274713002 37.79395382339768))",San Francisco,0237046,MIXED,,555469.0,225936.0,,1907.0,8250.0,8250.0,0.0,2.0,0.0, ,_,ME,405.240852503,893634,1.0,DOWNTOWN- OFFICE-350-S,San Francisco,1.0,-122.399190847,37.7940025136 | |
"POLYGON ((-122.3964937400307 37.79335498674916, -122.397325320222 37.79271016640127, -122.3974696743914 37.79341132542675, -122.3965299855578 37.79353105082634, -122.3964937400307 37.79335498674916))",San Francisco,0264004,MIPS,,79131319.0,83209623.0,,2005.0,570000.0,570000.0,0.0,32.0,0.0, ,_,,4134.37730242,893997,1.0,DOWNTOWN- OFFICE-400-S,Sa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Steps to install environment | |
1) | |
Get Anaconda (python with includes packages) and install it | |
https://www.continuum.io/downloads | |
2) | |
Get network file and put it in the same directory as this file | |
http://urbanforecast.com/data/2015_06_01_osm_bayarea4326.h5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
from bson.objectid import ObjectId | |
import json | |
import time | |
from string import join | |
import pandas as pd | |
import cPickle | |
MONGO = True | |
JURIS = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.neighbors import KDTree | |
import pandas as pd | |
from geopy.distance import vincenty | |
WALKING_SPEED = 3 # walking assumed at 3 miles per hour | |
TRANSFER_TIME = 10 # transfer time in minutes | |
# assume df1 and df2 each have 2 float columns specifying x and y | |
# in the same order and coordinate system and no nans. returns the indexes | |
# from df1 that are closest to each row in df2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE O |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this should be fairly self explanitory if you know ipf | |
# seed_matrix is your best bet at the totals, col_marginals are | |
# observed column marginals and row_marginals is the same for rows | |
def simple_ipf(seed_matrix, col_marginals, row_marginals, tolerance=1, cnt=0): | |
assert np.absolute(row_marginals.sum() - col_marginals.sum()) < 5.0 | |
# first normalize on columns | |
ratios = col_marginals / seed_matrix.sum(axis=0) | |
seed_matrix *= ratios | |
closeness = np.absolute(row_marginals - seed_matrix.sum(axis=1)).sum() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_network(name, weight_col, max_distance): | |
st = pd.HDFStore(os.path.join(misc.data_dir(), name), "r") | |
nodes, edges = st.nodes, st.edges | |
net = pdna.Network(nodes["x"], nodes["y"], edges["from"], edges["to"], | |
edges[[weight_col]]) | |
net.precompute(max_distance) | |
return net | |
@orca.step('local_pois') | |
def local_pois(settings): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.neighbors import KDTree | |
def nearest_neighbor(df1, df2): | |
kdt = KDTree(df1.as_matrix()) | |
distances, indexes = kdt.query(df2.as_matrix(), k=1, return_distance=True) | |
return pd.Series(distances.flatten(), index=df1.index.values[indexes.flatten()]) | |
import sys | |
import pandas as pd |
NewerOlder