Skip to main content

Basic Mathematics to kickstart Learning AIML

Mathematics is great

It is great to start with basic mathematics and revise the concepts from school before diving into the world of AI. Keep in mind that everything in the world can be represented mathematically. Math is behind the magic you see in day to day life.


We will try to learn the application of two-dimensional geometry, Three-dimensional geometry, multi(hyper) dimensional geometry, shapes, calculus using real-world problem scenarios.

We will try to understand:
  1. What are 2d, 3d, and hyper geometry shapes?
  2. What is w0, w1, x1, w2, x2... in w1x1 + w2x2 +...+ w0 = 0
  3. Why we need more than 3 dimensions and how it is represented?
  4. How to convert the equation to the matrix?
Let's start with why-to-learn-geometry

Use of geometry in AI

In the world of AI let's take an example of a classification problem:

Scenario

You are working in a multinational company that provides solutions using AI.

Problem Statement (hypothetical)

Predict the nationality of a person given dataset,

  • Case 1: Height and Weight of a person
  • Case 2: Height, Weight, and size of the eye
  • Case 3: Height, Weight, size of the eye, and color
  • Case 4: More than 4 parameters

let's make the assumption that our data is already classified by gender. We are trying to classify people for only one gender at a time.

Case 1

We are given height and weight data of two nationalities African and Chinese. We need to train the classification model which can predict the nationality. Let's see how we can tackle this.

First of all, let's plot the data to get some intuition, (Notebook)
Scatter Plot


Looking at the data we can draw a line that can separate the data. To draw a line we must know the equation of the line which is y = mx + c or ax + by + c=0. (which one is better?)

Let's try to draw a line such that it separates the most data with minimum error and we can predict the nationality of the new person using the equation of the line in the future. To manually fit the line I have created the interactive jupyter Notebook. After so many combinations of the value of slope m and intersection c, we can find the below line,
Separating data with a line

Here the question arises, Can we separate data using any other shape other than a line?
Yes, we can think of a circle, ellipse, or even a parabola or hyperbola. It is crucial to know the equation of such 2D geometrical shapes to use them to separate data.

In AI problems we use some techniques to find the parameters which in the case of a line are slope and intercept. (or a,b, and c in case of ax+by+c=0) Equation of a line

Case 2

We are now given the size of the eye of the person along with the height and weight of two nationalities African and Chinese. We need to train the classification model which can predict the nationality. Let's see how we can tackle this.

First of all, let's plot the data,
Plotting 3-dimensional data


To separate data in 3d we need a plane or any other shape in 3D. Let me give a funny example, we can not separate groups of mosquitoes and bees by stick but it can be done by a net.
After so many attempts and equation solving we find the below plan for ax + by + cz + d = 0
a = -3290.0
b = -7650.0
c = -840.0
d = 1168850.0

Separating data using the plane
Learn more about the plane at a Perpendicular distance from the origin.

So we can conclude that we need n-dimensional objects to separate data into n-dimensional space. So let's take the help of linear algebra and derive the equation of a plane in n-dimension.

What about 4 dimensions when we have four features, what about 100 dimensions where we have 100 features or properties of an object. It is not possible to solve the nth degree equation when the value of n is larger.

Let's take the help of linear algebra and represent an object of the nth degree.

Equation of line y = mx + c can be presented as ax + by + c = 0.
Equation of plane can be similarly presented as ax + by + cz + d = 0.
Equation of hyper plane in 4 dimension can be presented as ax + by + cz + dw + e = 0.
.
.
What about data with 50 features? we only have 26 alphabates in English. let's replace alphabates with w and subscript on n. we can formulate the same as,

2D line = w1x1 + w2x2 + w0 = 0
3D plane = w1x1 + w2x2 + w3x3 + w0 = 0
.
.
nD object = w1x1 + w2x2 +... + wnxn + w0 = 0

NoteGoing forward we will interpret the equation in vector form WT.X + W0 = 0.
W0 is also denoted as b which represents a bias in machine learning. But keep in mind that bias is nothing but a representation of intercept.

Other links:

Comments

  1. AI & ML in Dubai
    https://www.nsreem.com/ourservices/ai-ml/
    Artificial intelligence is very widespread today. In at least certainly considered one among its various forms has had an impact on all major industries in the world today, NSREEM is #1 AI & ML Service Provider in Dubai
    1633325204134-7

    ReplyDelete

Post a Comment

Popular posts from this blog

Optima of a function

Optima of a function We all know that the differentiation of a function is zero at point x if the function is optimum (or saddle point) at x. We will try to see what does that means intuitively and using a graph. For more formulas on calculus check out my other blog. ( Calculus in AI and ML ) Theory: Single Variable Function: The function has optima at x if its first derivative equals 0 at x. We follow the below process to find the maxima or minima of a function. \[\begin{align*} &\text{For function } y=f(x),\\ &\text{1. Evaulate c where } \frac{\mathrm{d} y}{\mathrm{d} x}\mid_{x=c} = f'(c) = 0 \\ &\text{There can be more than one c where} f'(c)=0\\ &\text{2. For each c calculate } \frac{\mathrm{d^2} y}{\mathrm{d} x^2} = f''(c) \\ &\text{if }f''(c) \begin{cases} & <0 \text{ There is Maxima at c} \\ & >0 \text{ There is Minima at c} \\ & =0 \text{ Can't be determined} \end{cases} \end{align*}\] Intuition: Let&#