First, in Vagrantfile, expose enough ports for lldb and automatically spawn gdbserver processes:
for i in 44000..44100
config.vm.network :forwarded_port, guest: i, host: i
end
Don't forget to vagrant reload
.
var dispatch = d3.dispatch("dataLoaded", "stationHovered", "nodesUpdated"); | |
d3.json("stations.json", function(error, stations) | |
{ | |
var data = {}; | |
data.nodes = stations.nodes; | |
data.links = stations.links; | |
for(var i = 0; i < data.nodes.length; i++) | |
{ |
import numpy as np | |
np.set_printoptions(precision=4) | |
np.random.seed(19894) | |
def gen_data(N=50): | |
X1 = np.random.uniform(0, 3, N) | |
X2 = np.random.uniform(0, 3, N) | |
pi = 1/(1+np.exp(-(-3+X1+X2))) | |
# a randomly selected variable between 0-1 is has the probability pi |
means = np.array([np.mean(X[y == k], axis=0) for k in labels]).T | |
pies, cov = np.array([np.mean(y == k) for k in labels]), np.cov(X.T) | |
cov_inv = np.linalg.inv(cov) | |
np.argmax(X @ cov_inv @ means - np.diag(0.5 * means.T @ cov_inv @ means) + | |
np.log(pies), axis=1) |
license: MIT |
%matplotlib inline | |
%config InlineBackend.figure_format = 'retina' | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
sns.set(style="ticks", color_codes=True) |
First, in Vagrantfile, expose enough ports for lldb and automatically spawn gdbserver processes:
for i in 44000..44100
config.vm.network :forwarded_port, guest: i, host: i
end
Don't forget to vagrant reload
.
def sizeof_fmt(num, suffix='o'): | |
"""Readable file size | |
:param num: Bytes value | |
:type num: int | |
:param suffix: Unit suffix (optionnal) default = o | |
:type suffix: str | |
:rtype: str | |
""" | |
for unit in ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z']: |
## | |
# Map businesses to census tracts | |
# | |
library(tidyverse) | |
library(sp) | |
library(spdplyr) | |
library(rgdal) | |
if (!exists('businesses')) { | |
# all businesses |
library(zipcode) | |
library(magrittr) | |
library(dplyr) | |
library(stringr) | |
library(acs) | |
# load all zipcodes | |
data(zipcode) | |
# as copied from the BARI's ACS indicators R syntax |
cluster | pt | x | y | num_neighbors | neighbors | |
---|---|---|---|---|---|---|
-1 | 0 | 51.41808903 | 13.59361029 | 2 | 0,27 | |
0 | 1 | 39.1323184 | -4.419204415 | 3 | 1,40,75 | |
-1 | 2 | 47.8075151 | -25.82256055 | 1 | 2 | |
-1 | 3 | 27.69970293 | 53.43419307 | 1 | 3 | |
0 | 4 | 39.86099482 | 5.676870902 | 3 | 4,56,75 | |
1 | 5 | -19.89185932 | 10.41027381 | 3 | 5,70,74 | |
1 | 6 | -0.050282532 | -4.032522276 | 3 | 6,14,42 | |
-1 | 7 | 18.56251189 | -28.65497991 | 1 | 7 | |
1 | 8 | -14.62990365 | -4.887040158 | 5 | 8,11,60,63,72 |