Generators and Coroutines in Python

Generators and Coroutines are very powerful tools in Python that can help simplify logic, speed up data-intensive programs or provide flexible and re-useable APIs. In this post, we will explore three main concepts in Python : Generators, Coroutines and Cogenerators. Generators Generators in Python are objects that contain some sort of internal state, and know how to produce the “next” value in a sequence. Before we talk about what generators are, we should talk about what problems they can help solve!...

May 10, 2022 · 8 min

Reproducible software in research using Python - Part 1

One of the big issues in Machine Learning research is reproducibility. In fields like biology that have many experimental variables and uncertainties, it is expected that results may be difficult to reproduce due to small sample sizes and the inherent complexity of the research. However, there is no excuse for Machine Learning research to be anything but trivial to reproduce. In this blog post, I will be demonstrating ways to make the software environment used for an experiment easily replicated as well as ways to add testing as a part of the experimental process to catch errors that might threaten the integrity of the results....

June 19, 2021 · 8 min

Monads in Python

Monads are a super interesting and useful design pattern often seen in functional programming languages such as Haskell. That being said, it is pretty simple to implement our own monads in Python. When talking about Monads, there are three “main” things that I use to describe in practical terms what a Monad is and what it does: Monads are essentially containers for values. In other words, you will have a Monad that will contain some arbitrary value or variable....

February 16, 2021 · 9 min

Decorators in Python

In python, you may have seen some syntax that looks a little like this: @something def foo(): pass The @something statement is called a decorator and is syntactic sugar allow you to concisely implement and use interesting concepts from functional programming called “Higher-order Functions” and “currying”. Before we get into how and why we might use decorators in Python, let’s talk about functional programming, Higher-Order Functions and currying. Currying Currying is a technique for taking a function that takes multiple inputs, and converting it into a sequence of single-input functions....

February 1, 2021 · 4 min

Implementing Neural Networks in Python

One of the more interesting Machine Learning models is the Neural Network. A Neural Network is a highly non-linear mathematical model that can be fitted to very complicated datasets, from image classification to text translation. In this blog post, we’ll be implementing our own simple Neural Network library in python, then test how our model performs through a practical example on an image classification dataset. What is a Neural Network? There are several types of Neural Networks, however we will be examining the simplest variant : a simple Feed-Forward Neural Network....

January 23, 2021 · 12 min

Implementing Logistic regression in Python

One of the simplest Machine Learning algorithms is Logistic Regression. At a conceptual level, there’s not much more to it than some simple calculus, but this algorithm can still be pretty effective in a lot of situations. In this post, we’re going to take a little bit of a look at the math behind Logistic Regression and then implement our own Logistic Regression library in python. What is Logistic Regression? First of all, when we talk about Machine Learning, we are really talking about curve fitting....

January 22, 2021 · 7 min