Linear Algebra for Deep Learning and Machine Learning

liner algebra for data science
liner algebra for data science

Hello readers, I welcome you in this series of posts. Here I shall covers the basic linear algebra for deep learning and machine learning.

First let’s get the fact straight. Mathematical principles and concepts forms the foundation of machine learning and deep learning.

Hence it is quite the most important step forward to the fundamental foundations of mathematical principles.

Therefore mathematical concepts such as the curse of dimensionality, or the regularization, binary, multi-class, ordinal regression, and others must be artistic in mind while building any machine learning model.

Where is Linear algebra applied in machine learning ?

In general the mostly solved problems are falling into the category of “Classifiers” or “Regressors”. And errors in computations are minimised by comparing the actual value with the predicted value. And this is where we use linear algebra ! However not limiting to the above scenario. Thus I just wanted to draw your first attention . And we will uncover how linear algebra becomes the most crucial part of the whole learning process

What topics should we learn ?

While there are many concepts to learn, we will be learning below areas of linear algebra from this series.

  1. Vector and Matrix.
  2. System of Linear Equations.
  3. Vector Space.
  4. Basis.

Additionally, these are the areas of machine learning (ML) and deep learning, where we apply linear algebra’s methods:

  1. Derivation of Regression Line.
  2. Linear Equation to predict the target value.
  3. Support Vector Machine.Classification (SVM).
  4. Dimensionality Reduction.
  5. Mean Square Error or Loss function.
  6. Regularization.
  7. Covariance Matrix.
  8. Convolution.

What python library are we going to use ?

We will be using numpy and pandas for the purpose of this tutorial. And as numpy and pandas already have the necessary utilities built , we will be using them. Also numpy and pandas are the mostly used libraries for such purposes. Thus this makes it easy to use these libraries with confidence as there is already a community built .

How to setup your system ?

To begin this, I would like to suggest you to follow the next part of the tutorial based on your level of maturity. Therefore I have shared the recommendations based on the user’s experience level and operating system of interest.

BEGINNER USERS

On all of Windows, macOS, and Linux:

  • Install Anaconda (it installs all packages you need and all other tools mentioned below).
  • For writing and executing code, use notebooks in JupyterLab for exploratory and interactive computing, and Spyder or Visual Studio Code for writing scripts and packages.
  • Use Anaconda Navigator to manage your packages and start JupyterLab, Spyder, or Visual Studio Code.

ADVANCED USERS

Windows or macOS

  • Install Miniconda.
  • Keep the base conda environment minimal, and use one or more conda environments to install the package you need for the task or project you’re working on.
  • Unless you’re fine with only the packages in the defaults channel, make conda-forge your default channel via setting the channel priority.

Linux

If you’re fine with slightly outdated packages and prefer stability over being able to use the latest versions of libraries:

  • Then use your OS package manager for as much as possible (Python itself, NumPy, and other libraries).
  • And install packages not provided by your package manager with pip install somepackage --user.

Otherwise if you use a GPU:

  • Then first install Miniconda.
  • Then Keep the base conda environment minimal, and use one or more conda environments to install the package you need for the task or project you’re working on.
  • And finally use the defaults conda channel (conda-forge doesn’t have good support for GPU packages yet).

Or otherwise:

  • First install Miniforge.
  • And then keep the base conda environment minimal, and use one or more conda environments to install the package you need for the task or project you’re working on.

Alternative if you prefer pip/PyPI

For users who know, from personal preference or reading about the main differences between conda and pip below, they prefer a pip/PyPI-based solution, we recommend:

  • First install Python from, for example, python.orgHomebrew, or your Linux package manager.
  • Then use Poetry as the most well-maintained tool that provides a dependency resolver and environment management capabilities in a similar fashion as conda does.

How to install numpy and pandas?

The only prerequisite for installing numpy and pandas is Python itself. If you don’t have Python yet and want the simplest way to get started, we recommend you use the Anaconda Distribution – it includes Python, NumPy,pandas and many other commonly used packages for scientific computing and data science.
Additionally a full list of the packages available as part of the Anaconda distribution can be found here.

numpy and pandas can be installed with conda, with pip, with a package manager on macOS and Linux, or from source. For more detailed instructions, consult our Python and NumPy installation guide below.

CONDA

If you use conda, you can install numpy and pandas from the defaults or conda-forge channels:

# Best practice, use an environment rather than install in the base env
conda create -n my-env
conda activate my-env
# If you want to install from conda-forge
conda config --env --add channels conda-forge
# The actual install command
conda install numpy
conda install pandas

PIP

If you use pip, you can install NumPy with:

pip install numpy
pip install pandas

Also when using pip, it’s good practice to use a virtual environment – see Reproducible Installs below for why.

Doubts? WhatsApp me !