Author: kostas

  • How to sample from softmax with temperature

    Here is how to sample from a softmax probability vector at different temperatures. import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl import seaborn as sns mpl.rcParams[‘figure.dpi’]= 144 trials = 1000 softmax = [0.1, 0.3, 0.6] def sample(softmax, temperature): EPSILON = 10e-16 # to avoid taking the log of zero #print(preds) (np.array(softmax) […]

  • How to explore two-dimensional data with a heatmap

    https://seaborn.pydata.org/generated/seaborn.heatmap.html

  • How to display a Choropleth map in Jupyter Notebook

    Here is the code: %matplotlib inline import geopandas as gpd import matplotlib as mpl # make rcParams available (optional) mpl.rcParams[‘figure.dpi’]= 144 # increase dpi (optional) world = gpd.read_file(gpd.datasets.get_path(“naturalearth_lowres”)) world = world[world.name != ‘Antarctica’] # remove Antarctica (optional) world[‘gdp_per_person’] = world.gdp_md_est / world.pop_est g = world.plot(column=’gdp_per_person’, cmap=’OrRd’, scheme=’quantiles’) g.set_facecolor(‘#A8C5DD’) # make the ocean blue (optional) Here […]

  • (Integer) Linear Programming in Python

    Step one: brew install glpk pip install pulp Step two: from pulp import * prob = LpProblem(“test1”, LpMinimize) # Variables x = LpVariable(“x”, 0, 4, cat=”Integer”) y = LpVariable(“y”, -1, 1, cat=”Integer”) z = LpVariable(“z”, 0, cat=”Integer”) # Objective prob += x + 4*y + 9*z # Constraints prob += x+y = 10 prob += […]

  • Things that are visible from space, the Garzweiler Surface Mine

    I was looking at arial photos of north-western Europe in Google Maps when I noticed a big white dot on the map! I thought, what the hell? To satisfy my curiosity I decided to zoom in for further investigation. It turns out that the big white dot is a giant surface mine. The 48 km² […]

  • Create a European city map with population density

    Datasets: – Urban morphological zones 2000 (EU): https://www.eea.europa.eu/data-and-maps/data/urban-morphological-zones-2000-2 – Population count (World): http://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-rev10/ – Administrative regions (World): http://gadm.org/ The map is European since the “urban” data from the European Environmental Agency (EEA) only covers Europe. Caveats The UMZ data ended up in PostGIS with srid 900914. You can use prj2epsg.org to convert the contents of […]

  • How to create a world-wide PostgreSQL database of administrative regions

    The GADM database contains geographical data for administrative regions, e.g. countries, regions and municipalities. As always, once you have the data in the right format, it is easy to import it into a database. The data is available from GADM in several formats. All data has the coordinate reference system in longitude/latitude and theWGS84 datum. […]

  • How to assess computers on your local area network

    I teach children how to programm and do other things with technology in an organisation called Coding Pirates in Denmark, which aims to be a kind of scout movement for geeks. A best seller among the kids is learning how to hack and I see this as a unique opportunity to convey some basic human […]

  • Urban Mining – Gold from Airbags,

    Airbag sensors There is a small amount of gold inside the Airbag sensor. The sensor contains a small gold-plated marble, which amounts to some tiny amount of gold. Integrated Chips One kilogram of chips contains 1-8 grams of gold (according to Archimedes Channel on YouTube). Judging from the video they look for gold in the […]

  • Urban Mining – Platinum from Road-side Dust

    These guys found that road-side dust contains 1000 DKK worth of platinum per 1 ton of dust. Cody explains that this concentration of platinum equals the amount found in good-quality platinum ore. Does the stretch of road matter? In a word, yes. The user Jafromobile commented that a car is likely to eject platinum particulates […]