Exporting Richly Formatted Text In Python

Today, I wondered whether I could automatically save an image of colored text from the Python console. I was looking for a way to display very long strings that automatically wrapped to its container, so I avoided the dreaded run-on string that never ends. Also, could I save the image elegantly with high resolution? In this article, I will discuss potential approaches for getting a file with nice-looking colored text that can be programmatically generated. ...

October 7, 2020 · 5 min

Fun Hacks for your Python Console

Hack #1: Color Text in Your Terminal You can change the colors of text shown in your Python terminal console using ANSI escape character sequences! Or you can use the colorama library to make the process a bit easier and more streamlined. Colorama works across all the platforms i.e. Windows, Mac OS and Unix. First, we import the modules that we need from colorama. [code] from colorama import Fore, Back, Style [/code] ...

September 12, 2020 · 2 min

Building Recommendations Systems

Recommendations systems are good for matching users to their favorite products and are incredibly popular. In fact you have likely used a recommendation system at least once in your life. For example, Amazon uses recommendation systems to suggest new exciting products to purchase based on users’ previous purchase patterns and those similar users. Netflix also utilizes recommendation systems to suggest new TV Shows and movies. Before we get into recommendation systems, it is important to briefly cover two general-purpose approaches for identifying target customer groups and making product recommendations. These two approaches are called Clustering and Association Rules. ...

September 7, 2020 · 4 min

Recurrent Neural Networks in PyTorch

Feed forward networks cannot learn from the past, but Recurrent Neural Networks (RNNs) can learn by accepting data in a sequence. Examples of applications for RNNs include the text autocomplete feature on your phone and performing language translations. Recurrent Neurons (RNs) act as the building blocks of RNNs. The difference between RNs and feed forward neurons is that RNs accept input x, at time t, as well as a hidden state or output from time t-1 from another RN. The output of a RN is a vector, unlike for a feed forward neuron. RNNs are trained (i.e. their weights are calculated) using backpropagation via Gradient Descent Optimization in time. Output from a single RNN layer at time instance,t is an input to the next layer. Each layer in the RNN represents an instance in time. ...

September 7, 2020 · 2 min

Fastai’s Practical Deep Learning for Coders Course Release - 2020 Update!

On Aug 21st, 2020, fastai released a new version of their Practical Deep Learning for Coders -Part 1 course. This course is a must-take for new and intermediate deep learning practitioners. It is well done and teaches you intuition without drowning you in theory. The only prerequisites are some high-school math, and a year of coding experience (preferably in Python). This course is free and can be done without any installation, by taking advantage of the Colab and/or Gradient platforms, which provide free, GPU-powered Python notebooks. Go here to learn more about the course. ...

September 3, 2020 · 1 min

How Genetic Algorithms Work

Genetic algorithms (GAs) are inspired by biology where only the fittest genes survive. It is based on Charles Darwin’s Natural Selection theory. We start with 2 parent chromosomes that each contain an ordered set of genes. Each parent contributes some of their genes when they mate to create children chromosomes. There is a randomness to the mating process so that each child has a diverse set of genes. This diversity is created by the crossover and mutation processes. Over time and with sufficient genetic diversity, the fittest genes, representing optimal characteristics for the species to survive, be come dominant and are propagated. This is nature’s way of optimizing over genetic diversity and we can co-opt this approach for tackling other optimization problems. ...

August 10, 2020 · 3 min

Regression & Classification Models in PyTorch

The purpose of this article is to share what I learned from a recent PyTorch course. We will share general machine learning tips as well as insights specific to deep learning library PyTorch. PyTorch is a deep learning library for Python and was created by Facebook in 2016. PyTorch is good for deep learning beginners. There are several other popular deep learning frameworks such as TensorFlow, Keras, Chainer, and ONNX. TensorFlow was developed by Google and now includes Keras (previously a separate framework). I chose to deepen my knowledge in PyTorch because it is easy to learn and is commonly used for deep learning. Fastai is another deep learning open source library that is really awesome and intuitive to use. While using Fastai, I found myself curious about the inner workings so it’s a plus that fastai wraps PyTorch as I can gain a better understanding of both libraries at once. Two birds, one stone! ...

May 5, 2020 · 3 min