This is the R version assignments of the online machine learning course (MOOC) on Coursera website by Prof. Andrew Ng.
To download lecture videos visit the course website:
This repository provides the starter code to solve the assignment in R statistical software; the completed assignments are also available beside each exercise file.
Simply follow these steps to complete the assignments:
- View the lectures
- Read the instructions (pdf). Instructions are basically for MATLAB/OCTAVE. R compatible version of instructions will become available here as Wiki pages in future.
- Use the Starter_solution folder and fill the parts of the code that is written "YOUR CODE HERE"
- If you couldn't solve it yourself, get help from the accompanied file suffixed by
_solutioninside the same folder of the starter code. For example,
starter_solution/ex1/computeCost.Rhas an associated solution file named
In order to produce similar results and plots to Octave/Matlab, you should install a few packages:
rglpackage is used to produce the 3D scatter plots and surface plots in the exercises.
portStemmerfunction in this package has the same role of the
rasterpackage is used to produce the plot of the bird in exercise 7.
httrpackages are needed for submission.
ginvfunction, generalized inverse, in
MASSpackage doesn't produce the same result of the Matlab
pinv.Ris the modified version of MASS
ginvto produce the same effect of the MATLAB
pinv. For more info see the stackoverflow discussion
lbfgsb3_.R: Certain optimization tasks could only be solved using
lbfgsb3package, yet there are a few bugs in this package. The purpose of
lbfgsb3_.Ris to address these bugs; it is used for exercises 4 and 8. Beware that
fminuncoptimization functions in Matlab takes one function as input and computes cost and gradient simultaneously. However, cost and gradient functions MUST be supplied into
Before starting to code, install the following packages:
Note that you don't have to do anything with what is mentioned above, just be informed.
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
A few screen-shots of the plots produced in R: