Contours of San Francisco overlayed over OpenStreeMap vector tiles using code from mbostock's vector tiles with multiple layers example. View the hi-res file
See gist for code used to generate contours.
| // Flyweight.js - Copyright Addy Osmani, 2012. | |
| // Consider public domain | |
| // My implementation in JS of this: | |
| // http://en.wikipedia.org/wiki/Flyweight_pattern | |
| // Simulate pure virtual inheritance/'implement' keyword for JS | |
| Function.prototype.implementsFor = function (parentClassOrObject) { | |
| if (parentClassOrObject.constructor == Function) { | |
| // Normal Inheritance | |
| this.prototype = new parentClassOrObject; |
| // installed Clojure packages: | |
| // | |
| // * BracketHighlighter | |
| // * lispindent | |
| // * SublimeREPL | |
| // * sublime-paredit | |
| { | |
| "word_separators": "/\\()\"',;!@$%^&|+=[]{}`~?", | |
| "paredit_enabled": true, |
| import multiprocessing | |
| import pandas as pd | |
| import numpy as np | |
| def _apply_df(args): | |
| df, func, kwargs = args | |
| return df.apply(func, **kwargs) | |
| def apply_by_multiprocessing(df, func, **kwargs): | |
| workers = kwargs.pop('workers') |
Contours of San Francisco overlayed over OpenStreeMap vector tiles using code from mbostock's vector tiles with multiple layers example. View the hi-res file
See gist for code used to generate contours.
| from __future__ import division | |
| from numpy import * | |
| class AdaBoost: | |
| def __init__(self, training_set): | |
| self.training_set = training_set | |
| self.N = len(self.training_set) | |
| self.weights = ones(self.N)/self.N | |
| self.RULES = [] |
| # -*- coding: utf-8 -*- | |
| """ Small script that shows hot to do one hot encoding | |
| of categorical columns in a pandas DataFrame. | |
| See: | |
| http://scikit-learn.org/dev/modules/generated/sklearn.preprocessing.OneHotEncoder.html#sklearn.preprocessing.OneHotEncoder | |
| http://scikit-learn.org/dev/modules/generated/sklearn.feature_extraction.DictVectorizer.html | |
| """ | |
| import pandas | |
| import random |
| {"error": 42716.2954, "samples": 506, "value": [22.532806324110698], "label": "RM <= 6.94", "type": "split", "children": [{"error": 17317.3210, "samples": 430, "value": [19.93372093023257], "label": "LSTAT <= 14.40", "type": "split", "children": [{"error": 6632.2175, "samples": 255, "value": [23.349803921568636], "label": "DIS <= 1.38", "type": "split", "children": [{"error": 390.7280, "samples": 5, "value": [45.58], "label": "CRIM <= 10.59", "type": "split", "children": [{"error": 0.0000, "samples": 4, "value": [50.0], "label": "Leaf - 4", "type": "leaf"}, {"error": 0.0000, "samples": 1, "value": [27.9], "label": "Leaf - 5", "type": "leaf"}]}, {"error": 3721.1632, "samples": 250, "value": [22.90520000000001], "label": "RM <= 6.54", "type": "split", "children": [{"error": 1636.0675, "samples": 195, "value": [21.629743589743576], "label": "LSTAT <= 7.57", "type": "split", "children": [{"error": 129.6307, "samples": 43, "value": [23.969767441860473], "label": "TAX <= 222.50", "type": "split", "children": [{"err |
| id | name | age | |
|---|---|---|---|
| 0 | aaron | 34 | |
| 1 | tina | 36 | |
| 2 | noah | © |
| def invalid_xml_remove(c): | |
| #http://stackoverflow.com/questions/1707890/fast-way-to-filter-illegal-xml-unicode-chars-in-python | |
| illegal_unichrs = [ (0x00, 0x08), (0x0B, 0x1F), (0x7F, 0x84), (0x86, 0x9F), | |
| (0xD800, 0xDFFF), (0xFDD0, 0xFDDF), (0xFFFE, 0xFFFF), | |
| (0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF), (0x3FFFE, 0x3FFFF), | |
| (0x4FFFE, 0x4FFFF), (0x5FFFE, 0x5FFFF), (0x6FFFE, 0x6FFFF), | |
| (0x7FFFE, 0x7FFFF), (0x8FFFE, 0x8FFFF), (0x9FFFE, 0x9FFFF), | |
| (0xAFFFE, 0xAFFFF), (0xBFFFE, 0xBFFFF), (0xCFFFE, 0xCFFFF), | |
| (0xDFFFE, 0xDFFFF), (0xEFFFE, 0xEFFFF), (0xFFFFE, 0xFFFFF), |
| """Playing with tornado.websocket, to add markers to a Google Map using WebSockets | |
| $ pip install tornado | |
| $ python livemap.py --port=8888 | |
| Open http://localhost:8888 in one window | |
| Each time http://localhost:8888/ping is opened in a second window, a | |
| new marker is added to the map (at a random location) |