Solutions and explanations to the python programming assignments for the coursera Machine Learning course.
This repository contains all the solutions to the python versions of the programming assignments for the Machine Learning online class taught by Stanford Professor Andrew Ng. These problems are credited to @dibgerge.
Normally if I don't understand a problem, looking at the solution will help me understand how to approach it and solve it effectively. However, that's hard to do when the solutions are cryptic, not explained, and don't use good practices. This repository aims to help with those looking for solutions with in-depth explanations and sensible code.
If you're going into this course with no programming background I recommend that you first take some time to learn the basics of python. Primarily, you have to be familiar with learning how to solve problems in a computer science oriented way.
In the problem sets, you will face some problems that recommend you to come up with a simple solution to solve a complex problem, which isn't easy in python if you are a beginner.
Once you know how to solve problems with computer science, try getting familiar with the numpy library, which you will be using a lot throughout the problem sets.
If you feel like the problem is too difficult to solve, rather than looking at the solutions, I recommend that you take a bit of time off the problem to do something else, so that you can subconsciously reflect on the problem and look at it in new ways. In many cases, I was stuck on a problem for a few hours and after I came back from a small break, I immediately knew how to solve it.
If you ever feel like you cannot ever come up with a solution or that it feels impossible to succeed, don't worry. That is a part of learning how to program, and I can say for sure that many programmers have felt the same way, moments before they solved the problem. The key is to keep up hope so that you can work diligently and persistently.
These problem sets are relatively difficult, but they certainly aren't impossible for the average person! Just stay patient and you will get there. And of course, if you feel like you seriously cannot come up with a solution, these solutions are meant to help you understand what a good implementation would be.
Good luck!
The python versions of the assignments are credited to @dibgerge.
- The assignments use Jupyter Notebook, which provides an intuitive flow easier than the original MATLAB/OCTAVE assignments.
- The original assignment instructions have been completely re-written and the parts which used to reference MATLAB/OCTAVE functionality have been changed to reference its
python
counterpart. - The re-written instructions are now embedded within the Jupyter Notebook along with the
python
starter code. For each assignment, all work is done solely within the notebook. - The
python
assignments can be submitted for grading. They were tested to work perfectly well with the original Coursera grader that is currently used to grade the MATLAB/OCTAVE versions of the assignments. - After each part of a given assignment, the Jupyter Notebook contains a cell which prompts the user for submitting the current part of the assignment for grading.
These assignments has been tested and developed using the following libraries:
- python==3.6.4
- numpy==1.13.3
- scipy==1.0.0
- matplotlib==2.1.2
- jupyter==1.0.0
- jupyter-client==5.0.1
If you are new to python and to jupyter
notebooks, no worries! There is a plethora of tutorials and documentation to get you started. Here are a few links which might be of help:
-
Python Programming: A turorial with videos about the basics of python.
-
Numpy and matplotlib tutorial: We will be using numpy extensively for matrix and vector operations. This is great tutorial to get you started with using numpy and matplotlib for plotting.
-
Jupyter notebook: Getting started with the jupyter notebook.
-
Python introduction based on the class's MATLAB tutorial: This is the equivalent of class's MATLAB tutorial, in python.