Basics of Machine Learning

What is a scalar ?

A scalar is also called a zero Dimensional Array . any single number or value is a scalar
example:

Weight: 70 kg

Temperature: 36.6°C

what is a vector ?

A vector is a 1-D array or an array which in most progrmming languages is written as [1,3,4,5]
For example:

A 3D point in space: [2, 5, 7] (x, y, z coordinates)

what is a matrix ?

A matrix is a 2-D array . i.e for e.g a table with rows and columns is a 2D array . It is also called an array inside an array i.e [ [ 1,2,3,4],[7,8,4,3] ]
A matrix is organized in rows and columns. It’s like a grid where each entry corresponds to a specific row and column. For instance:

3D Array..NDarray

A 3D array adds another dimension to the grid. Imagine stacking multiple 2D arrays like slices in a cube. .The same concept applies to higher order arrays like 4D , 5 D arrays . i.e a 4D array is nothing but stacked 3D arrays . Refer to the other blog also about array indexing How elements are indexed in a 3Dimensional array
For instance: the following is the example of a 3D array.
import numpy as np

# Create a 3D array
array = np.array([[[1, 2, 3],
[4, 5, 6]],
[[7, 8, 9],
[10, 11, 12]]])

# Access element at index (1, 0, 2)
element = array[1, 0, 2] # Result: 9
print(element)
# prints 9

Access Element in a 3 Dimensional Array using numpy

import numpy as np

# Create a 3D array
array = np.array([[[1, 2, 3], [4, 5, 6]],
                  [[7, 8, 9], [10, 11, 12]]])

# Access element 9
# Explanation : consider the above 3D array  as a stacked 2D array with 2 layers 
layer 0 :
[[1, 2, 3], [4, 5, 6]]
layer 1 :
[[7, 8, 9], [10, 11, 12]]
9 is in layer 1 
Within that layer, pick the first row.
Then, take the third element in that row
element = array[1, 0, 2]
print(element)  # Output: 9

This structure makes it easy to navigate, slice, and manipulate data in three-dimensional space.

How elements are indexed in a 3Dimensional array

In a 3D array, elements are organized in three dimensions, and their positions are specified using three indices, typically written as [i][j][k] or (i, j, k). Here’s a breakdown:

How Indexing Works:

This hierarchy lets you pinpoint any element in the 3D array.

How Indexing Works:

  1. First Dimension (i):
  • Determines which “block” or “layer” of the array you’re accessing.
  • Think of it as choosing a specific 2D “sheet” within the 3D array.
  1. Second Dimension (j):
  • Specifies the “row” within the selected 2D sheet.
  1. Third Dimension (k):
  • Points to the “column” within the chosen row.

This hierarchy lets you pinpoint any element in the 3D array.

Example:

Imagine a 3D array as a stack of 2D grids:

Layer 0:
[[1, 2, 3],
 [4, 5, 6]]

Layer 1:
[[7, 8, 9],
 [10, 11, 12]]
  • To access the number 9, you’d use indices [1][0][2]:
  • 1: Select the second layer (index 1 because indexing starts at 0).
  • 0: Within that layer, pick the first row.
  • 2: Then, take the third element in that row.

In Code (Using NumPy):

import numpy as np

# Create a 3D array
array = np.array([[[1, 2, 3], [4, 5, 6]],
                  [[7, 8, 9], [10, 11, 12]]])

# Access element 9
element = array[1, 0, 2]
print(element)  # Output: 9

This structure makes it easy to navigate, slice, and manipulate data in three-dimensional space.

what is AI and Machine Learning

Artificial intelligence (AI) is a broad field that refers to the use of technologies to build machines and computers that have the ability to mimic cognitive functions associated with human intelligence, such as the abilities to see, understand, and respond to spoken or written language, and to analyse data, make recommendations, and more ¹⁴. Machine learning (ML) is a subset of AI that automatically enables a machine or system to learn and improve from experience. Instead of explicit programming, machine learning uses algorithms to process large amounts of data, learn from the insights, and then make informed decisions. Machine learning algorithms improve in performance over time as they are trained – exposed to more data. Machine learning models are the output, or what the program learns, from running an algorithm on training data. The more data used, the better the model will become.

Machine Learning Frameworks Available

There are many machine learning frameworks available, each with its own strengths and weaknesses. Here are some of the most popular:

  1. TensorFlow: TensorFlow is an open source machine learning framework that was developed by Google. It is widely used for building deep learning models and has a large community of developers.
  2. PyTorch: PyTorch is another popular open source machine learning framework, which is widely used for the construction of deep learning models. It is known for its ease of use and flexibility.
  3. scikit-learn: scikit-learn is a popular machine learning library for Python that provides a wide range of algorithms for classification, regression, clustering, and more. It is known for its ease of use and is widely used in industry and academia ¹⁴.
  4. Keras: Built on top of TensorFlow, Keras is a high-level neural network API. It provides a simple and intuitive interface for building deep learning models ¹³.
  5. MXNet: Known for its scalability and speed, MXNet is an open source deep learning framework. It supports multiple programming languages and provides a wide range of tools for building deep learning models.
  6. Caffe: Caffe is a deep learning framework widely used in computer vision applications. It provides a simple and efficient interface to build convolutional neural nets (CNNs).
  7. **Theano: Theano is a Python library that allows you to efficiently define, optimise and evaluate mathematical expressions involving multi-dimensional arrays. It is widely used for building deep learning models.
  8. Torch: Torch is an open source machine learning library that has a wide range of algorithms for deep learning model building. It is known for its ease of use and flexibility.
  9. **CNTK: CNTK (Microsoft Cognitive Toolkit) is an open source framework for deep learning that was developed by Microsoft. It provides a wide range of tools for building deep learning models, and supports multiple languages.