Automatically generating Python documentation with Sphinx, autodoc, and ReadTheDocs

Generating documentation for Python packages/modules can be quite time consuming, but there's a way to generate it automatically from docstrings. This post is mostly a summary of the fantastic guide by Sam Nicholls found here, but with one important addition (see the section on mocking). We'll be using the following: Sphinx - Python package for generating documentation Sphinx autodoc - Sphinx extension to generate documentation from docstrings ReadTheDocs - build and host documentation online Before you start, make sure you've written docstrings for your modules/functions/methods. This is the most time consuming part, but you should be commenting and documenting your…

Continue Reading

Overview of Convolutional Neural Networks (CNN)

Regular feed-forward artificial neural networks (ANN), like the type featured below, allow us to learn higher order non-linear features, which typically results in improved prediction accuracy over smaller models like logistic regression. However, ANNs have a number of problems that make them less ideal for certain types of problems. For example, imagine a case where we wanted to classify images of handwritten digits. An image is just a 2D array of pixel intensity values, so a small 28x28 pixel image has a total of 784 pixels. If we wanted to classify this using an ANN, we would flatten the 2D…

Continue Reading

Configure (base) Spacemacs

I love using Spacemacs. I like how extensible Emacs is, but prefer the modal editing nature of Vi(m), and Spacemacs provides the best of both worlds through the use of Evil. I enjoy tinkering with my editor configuration to get the perfect setup and there are a few ways this can be achieved: Use base Emacs with customizations Use the full Spacemacs distribution Use and customize the base Spacemacs distribution Using base Emacs (1) and adding our own packages and configurations is doable but it takes a lot of work. Full Spacemacs (2) offers everything the distribution has to offer,…

Continue Reading

XOR Logic Gate – Neural Networks (3/3)

(Part 3 of a series on logic gates) We have previously discussed logic gates and the importance of bias units. Here, we will introduce the XOR gate and show why logistic regression can't model the non-linearity required for this particular problem. As always, the full code for these examples can be found in my GitHub repository here. XOR gates output True if either of the inputs are True, but not both. It acts like a more specific version of the OR gate: Input 1 Input 2 Output 0 0 0 0 1 1 1 0 1 1 1 0 If…

Continue Reading

AND Logic Gate – Importance of bias units (2/3)

(Part 2 of a series on logic gates) We often neglect to consider the role bias plays in our models. We know that we should include bias units, but why? Here, I'll walk through a short example using an AND gate to highlight the importance of the bias unit. Bias units allow us to offset the model in the same way that an intercept allows us to offset a regression line. Imagine a simple AND gate. It will only fire if both inputs are true: Input 1 Input 2 Output 0 0 0 0 1 0 1 0 0 1…

Continue Reading

OR Logic Gate using Theano (1/3)

(Part 1 of a series on logic gates) Theano is a powerful Python library that provides some useful tools for machine learning, such as GPU training and symbolic differentiation of the cost function during gradient descent. It can be a bit challenging to understand how Theano works, so before jumping into more complex non-linear models, we can get to grips with Theano by implementing something simple like an OR gate. An OR gate receives 2 inputs and will output true if either of the inputs are true. So, there are 3 cases where an OR gate will output a true…

Continue Reading

Multiple Regression using Python

Whenever I do any machine learning I either manually implement models in MATLAB or use Python libraries like scikit-learn where all of the work is done for me. However, I wanted to learn how to manually implement some of these things in Python so I figured I'd document this learning process over a series of posts. Lets start with something simple: ordinary least squares multiple regression The goal of multiple regression is predict the value of some outcome from a series of input variables. Here, I'll be using the Los Angeles Heart Data Lets import some modules: [crayon-5a8f92a4c3960697539485/] Next, we'll…

Continue Reading
Close Menu