15 Octave Commands Every Data Scientist Must Know

Octave Commands

Earlier this year the Big Data Beard team tackled Andrew Ng’s Machine Learning course on Coursera. In week two the course started to get hands on with Machine Learning labs. These labs were all done in Octave or Matlab. I had the misfortune of not having any experience using Octave or Matlab. So not only was I learning the Machine Learning content, I also had to level on on my Octave knowledge. Let’s jump through the top Octave Commands I learned in this course.

Octave Commands

What is Octave

Octave is an open source application that runs on Windows, Mac, & Linux systems used for computing large mathematical computations. Octave the open source version of Matlab which is used heavily by Data Scientist, Engineers, and Mathematicians for developing mathimatical models. Think the relationship between Octave and Matlab as CentOS is to Redhat.

Why Use Octave vs. Python?

Throughout the Machine Learning course assignment are calculated and submitted using Octave. Why Octave over using Python or R? Andrew Ng built this course to revolve around the fundamentals of Machine Learning. This course is more a math and concepts fundamentals versus showing how to code. While Python is a fairly easy language to pick up, it still requires basic coding skills. Octave gives non-coding students the ability to easily jump into implementation the mathematical concepts in the course.

I would have rather used Python, but I have a background in software engineering so of course I would.

Octave Commands

At first glance Octave reminded me of the TI-83 from my high school days (yes I’m that old). The syntax is very simple and the commands have roots in the UNIX filesystem. Let’s walk through the top Octave Commands.


Octave Commands
Baseline Octave CLI Commands

ls – List files, sub-directories, and content in current location. Same thing as doing ls from the CLI in Linux.

cd – Change directory. When you need to move to another directory cd allows you to move to that location.

mkdir – Creates an empty directory in some location.

help – Documentation from the CLI. Use the help command then name of command you want documentation on.

Declaring Variables in Octave

Variable Name – To declare variables in Octave it’s as simple is assigning the variable name then setting it equal to some value or other variable.

Arithmetic Octave Commands

 Addition -Simple addition

Subtract -Simple subtraction

Multiplication -Simple multiplication

Division -Simple division

Exponential  -Simple Exponential

sqrt() – Find square root of some value or variable.


Octave Complex Functions

plot() – Allows users to pass in variable to be plotted.

rand() – Generate random numbers.

ones() – Create matrix with n (whatever you pass in) dimensions.

size() – Describe the size of n dimensions in matrix.


Want More Big Data Beard?

Find out more tips about Octave Commands, Data Analytics Architecture, and other cool  topics in Big Data by subscribing to the Big Data Beard Podcast.