Python code for Machine Learning class offered by Coursera


Sorry for the shilling, but here’s my upcoming project:

Please register your email address if you’re interested in it.

Edit: Sadly by the request of Coursera itself, I’ve removed this particular github repository. Coursera is doing the right thing though, don’t blame them.


I applied and followed Machine Learning course which is taught by Andrew Ng and offered freely online on Coursera ( However since the Octave installed on my computer doesn’t work properly (e.g. plotting functionality doesn’t work at all, etc), I decided to use python instead.

I managed to solve all of the programming exercises offered, in python instead of Octave. You can access the exercises’ solutions here:

In order to get started with python for machine learning, you might want to install these python libraries / modules:

  1. Numpy (, for matrix and array manipulations
  2. Scipy (, used mainly on optimization / minimization functions
  3. Matplotlib (, for plotting
  4. NLTK (, mainly for preprocessing text in spam detection section
  5. Sci-Kit Learn (, used for the SVM section. This is a great machine learning library has a good write up on how to install most of these modules using Homebrew and pip.

7 thoughts on “Python code for Machine Learning class offered by Coursera

  1. nice! thanks for the share – i’m trying to move from matlab to python and was told to do the ml exercises in python instead. Now i can see how other people would go about the same problem and make improvements, many thanks

    • You’re welcome! I did it in Python because my Octave doesn’t have the full functionalities. Great to see that it’s useful for others.

  2. rajbir singh

    great work subokita.. beautiful ise of python.great help for those who want to learn python immensely useful to me… got better understanding than i would have got through matlab or tutorial videos …:)

    • Hmm, I googled for the programming language, and it sounds interesting. Although I dunno whether all the current libraries I used in python examples (e.g. scikit, nltk) can be bound to Julia.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s