RepositoryR
faridcher

faridcher/ml-course

Starter code of Prof. Andrew Ng's machine learning MOOC in R statistical language

173stars
145forks
0issues
1views

Introduction

This is one of the best massive open online courses (MOOCs) on machine learning and is taught by Prof. Andrew NG. However, Prof. NG teaches the course along with MATLAB/Octave and the programming exercises must be done and submitted with either of them. 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 programming exercises?

To watch the lecture videos and slides please visit the course original website. This repository provides the starter code to solve the programming exercises in R statistical software. Simply follow these steps to complete the programming exercises:

  1. Watch the lecture videos
  2. Read R compatible version of instructions which are available as wiki pages
  3. fill the parts of the code that are written "YOUR CODE HERE"
  4. 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 named starter/ex1/computeCost-solution.r
  5. Submit

Dependencies

In order to produce similar results and plots to Octave/MATLAB, you should install a few packages (install.packages(c('rgl','lbfgsb3c','SnowballC','jsonlite', 'httr'))):

  • rgl package is used to produce the 3D scatter plots and surface plots in the exercises 1 and 7.
  • lbfgsb3c: to solve large optimization tasks in exercises 4 and 8
  • SnowballC: portStemmer function in this package plays the same role of the portStemmer.m in exercise 6
  • jsonlite and httr packages are needed for submissions.

Furthermore, the ginv (generalized inverse) function in MASS package doesn't produce the same result of the MATLAB pinv (pseudo-inverse). So lib/pinv.r is the modified version of MASS::ginv to produce the same result of the MATLAB pinv.

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 problems with submission here.

Licence

This project is released under MIT to the extent it is original.

Similar Projects

Discover other similar projects and AI models.

RepositoryC++
tensorflow/tensorflow

An Open Source Machine Learning Framework for Everyone

201.9k
Dec 1, 2026
RepositoryJupyter Notebook
nfmcclure/tensorflow_cookbook

Code for Tensorflow Machine Learning Cookbook

6.2k
May 23, 2024
RepositoryJupyter Notebook
jmartinezheras/2018-MachineLearning-Lectures-ESA

Machine Learning Lectures at the European Space Agency (ESA) in 2018

381
Sep 18, 2023
RepositoryPython
pytorch/pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration

105.8k
Dec 1, 2026
RepositoryR
bwlewis/irlba

Fast truncated singular value decompositions

135
Oct 1, 2026
RepositoryR
erichson/rSVD

Randomized Matrix Decompositions using R

105
Nov 4, 2026
RepositoryPython
apachecn/ailearning

AiLearning:数据分析+机器学习实战+线性代数+PyTorch+NLTK+TF2

42.7k
Nov 12, 2024
RepositoryJavaScript
lutzroeder/netron

Visualizer for neural network, deep learning and machine learning models

33.8k
Dec 1, 2026
RepositoryPython
MaxHalford/prince

:crown: Multivariate exploratory data analysis in Python — PCA, CA, MCA, MFA, FAMD, GPA

1.5k
Nov 14, 2026