Linear Regression

Great article! Reblogging it for future reference.

Math ∩ Programming

Machine learning is broadly split into two camps, statistical learning and non-statistical learning. The latter we’ve started to get a good picture of on this blog; we approached Perceptrons, decision trees, and neural networks from a non-statistical perspective. And generally “statistical” learning is just that, a perspective. Data is phrased in terms of independent and dependent variables, and statistical techniques are leveraged against the data. In this post we’ll focus on the simplest example of this, linear regression, and in the sequel see it applied to various learning problems.

As usual, all of the code presented in this post is available on this blog’s Github page.

The Linear Model, in Two Variables

And so given a data set we start by splitting it into independent variables and dependent variables. For this section, we’ll focus on the case of two variables, $latex X, Y$. Here, if we want…

View original post 2,899 more words

The Fast Fourier Transform

Math ∩ Programming

It’s often said that the Age of Information began on August 17, 1964 with the publication of Cooley and Tukey’s paper, “An Algorithm for the Machine Calculation of Complex Fourier Series.” They published a landmark algorithm which has since been called the Fast Fourier Transform algorithm, and has spawned countless variations. Specifically, it improved the best known computational bound on the discrete Fourier transform from $latex O(n^2)$ to $latex O(n \log n)$, which is the difference between uselessness and panacea.

Indeed, their work was revolutionary because so much of our current daily lives depends on efficient signal processing. Digital audio and video, graphics, mobile phones, radar and sonar, satellite transmissions, weather forecasting, economics and medicine all use the Fast Fourier Transform algorithm in a crucial way. (Not to mention that electronic circuits wouldn’t exist without Fourier analysis in general.) Before the Fast Fourier Transform algorithm was public knowledge, it simply…

View original post 2,410 more words

How to know your python code is PEP8 compliant?

Everyday, I am learning new things about this awesome language. One amongst the great things it offers is its readability and how it is ingrained in its syntax. It really makes newbies write readable code. This post is about how to know whether your code is PEP8 compliant. PEP8 is the standard code styling guide followed by python developers worldwide.

  1. Install the command-line program pep8
    $ pip install pep8
  2. Execute it for the python file, you want to check, to get the code violations. E.g.
    $ pep8 W191 indentation contains tabs W191 indentation contains tabs W191 indentation contains tabs E501 line too long (91 > 79 characters)

That’s it! Its as simple as that (simplicity – another great feature of python). You can run it on all of your files together (or on a series of files) :

  $ pep8 *.py

Disadvantage: It will give a long list of violations if you are new to python. I recommend running it after every python file you write. Its more manageable that way. Once you are experienced enough, then the above technique will be helpful since the number of violations would be lesser.

Python Guide: Code Style