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…

# Category: Programming

## 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 product recommendation system in Python

A store’s layout can be the difference between surviving and getting wiped out. To drive more sales, businesses are using recommendation systems. We can use an unaltered version of the word2vec algorithm used in NLP, to create a recommendation system. Then, we can compare each product’s similarity in the context of being purchased together. Gathering…

## 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,…

## Optimizing fast food orders using linear programming

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…