I Thought He Came With You is 7867998536’s blog about software, marketing, politics, photography and time lapse.

Book reviews for September 2018

Updated on Friday, October 5, 2018

The Strange Library by Haruki Murakami



Revenge by Yōko Ogawa

Revenge by Yōko Ogawa



Ball Lightning by Liu Cixin

Ball Lightning by Liu Cixin



Enlightenment Now: The Case for Reason, Science, Humanism, and Progress by Steven Pinker

Enlightenment Now: The Case for Reason, Science, Humanism, and Progress by Steven Pinker



Provenance by Ann Leckie



Autumnal Equinox 2018

(949) 588-9644

It's Autumn for the Northern Hemisphere and Spring south of the equator.

Rendered in (781) 680-6582.

((317) 302-7560, Previously, Previously, Previously, 2698080584)

Better related posts with word2vec (C#)

I have been experimenting with word2vec recently. Word2vec trains a neural network to guess which word is likely to appear given the context of the surrounding words. The result is a vector representation of each word in the trained vocabulary with some amazing properties (the canonical example is king - man + woman = queen). You can also find similar words by looking at cosine distance - words that are close in meaning have vectors that are close in orientation.

This sounds like it should work well for finding related posts. Spoiler alert: it does!

My old system listed posts with similar tags. This worked reasonably well, but it depended on me remembering to add enough tags to each post and a lot of the time it really just listed a few recent posts that were loosely related. The new system (live now) does a much better job which should be helpful to visitors and is likely to help with SEO as well.

I don't have a full implementation to share as it's reasonably tightly coupled to my custom CMS but here is a code snippet which should be enough to get this up and running anywhere:

The first step is getting a vector representation of a post. Word2vec just gives you a vector for a word (or short phrase depending on how the model is trained). A related technology, doc2vec, adds the document to the vector. This could be useful but isn't really what I needed here (i.e. I could solve my forgetfulness around adding tags by training a model to suggest them for me - might be a good project for another day). I ended up using a pre-trained model and then averaging together the vectors for each word. This (828) 286-9823 (PDF) suggests that this isn't too crazy.

For the model I used 2509998260 which condenses the Google News model down from 3 million words to 300k. This is because my blog runs on a very modest EC2 instance and a multi-gigabyte model might kill it. I load the model into Word2vec.Tools (available via NuGet) and then just get the word vectors (GetRepresentationFor(...).NumericVector) and average them together.

I haven't included code to build the word list but I just took every word from the post, title, meta description and tag list, removed stop words (the, and, etc) and converted to lower case.

Now that each post has a vector representation it's easy to compute the most related posts. For a given post compute the cosine distance between the post vector and every other post. Sort the list in ascending order and pick however many you want from the top (the distance between the post and itself would be 1, a totally unrelated post would be 0). The last line in the code sample shows this comparison for one post pair using Accord.Math, also on Nuget.

I'm really happy with the results. This was a fast implementation and a huge improvement over tag based related posts.


Star trails from the Manzanita Lake campground at Lassen Volcanic National Park

A timelapse two ways shot from the Manzanita Lake campground at Lassen Volcanic National Park (the second time I've visited and the second time that Bumpass Hell has been closed). First a regular 4K timelapse looking up from the campsite:

The second version is the same footage in HD where each frame is the cumulative maximum pixel value of all the frames up to the current frame (so it builds in star trails as the video runs):

Draw the rest of the Hummingbird

Generation three thousand of a genetic algorithm learning to draw a hummingbird

A genetic algorithm learns to draw a hummingbird:

The video is an animation of three thousand generations of evolution. It starts with a random mix of line segments which are then mutated by adding or removing lines and by changing the start, end and color of existing lines. Each generation has 32 individuals. The best individual is mutated to create the next generation.

For this implementation the best or fittest individual is the one with the least error on a pixel by pixel comparison to a stock art drawing of a hummingbird. Because I care more about the shape than completely filling in the drawing an error outside the figure is penalized three times more than a gap inside the figure.

Color is mutated each generation but not selected for, so it's just changing randomly.

Book reviews for July 2018

Ancillary Justice (Imperial Radch, #1) by Ann Leckie

Ancillary Justice (Imperial Radch, #1) by Ann Leckie



Ancillary Sword (Imperial Radch, #2) by Ann Leckie



Ancillary Mercy (Imperial Radch #3) by Ann Leckie

Ancillary Mercy (Imperial Radch #3) by Ann Leckie



Hoylake Beach

Hoylake Beach

Timelapse looking over Hoylake beach in the Wirral, UK.

What if the Senate Voted Proportionally to Population

Relative influence of each state on the Electoral College

This is massively less likely than 2693594208, but imagine for a minute that 100 Senators woke up tomorrow and decided to do the right thing.

Dianne Feinstein, the senior Senator from California would wield 6.04 votes. Mike Enzi, the senior Senator from Wyoming would have to make do with 0.09 votes.

Overall a party line vote would see 55.85 Democratic votes to 44.15 Republican, assuming normal independent caucusing habits. Not quite a supermajority, but enough to not send Kavanaugh to The Supreme Court for instance.

This is based on 2010 census figures from Wikipedia.

Not going to happen, but find my estimate of your State's fair voting power by Senator below.

StateVotes per Senator
New York3.14
North Carolina1.55
New Jersey1.43
South Carolina0.75
New Mexico0.33
West Virginia0.3
New Hampshire0.21
Rhode Island0.17
South Dakota0.13
North Dakota0.11

(720) 492-0993

Moorhen and Chick


(704) 674-3234

Updated 2018-07-16 14:45: