Af Kostas Kefaloukos Danmark er et lille halvkoldt land, halvlangt mod nord. Det er ikke så koldt at der er særligt meget sne. Til gengæld blæser det meget og regner hele tiden. Disse vejrforhold gør at danskerne ofte bliver forkølede og udvikler store mængder af snot i næse og svælg. På samme måder som grønlænderne […]
I’m interested in object detection and other computer vision tasks. For example, I’m working on a teddy-bear detector with my son. So, how do you quickly download images for a certain category? You can use this approach that I learned from a course on Udemy. In the above example, the crawler will find images in […]
Create a pandas dataframe with a date column: import pandas as pd import datetime TODAY = datetime.date.today() ONE_WEEK = datetime.timedelta(days=7) ONE_DAY = datetime.timedelta(days=1) df = pd.DataFrame({’dt’: [TODAY-ONE_WEEK, TODAY-3*ONE_DAY, TODAY], ‘x’: [42, 45,127]})import pandas as pd import datetime TODAY = datetime.date.today() ONE_WEEK = datetime.timedelta(days=7) ONE_DAY = datetime.timedelta(days=1) df = pd.DataFrame({‘dt’: [TODAY-ONE_WEEK, TODAY-3*ONE_DAY, TODAY], ‘x’: […]
Cosine similarity is the normalised dot product between two vectors. I guess it is called “cosine” similarity because the dot product is the product of Euclidean magnitudes of the two vectors and the cosine of the angle between them. If you want, read more about cosine similarity and dot products on Wikipedia. Here is how […]
Terms used in shipping
Now that I work in shipping, it is necessary to learn a bunch of new terms. Shipping is regulated under Admiralty Law and there are traditional documents and parties involved. Knowing what these are is crucial to understanding shipping. Legal documents There are three key documents involved with shipping: Bill of Lading (sometimes abbreviated as […]
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 […]
https://seaborn.pydata.org/generated/seaborn.heatmap.html
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)%matplotlib […]
Step one: brew install glpk pip install pulpbrew 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 […]
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² […]