Introduction
This is one of the best massive online open courses (MOOC) on machine learning and is taught by Prof. Andrew NG. However, Prof. NG teaches the course along with MATLAB/Octave and the assignments must be done and submitted in MATLAB/Octave. Do you like the course but not the proprietary MATLAB or the sluggish Octave? Or for any reason, would you rather to use the free GNU R to complete the assignments? This project is your answer.
To view the lecture videos, slides and assignments instructions visit the course website and its wiki page. This repository provides the starter code to solve the assignments in R statistical software; the completed assignments are also available beside each exercise file. Simply follow these steps to complete the assignments:
- View the lecture videos and handouts.
- Read R compatible version of instructions which are available as wiki pages.
- Use the starter directory and fill the parts of the code that is written "YOUR CODE HERE"
- If you couldn't solve it by yourself, get help from the accompanied file suffixed by
_solution
inside the same directory of the starter code. For example,starter/ex1/computeCost.R
has an associated solution file namedstarter/ex1/computeCost_solution.R
- Submit
Dependencies
In order to produce similar results and plots to Octave/Matlab, you should install a few packages:
rgl
package is used to produce the 3D scatter plots and surface plots in the exercises.SnowballC
:portStemmer
function in this package has the same role of theportStemmer.m
.raster
package is used to produce the plot of the bird in exercise 7.jsonlite
andhttr
packages are needed for submission.pinv.R
: Theginv
(generalized inverse) function inMASS
package doesn't produce the same result of the Matlabpinv
(pseudo-inverse). I wrotepinv.R
as the modified version of MASSginv
to produce the same result of the MATLABpinv
. For more info see this stackoverflow discussionlbfgsb3_.R
: Certain optimization tasks could only be solved usinglbfgsb3
package, yet there are a few bugs in this package. The purpose oflbfgsb3_.R
is to address these bugs; it is used for exercises 4 and 8. Beware thatfmincg
orfminunc
optimization function in MATLAB takes one function as input and computes cost and gradient simultaneously. However, cost and gradient functions must be supplied intooptim
orlbfgsb3
functions individually.
Before starting to code, install the following packages:
install.packages(c('rgl','lbfgsb3','SnowballC','raster','jsonlite', 'httr'))
Submission
After completing each assignment, source("submit.r")
and then submit()
in your R console.
I submitted the solutions to Coursera for testing and the scores were 100%. Please report any problem with submission here.
Topics covered in the course and assignments
- Linear regression, cost function and normalization
- Gradient descent and advanced optimization
- Multiple linear regression and normal equation
- Logistic regression, decision boundary and multi-class classification
- Over-fitting and Regularization
- Neural Network non-linear classification
- Model validation, diagnosis and learning curves
- System design, prioritizing and error analysis
- Support vector machine (SVM), large margin classification and SVM kernels (linear and Gaussian)
- K-Means clustering
- Principal component analysis (PCA)
- Anomaly detection, supervised learning
- Recommender systems, Collaborative filtering
- Large scale machine learning, stochastic and mini-batch gradient descent, on-line learning, map reduce
Screen-shots
A few screenshots of the plots produced in R:
Licence
This project is released under MIT to the extent it is original.