From 07bf4dd93131425888a2c816050e40ec90b94175 Mon Sep 17 00:00:00 2001 From: Maor Date: Sun, 30 Sep 2018 18:21:22 +0300 Subject: [PATCH 01/12] Fixed 'Toy Story' movie average calculation bug in Ex8. The indicator matrix should be used for filtering elements instead of selecting elements. --- Exercise8/exercise8.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercise8/exercise8.ipynb b/Exercise8/exercise8.ipynb index 3e4aa60..c47efd2 100755 --- a/Exercise8/exercise8.ipynb +++ b/Exercise8/exercise8.ipynb @@ -469,7 +469,7 @@ "\n", "# From the matrix, we can compute statistics like average rating.\n", "print('Average rating for movie 1 (Toy Story): %f / 5' %\n", - " np.mean(Y[0, R[0, :]]))\n", + " np.mean(Y[0, R[0, :] == 1]))\n", "\n", "# We can \"visualize\" the ratings matrix by plotting it with imshow\n", "pyplot.figure(figsize=(8, 8))\n", From d4085fa99635f614c257a7d973a2b2df68f0b253 Mon Sep 17 00:00:00 2001 From: Jeroen Van Goey Date: Sat, 20 Oct 2018 22:49:01 +0200 Subject: [PATCH 02/12] Fix typo Fix a simple typo. PS: thanks for implementing this, this is a godsend! --- Exercise1/exercise1.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercise1/exercise1.ipynb b/Exercise1/exercise1.ipynb index 7ebc6fa..6eea3ca 100755 --- a/Exercise1/exercise1.ipynb +++ b/Exercise1/exercise1.ipynb @@ -168,7 +168,7 @@ "\n", "Execute the next cell to grade your solution to the first part of this exercise.\n", "\n", - "*You should now submit you solutions.*" + "*You should now submit your solutions.*" ] }, { From 67f760436126a4b8161c02342bad4895db46db87 Mon Sep 17 00:00:00 2001 From: Uzair Fasih Date: Tue, 19 Mar 2019 19:24:48 +0530 Subject: [PATCH 03/12] Changed lambda_ value from 100 to 0 --- Exercise5/exercise5.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercise5/exercise5.ipynb b/Exercise5/exercise5.ipynb index 66c4500..c5e5c67 100755 --- a/Exercise5/exercise5.ipynb +++ b/Exercise5/exercise5.ipynb @@ -657,7 +657,7 @@ "metadata": {}, "outputs": [], "source": [ - "lambda_ = 100\n", + "lambda_ = 0\n", "theta = utils.trainLinearReg(linearRegCostFunction, X_poly, y,\n", " lambda_=lambda_, maxiter=55)\n", "\n", From 5a25b495a3e4e9d016427a11efbd1369ee5ec5e8 Mon Sep 17 00:00:00 2001 From: Yegor Tokmakov Date: Wed, 17 Apr 2019 12:13:26 +0200 Subject: [PATCH 04/12] Fix autoreload https://github.com/dibgerge/ml-coursera-python-assignments/issues/21 --- Exercise7/exercise7.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercise7/exercise7.ipynb b/Exercise7/exercise7.ipynb index 0668112..2dbde78 100755 --- a/Exercise7/exercise7.ipynb +++ b/Exercise7/exercise7.ipynb @@ -52,7 +52,7 @@ "# library written for this exercise providing additional functions for assignment submission, and others\n", "import utils\n", "\n", - "%load_ext autoreload \n", + "%load_ext autoreload\n", "%autoreload 2\n", "\n", "# define the submission/grader object for this exercise\n", From f2edc4fbb8aac52c7fdc7287bca34a5d9a56a13e Mon Sep 17 00:00:00 2001 From: Gavin Hughes Date: Thu, 25 Jul 2019 12:01:50 -1000 Subject: [PATCH 05/12] Fix typo. --- Exercise1/exercise1.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercise1/exercise1.ipynb b/Exercise1/exercise1.ipynb index 6eea3ca..0d245b5 100755 --- a/Exercise1/exercise1.ipynb +++ b/Exercise1/exercise1.ipynb @@ -845,7 +845,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "*You should not submit your solutions.*" + "*You should now submit your solutions.*" ] }, { From ba5cb0389a440e0f697bf2805a0a488dbe22cc6d Mon Sep 17 00:00:00 2001 From: Furqan Amin Date: Sat, 3 Aug 2019 10:35:49 +0500 Subject: [PATCH 06/12] Fixed exercise4.ipynb Added the missing mathematical equation in Point #4 of 2.4 backpropagation. Also added an implementation note linking to the discussions of the course so it could help fellow students to implement backprop. --- Exercise4/exercise4.ipynb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Exercise4/exercise4.ipynb b/Exercise4/exercise4.ipynb index d8ebee0..ab2e614 100755 --- a/Exercise4/exercise4.ipynb +++ b/Exercise4/exercise4.ipynb @@ -664,6 +664,7 @@ "Note that the symbol $*$ performs element wise multiplication in `numpy`.\n", "\n", "1. Accumulate the gradient from this example using the following formula. Note that you should skip or remove $\\delta_0^{(2)}$. In `numpy`, removing $\\delta_0^{(2)}$ corresponds to `delta_2 = delta_2[1:]`.\n", + "$$ \\Delta^{(l)} = \\Delta^{(l)} + \\delta^{(l+1)} (a^{(l)})^{(T)} $$\n", "\n", "1. Obtain the (unregularized) gradient for the neural network cost function by dividing the accumulated gradients by $\\frac{1}{m}$:\n", "$$ \\frac{\\partial}{\\partial \\Theta_{ij}^{(l)}} J(\\Theta) = D_{ij}^{(l)} = \\frac{1}{m} \\Delta_{ij}^{(l)}$$\n", @@ -672,7 +673,10 @@ "**Python/Numpy tip**: You should implement the backpropagation algorithm only after you have successfully completed the feedforward and cost functions. While implementing the backpropagation alogrithm, it is often useful to use the `shape` function to print out the shapes of the variables you are working with if you run into dimension mismatch errors.\n", "\n", "\n", - "[Click here to go back and update the function `nnCostFunction` with the backpropagation algorithm](#nnCostFunction)." + "[Click here to go back and update the function `nnCostFunction` with the backpropagation algorithm](#nnCostFunction).\n", + "\n", + "\n", + "**Note:** If the iterative solution provided above is proving to be difficult to implement, try implementing the vectorized approach which is easier to implement in the opinion of the moderators of this course. You can find the tutorial for the vectorized approach [here](https://www.coursera.org/learn/machine-learning/discussions/all/threads/a8Kce_WxEeS16yIACyoj1Q)." ] }, { From 8433480788e7f5ea0cf372be446830321a8f9b75 Mon Sep 17 00:00:00 2001 From: Jonathan Dayton Date: Thu, 24 Oct 2019 14:01:48 -0500 Subject: [PATCH 07/12] Minor grammar fixes --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ca997de..a8c7eb2 100755 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ ![](machinelearning.jpg) -This repositry contains the python versions of the programming assignments for the [Machine Learning online class](https://www.coursera.org/learn/machine-learning) taught by Professor Andrew Ng. This is perhaps the most popular introductory online machine learning class. In addition to being popular, it is also one of the best Machine learning classes any interested student can take to get started with machine learning. An unfortunate aspect of this class is that the programming assignments are in MATLAB or OCTAVE, probably because this class was made before python become the go-to language in machine learning. +This repositry contains the python versions of the programming assignments for the [Machine Learning online class](https://www.coursera.org/learn/machine-learning) taught by Professor Andrew Ng. This is perhaps the most popular introductory online machine learning class. In addition to being popular, it is also one of the best Machine learning classes any interested student can take to get started with machine learning. An unfortunate aspect of this class is that the programming assignments are in MATLAB or OCTAVE, probably because this class was made before python became the go-to language in machine learning. -The Python machine learning ecosystem has grown exponentially in the past few years, and still gaining momentum. I suspect that many students who want to get started with their machine learning journey would like to start it with Python also. It is for those reasons I have decided to re-write all the programming assignments in Python, so students can get acquainted with its ecosystem from the start of their learning journey. +The Python machine learning ecosystem has grown exponentially in the past few years, and is still gaining momentum. I suspect that many students who want to get started with their machine learning journey would like to start it with Python also. It is for those reasons I have decided to re-write all the programming assignments in Python, so students can get acquainted with its ecosystem from the start of their learning journey. These assignments work seamlessly with the class and do not require any of the materials published in the MATLAB assignments. Here are some new and useful features for these sets of assignments: @@ -96,4 +96,4 @@ If you are new to python and to `jupyter` notebooks, no worries! There is a plet - I would like to thank professor Andrew Ng and the crew of the Stanford Machine Learning class on Coursera for such an awesome class. -- Some of the material used, especially the code for submitting assignments for grading is based on [`mstampfer`'s](https://github.com/mstampfer/Coursera-Stanford-ML-Python) python implementation of the assignments. \ No newline at end of file +- Some of the material used, especially the code for submitting assignments for grading is based on [`mstampfer`'s](https://github.com/mstampfer/Coursera-Stanford-ML-Python) python implementation of the assignments. From 7be98ac3cd361b003f8661ffc83806ff293a6ef3 Mon Sep 17 00:00:00 2001 From: Filip Date: Mon, 18 Nov 2019 14:26:25 +0100 Subject: [PATCH 08/12] Added a link to Deepnote --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca997de..6bb7cc8 100755 --- a/README.md +++ b/README.md @@ -13,7 +13,11 @@ These assignments work seamlessly with the class and do not require any of the m - 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. +- 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. + + ## Online workspace + + You can work on the assignments in an online workspace called [Deepnote](https://www.deepnote.com/). This allows you to play around with the code and access the assignments from your browser. [](https://beta.deepnote.com/launch?template=data-science&url=https%3A%2F%2Fgithub.com%2Fdibgerge%2Fml-coursera-python-assignments) ## Downloading the Assignments @@ -24,7 +28,7 @@ To get started, you can start by either downloading a zip file of these assignme 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 `jupyter` notebook, which has a `.ipynb` extension. All the code which you need to write will be written within this notebook. - A python module `utils.py` which contains some helper functions needed for the assignment. Functions within the `utils` module are called from the python notebook. You do not need to modify or add any code to this file. - + ## Requirements These assignments has been tested and developed using the following libraries: From fe6eff79a86c27367585b76853a03dce247d3fab Mon Sep 17 00:00:00 2001 From: Christopher Daigle Date: Tue, 11 Feb 2020 07:34:57 -0500 Subject: [PATCH 09/12] Update requirements.txt --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1a7539c..7ae5f83 100755 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ ipython==6.5.0 ipython-genutils==0.2.0 ipywidgets==7.4.0 jedi==0.12.1 -Jinja2==2.10 +Jinja2==2.10.1 jsonschema==2.6.0 jupyter==1.0.0 jupyter-client==5.2.3 @@ -33,7 +33,7 @@ mkl-fft==1.0.4 mkl-random==1.0.1 nbconvert==5.3.1 nbformat==4.4.0 -notebook==5.6.0 +notebook==5.7.8 numpy==1.13.3 pandocfilters==1.4.2 parso==0.3.1 @@ -61,7 +61,7 @@ terminado==0.8.1 testpath==0.3.1 tornado==5.1 traitlets==4.3.2 -Twisted==18.7.0 +twisted==19.7.0 wcwidth==0.1.7 webencodings==0.5.1 widgetsnbextension==3.4.0 From 7998f93ceb40370c7990db7d7094d1325cdc4370 Mon Sep 17 00:00:00 2001 From: Christopher Daigle Date: Tue, 11 Feb 2020 07:40:32 -0500 Subject: [PATCH 10/12] change to safe versions of packages Jinja2 (2.10 -> 2.10.1), notebook (5.6.0 -> 5.7.8), and twisted (Twisted 18.7.0 -> twisted 19.7.0) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7ae5f83..2890a28 100755 --- a/requirements.txt +++ b/requirements.txt @@ -61,7 +61,7 @@ terminado==0.8.1 testpath==0.3.1 tornado==5.1 traitlets==4.3.2 -twisted==19.7.0 +twisted==19.7.0 wcwidth==0.1.7 webencodings==0.5.1 widgetsnbextension==3.4.0 From 461a27df812418351412483e49a1a5f6f35e9b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9=20=D0=94=D0=B0?= =?UTF-8?q?=D0=BD=D0=B0=D0=B8=D0=BB=D0=BE=D0=B2?= Date: Tue, 19 May 2020 13:04:33 +0300 Subject: [PATCH 11/12] Mistaken indexes fix --- Exercise8/exercise8.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exercise8/exercise8.ipynb b/Exercise8/exercise8.ipynb index 8cd6824..d8aeda3 100755 --- a/Exercise8/exercise8.ipynb +++ b/Exercise8/exercise8.ipynb @@ -683,7 +683,7 @@ "\n", "$$ \\frac{\\partial J}{\\partial x_k^{(i)}} = \\sum_{j:r(i,j)=1} \\left( \\left(\\theta^{(j)}\\right)^T x^{(i)} - y^{(i,j)} \\right) \\theta_k^{(j)} $$\n", "\n", - "$$ \\frac{\\partial J}{\\partial \\theta_k^{(j)}} = \\sum_{i:r(i,j)=1} \\left( \\left(\\theta^{(j)}\\right)^T x^{(i)}- y^{(i,j)} \\right) x_k^{(j)} $$\n", + "$$ \\frac{\\partial J}{\\partial \\theta_k^{(j)}} = \\sum_{i:r(i,j)=1} \\left( \\left(\\theta^{(j)}\\right)^T x^{(i)}- y^{(i,j)} \\right) x_k^{(i)} $$\n", "\n", "Note that the function returns the gradient for both sets of variables by unrolling them into a single vector. After you have completed the code to compute the gradients, the next cell run a gradient check\n", "(available in `utils.checkCostFunction`) to numerically check the implementation of your gradients (this is similar to the numerical check that you used in the neural networks exercise. If your implementation is correct, you should find that the analytical and numerical gradients match up closely.\n", @@ -809,7 +809,7 @@ "\n", "$$ \\frac{\\partial J}{\\partial x_k^{(i)}} = \\sum_{j:r(i,j)=1} \\left( \\left(\\theta^{(j)}\\right)^T x^{(i)} - y^{(i,j)} \\right) \\theta_k^{(j)} + \\lambda x_k^{(i)} $$\n", "\n", - "$$ \\frac{\\partial J}{\\partial \\theta_k^{(j)}} = \\sum_{i:r(i,j)=1} \\left( \\left(\\theta^{(j)}\\right)^T x^{(i)}- y^{(i,j)} \\right) x_k^{(j)} + \\lambda \\theta_k^{(j)} $$\n", + "$$ \\frac{\\partial J}{\\partial \\theta_k^{(j)}} = \\sum_{i:r(i,j)=1} \\left( \\left(\\theta^{(j)}\\right)^T x^{(i)}- y^{(i,j)} \\right) x_k^{(i)} + \\lambda \\theta_k^{(j)} $$\n", "\n", "This means that you just need to add $\\lambda x^{(i)}$ to the `X_grad[i,:]` variable described earlier, and add $\\lambda \\theta^{(j)}$ to the `Theta_grad[j, :]` variable described earlier.\n", "\n", From 3e46ab61824946925fbe02506f068e149c4f3103 Mon Sep 17 00:00:00 2001 From: Mukund Choudhary Date: Fri, 22 May 2020 14:27:33 +0530 Subject: [PATCH 12/12] possible typo fix --- Exercise1/exercise1.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercise1/exercise1.ipynb b/Exercise1/exercise1.ipynb index 0d245b5..fcc76a3 100755 --- a/Exercise1/exercise1.ipynb +++ b/Exercise1/exercise1.ipynb @@ -508,7 +508,7 @@ " X : array_like\n", " The input dataset of shape (m x n+1).\n", " \n", - " y : arra_like\n", + " y : array_like\n", " Value at given features. A vector of shape (m, ).\n", " \n", " theta : array_like\n",