To get started, you can start by either downloading a zip file of these assignments by clicking on the Clone or download button. If you have git installed on your system, you can clone this repository using :
git clone https://github.com/dibgerge/ml-coursera-python-assignments.git
Each assignment is contained in a separate folder. For example, assignment 1 is contained within the folder Exercise1. Each folder contains two files:
- The assignment
jupyternotebook, which has a.ipynbextension. All the code which you need to write will be written within this notebook. - A python module
utils.pywhich contains some helper functions needed for the assignment. Functions within theutilsmodule are called from the python notebook. You do not need to modify or add any code to this file.
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
We recommend using at least these versions of the required libraries or later. Python 2 is not supported.
Once you have installed python, create a new python environment will all the requirements using the following command:
conda env create -f environment.yml
After the new environment is setup, activate it using (windows)
activate machine_learning
or if you are on a linux machine
source activate machine_learning
Now we have our python environment all set up, we can start working on the assignments. To do so, navigate to the directory where the assignments were installed, and launch the jupyter notebook from the terminal using the command
jupyter notebook
This should automatically open a tab in the default browser. To start with assignment 1, open the notebook ./Exercise1/exercise1.ipynb.
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.
-
In many of the exercises, the regularization parameter
$\lambda$ is denoted as the variable namelambda_, notice the underscore at the end of the name. This is becauselambdais a reserved python keyword, and should never be used as a variable name. -
In
numpy, the functiondotis used to perform matrix multiplication. The operation '*' only does element-by-element multiplication (unlike MATLAB). If you are using python version 3.5+, the operator '@' is the new matrix multiplication, and it is equivalent to thedotfunction.
- The questions are taken or largely inspired by Andrew Ng's Coursera course on machine learning.