
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Learn linear algebra for data science and machine learning using R, covering vectors, matrices, determinants, inverses, norms, eigenvalues, eigenvectors, singular value decomposition, and practical R code demos.
Explore how linear algebra underpins data science and machine learning, and master concepts like vectors, matrices, and tensors, and the rules to manipulate them for machine learning and deep learning.
Explore how linear algebra powers data science by representing data as vectors, matrices, and tensors. See how matrices organize rows as samples and columns as attributes via linear equations.
Learn linear algebra to preprocess data, transform it, and visualize in higher dimensions. This foundation underpins machine learning and deep learning, supports regression, optimization, classification, dimensionality reduction, and neural networks.
Download R from CRAN using Linux, macOS, or Windows. Complete the setup with defaults, create a desktop shortcut, and open the R GUI console; next, learn about installing R Studio.
Install RStudio, the integrated development environment for writing and executing R scripts, after ensuring R is installed, then download the desktop installer from the RStudio website and follow on-screen steps.
Navigate the RStudio interface, an integrated development environment for R, to write and run code in the text editor, view results in the console, and manage the working directory.
Learn to use the built-in help and examples in the official R documentation. Access help.start, the help function, and the question mark, and view examples for functions like sum.
Explore customizing the RStudio look and feel through global options, adjusting appearance, font size, and editor theme, and set the default working directory—optional and not obstructing command execution.
Explore essential R functions for development, including get to display current working directory and set the working directory to a path, and ls, rm, library, and history to manage objects.
Write and run your first R program using the R GUI or RStudio; print hello R and save your work as a script for multi-statement programs.
Set the working directory in RStudio, create an R script, write print statements to display hello R in the console, save as first.r, and remember R is case sensitive.
Discover how to document R scripts with hash comments, how the interpreter ignores them, and how to efficiently comment multiple lines using one hash per line.
Learn scalars and vectors, including magnitude and components; a vector is a one dimensional array of real numbers in rn. Understand column and row representations for data science.
Explore two-dimensional vectors in R2, arrows from the origin to (2,4) and (-3,5) showing direction and magnitude. Represent vectors as ordered numbers with column form used in data science.
Explore vectors in three dimensional space with three components plotted from the origin along x, y, and z axes, including column and row representations and data science vectors.
Represent data in n-dimensional space with vectors of n components in r^n, using column vectors to handle higher dimensions and align attributes across cities like London and Paris.
Create vectors in R with c and assign, view contents, and measure length to handle n-dimensional data. Explore London, Paris, and Lisbon weather vectors as examples.
Create vectors of consecutive numbers in R using the colon operator or sequence function, with ranges and by steps such as 1 to 6 and 6 to 1.
learn to access and modify vectors in r using one-based indexing with square brackets, handle out-of-range values as na, and apply relational operations to set elements to zero.
Explore zero vectors as the origin in R2, R3, and RN, and learn that a ones vector has all components equal to one, denoted by 1_n for n components.
Learn to create zero and ones vectors in R using the c function, rep function, and vector function, with three- and eight-component examples in numeric and integer types.
Explore vector addition by adding corresponding components of column vectors, illustrated with family income and expenses, and extend to u plus v in R2, R3, and RN.
Demonstrates vector addition through element wise addition of corresponding components of two vectors, with examples h and w, and u and v, yielding (14000, 9000) and (9, -3, 7).
Explore scalar multiplication, applying a scalar to each vector component to produce a new vector; see how income and expenses examples illustrate length scaling with positive and negative scalars.
Demonstrate scalar multiplication by multiplying each vector component by a scalar to form a vector; illustrate element-wise results with income 8000 and expenses 5000, and vector u [3, -7, 5].
Explore the vector properties in n-dimensional space, including commutative and associative vector addition, the existence of a zero vector, and distributive and scalar-multiplication laws for vectors.
Learn how addition and scalar multiplication form linear combinations of vectors, illustrated by 2u plus 3v, and generalize to v1 through vn with scalars c1 through cn.
Demonstrate forming linear combinations by adding scaled vectors in R, using u = (3, -7) and v = (6, 4) to produce (24, -2) elementwise.
Learn how column vectors store data, such as weather for London and Paris, and how transposing converts between column and row with the superscript t, returning to the original vector.
Learn how to transpose a vector in R using the t function, turning a column vector into a row vector and vice versa, demonstrated with vector L.
Explore the dot product, or inner product, of vectors, showing how u^T v yields a scalar that measures alignment and direction in R^n, with examples in R^2 and R^3.
Compute the dot product of two vectors in R using %*% or crossprod, producing a scalar; ensure equal dimensions and view examples like (2,4) and (-3,5) yielding 14.
Learn how the outer product forms an n by n matrix by multiplying a column vector by the transpose of another vector, with examples in R2 and R3.
Explore outer product of two vectors in R using t cross prod, producing a matrix; see examples with u=(2,4), v=(-3,5) and u=(3,-2,5), v=(6,4,2).
Understand how matrices store tabular data in data science, with six observations and seven attributes, using row and column indices to reference elements in a two-dimensional array.
Explore how matrices define dimension by rows and columns, with square, rectangular, wide, and tall examples, diagonal elements, and links to linear equations in data science and machine learning.
Create matrices in R with the matrix function and c to input elements, show column-wise and row-wise options, and set dimensions with nrow, ncol, or dim; retrieve diagonals with diag.
Explore how to determine a matrix’s dimensions and size in R using dim, nrow, ncol, and length on a 3-by-2 matrix, revealing rows, columns, and total elements.
Assign names to matrix rows and columns in R using rownames and colnames, turning indices into April, July, October and into max temperature and min temperature.
Learn to access and modify matrix elements in R using row-column indexing with square brackets, starting from one, and single-position indexing for column-wise storage.
Learn to append rows and columns to a matrix in R using rbind and cbind, and assign the results back to the matrix M.
Shows how to delete rows and columns in a three-by-three matrix in R using negative indexing, including removing the second row and the third column by reassigning the matrix.
Explore creating matrices in R with rbind and cbind to bind rows and columns from vectors like April, July, and October, yielding matrix M.
Explore the matrix transpose, swapping rows and columns to form A^T, with examples A and B, and learn that a transpose of a transpose returns the original matrix.
Learn to transpose a matrix in R using t, interchanging rows and columns; a 3x2 matrix becomes a 2x3, and the transpose of a transpose returns the original matrix.
Explore why a symmetric matrix equals its transpose and must be square, illustrated with A and A^T. See how distance matrices demonstrate symmetry and why B and rectangular C fail.
Demonstrate how to determine whether a matrix is symmetric in R by computing the transpose with t and comparing the matrix to its transpose, using examples of varying dimensions.
Explore identity matrices as square matrices with ones on the diagonal and zeros elsewhere, denoted I, and see that multiplying any matrix by I yields the original matrix.
Learn to create identity matrices in R with the Dag function for two by two, three by three, and five by five sizes, with diagonal elements one and zeros elsewhere.
Explore diagonal matrices, square matrices with nonzero diagonal elements and zero off-diagonal elements. Identity matrices are diagonal, and diagonal matrices can be rectangular as well.
Explore creating diagonal matrices in R using the Dag and Diag functions, set diagonal values and retrieve diagonal elements, while non-diagonal entries remain zero.
Explore upper and lower triangular matrices in linear algebra for data science and machine learning using R, where the diagonal and entries above or below it determine zeros and nonzeros.
Explore zero and ones matrices, defining a zero matrix as all-zero elements and a ones matrix as all-one elements, with examples across various dimensions.
Learn to create zero and ones matrices in R using the matrix function, specifying rows and columns to form three by three and other dimensions.
Learn to perform matrix addition element-wise, preserving dimensions, as shown with two by two and two by three matrices where corresponding elements are summed.
Perform matrix addition by adding corresponding elements of two matrices of the same dimension, illustrated with a 2x3 example and specific element-wise sums.
Learn scalar multiplication of matrices by multiplying each element by a scalar. The result preserves dimensions, with examples on 2x2 and 2x3 matrices.
Learn how to perform element-wise scalar multiplication on matrices in R, multiplying each entry by a scalar to yield a matrix of the same dimensions.
Perform the Hadamard product, or element-wise product, by multiplying corresponding elements of two matrices with identical dimensions, as shown with A and B (2x3); the result preserves the same shape.
Learn to perform the Hadamard product by multiplying corresponding elements of two matrices of the same dimensions, as shown with a 2x3 example.
Compute the trace by summing a matrix's diagonal elements to yield a scalar; 2×2 and 3×3 use A11, A22, A33, while 2×3 uses A11 and A22, aiding eigenvalue verification.
Compute the trace of a matrix in R by summing diagonal elements to yield a scalar, using the pragma package with library(pragma) and trace, noting non-square matrices trigger an error.
Master matrix multiplication, not elementwise like addition, and dot product rule. Ensure A is m by p and B is p by n to yield an m by n result.
Demonstrate matrix multiplication in R by computing the dot product of A's rows with B's columns, ensuring A's columns equal B's rows and using %*%.
Learn the algebraic properties of matrix operations, including commutative and associative matrix addition, scalar distribution, noncommutative multiplication, identity matrices, left and right distributivity, and transpose rules.
Compute the powers of a matrix by multiplying A by itself k times, preserving n by n dimensions, with examples such as a two by two matrix.
Compute the matrix power in R by multiplying a square matrix by itself k times using the matrix gal package and the matrix.power function.
Multiplying a diagonal matrix by a matrix scales each row of the second matrix by the corresponding diagonal element, as shown in a 3x3 example.
Show how diagonal matrix multiplication in R scales the rows of B by A’s diagonal elements, and how B is scaled by A when reversed.
Explore determinants as a map from square matrices to real numbers, computed via two-by-two and three-by-three submatrices, cofactors, and checkerboard signs, with examples and notes on singular matrices.
Compute determinants of square matrices in R using the det function, illustrated with 2x2 and 3x3 examples, showing determinants can be negative or zero.
Explore the core determinant properties: det(I)=1; det(A^T)=det(A); det(AB)=det(A)det(B); det(A^n)=det(A)^n; and det(A)=1/det(A^{-1}), enabling easier work with complex matrix operations.
Explore the inverse of a matrix, its relationship to the identity matrix, and conditions for existence in square matrices using determinants; learn methods like Gaussian elimination.
compute the inverse of a square matrix in R using the solve function, with 2x2 and 3x3 examples.
Learn how the determinant governs invertibility: a non-zero determinant makes a matrix invertible (non-singular), while a zero determinant yields a singular, non-invertible matrix.
Explore checking matrix singularity and invertibility in R by determinants and the Matrix Calc package; use is.singular.matrix and det, and compute inverses with solve when possible.
Explain the key properties of matrix inverses, including left and right inverses, inverse of a product, inverse of an inverse, and the relation with transpose.
Apply linear algebra to data science and machine learning by studying systems of linear equations, represented with matrices and vectors, and distinguish linear relationships using coefficients, variables, and constants.
Explore systems of linear equations, where a system uses the same variables and yields a unique solution, infinitely many solutions, or no solution, visualized as intersecting, coinciding, or parallel lines.
Represent systems of linear equations with matrices by forming the coefficient matrix and appending the right-hand side as an augmented matrix. Use two- and three-variable examples to illustrate.
Explore elementary row operations—interchange, scaling, and replacement—and how they modify augmented matrices without changing the underlying linear system, and see that these operations are reversible for solving.
Learn to solve linear systems using the Gaussian elimination method on augmented matrices, turning them into row echelon form with pivot elements, and perform back substitution.
Apply Gauss-Jordan elimination to the augmented matrix to obtain row reduced echelon form, turning pivots into zeros above and below, and solve the linear system.
Demonstrates Gauss-Jordan elimination in R by converting an augmented 3x3 matrix to reduced row echelon form to solve for x1, x2, x3 using the rref function.
Represent a linear system as a matrix vector product ax=b, where A is m-by-n, x is the variables vector, and b is the constants.
Represent systems of linear equations as a matrix-vector product A x = b and as a linear combination of A's columns, illustrating how coefficients and unknowns form b.
Examine the matrix vector product ax=b, with A as the coefficient matrix and x as variables, classifying by m vs n cases, yielding unique solution, multiple solutions, or no solution.
Represent a system of linear equations as A x = b and solve with the matrix inverse, requiring a square, invertible A (nonzero determinant), illustrated with a two-equation example.
solve systems of linear equations in R by constructing matrix A and vector b, then compute x as A inverse times b using the solve function, with two- and three-variable examples.
Learn how to solve a system of linear equations using Cramer's rule with a square invertible matrix, calculating determinants and replacing columns to find x1 and x2.
Solve a two-equation system using Cramer's rule in R by forming matrix A of coefficients and vector b, computing determinants, and obtaining x1 and x2 as 8 and -3.
Solve systems of linear equations in R with qrSolve() from the pragma package by building matrix a and vector b; show x1=8, x2=-3, and x1=3, x2=5, x3=-1 for three-equation case.
Explore vector length through norms, including L2 (Euclidean), L1 (Manhattan), p norms, and the max norm, and compare their behavior with outliers and sparsity.
Compute vector length with the L2 norm, or Euclidean distance, by taking the square root of the sum of squared components. For example, (3,4) yields 5.
Compute the L2 norm (Euclidean length) of vectors in R using the pragma package and the norm function, with examples for v = c(3,4) and w = c(3,-2,5).
Compute the L1 norm, or Manhattan distance, by summing the absolute values of a vector's components, from R2 to R3 and beyond.
Compute the L1 norm (Manhattan distance) of vectors in R using the pragma package and the norm function with type 1, illustrated with vectors (3,4) and (3,-2,5).
Compute the LP norm for a vector, a generalization of L1 and L2, by taking the p-th root of the sum of absolute values to the p power.
Learn to compute the LP norm of vectors in R, a generalization of L1 and L2, using the norm function with p = 4 and the pragma package.
Compute the l infinity norm, or max norm, of a vector by taking the maximum of the absolute values of its components.
Compute the l infinity norm of a vector in R by taking the maximum of its absolute components, using the norm function with Inf and library(pragma) to load the package.
This course will help you in understanding of the Linear Algebra and math’s behind Data Science and Machine Learning. Linear Algebra is the fundamental part of Data Science and Machine Learning. This course consists of lessons on each topic of Linear Algebra + the code or implementation of the Linear Algebra concepts or topics.
There’re tons of topics in this course. To begin the course:
We have a discussion on what is Linear Algebra and Why we need Linear Algebra
Then we move on to Getting Started with R, where you will learn all about how to setup the R environment, so that it’s easy for you to have a hands-on experience.
Then we get to the essence of this course;
Vectors & Operations on Vectors
Matrices & Operations on Matrices
Determinant and Inverse
Solving Systems of Linear Equations
Norms & Basis Vectors
Linear Independence
Matrix Factorization
Orthogonality
Eigenvalues and Eigenvectors
Singular Value Decomposition (SVD)
Again, in each of these sections you will find R code demos and solved problems apart from the theoretical concepts of Linear Algebra.
You will also learn how to use the R's pracma, matrixcalc library which contains numerous functions for matrix computations and solving Linear Algebric problems.
So, let’s get started….