Every time you navigate to a new URL, your browser checks to see if it is in a list of millions of malicious sites. Normally, searching through such a list would take minutes. Anything more than a few milliseconds would make it unusable. So how do they pull it off? Bloom filters! A bloom filter…

# Tag: Python

## Creating animated 3D plots in Python

Matplotlib has become the standard plotting library in Python. This is thanks to its simple API and NumPy/SciPy integration, making it easy to add interactive plots to any code. In this post, I will walk through how to make animated 3D plots in Matplotlib, and how to export them as high quality GIFs. RGB Color…

## Applying A* path finding to latent word vectors

Path finding algorithms There are many algorithms for finding the shortest path between two points, but few are better known than Dijkstra’s algorithm and the A* algorithm. Dijkstra’s algorithm Dijkstra’s algorithm is often described as being “shortest-path first”. This is a greedy approach that isn’t suitable for large graphs. Source: wikimedia.org A* search algorithm A*,…

## Evolutionary algorithms in Python

What is context-free grammar? A grammar is a set of production rules for a language. Context-free grammar is any grammar that is of the form , where is a finite set of nonterminal characters, is a finite set of terminal characters, is the relation from to , and is the start symbol. This is what…

## Building a recommendation system in Python

For competitive, low-margin businesses, a store’s layout can be the difference between surviving and getting wiped out. To drive more sales, businesses are using recommendation systems in online stores, and data-driven nudging at brick-and-mortar locations. How can purchasing data be turned into sales? We can use an unaltered version of the word2vec algorithm used in…

## Word segmentation in Python using SentencePiece

What is word segmentation? Word segmentation (also called tokenization) is the process of splitting text into a list of words. Humans can do this pretty easily, but computers need help sometimes. At a higher level, you can think of segmentation as a way of boosting character-level models that also makes them more human-interpretable. Setup First,…

## Linear Programming in Python

What is linear programming? Linear programming is not a concept in programming, but rather one of mathematics. Given a set of items that have associated costs and benefits, how do you find a mix of items such that the required benefits are met and the cost is minimized? We can start off by requiring that…