Algorithms and Data science, we cannot think one without the other. However, how does one relate to the other?
In this section, we’ll try to understand this important topic.
Firstly, we’ll take a look at the following diagram which we have on the sidebar.
![Machine learning algorithm and data science](https://i0.wp.com/sanjibsinha.com/wp-content/uploads/2022/06/Machine-learning-algorithm-and-data-science.jpg?ssl=1)
For the beginners, let’s assure one thing. The machine learning algorithms represent algorithms. There is no difference.
However, we cannot understand the core concepts of data science if we don’t take time to understand how algorithms work.
In data science, we will see plenty of algorithms.
For one reason.
Although a few machine learning algorithms which are actually libraries of algorithms, yet we want to learn it from the core.
Therefore let’s see how we can interpret one of the oldest algorithms in the world.
Thousand years ago Greek mathematicians used Euclidean algorithm to find the greatest common divisors of two numbers.
It is actually a step by step guide to find the greatest common divisor of two numbers.
Let’s see the first method.
def get_gcd(x, y):
while x != y:
if(x > y):
x = x - y
else:
y = y - x
return x
input_one = input('Please enter a number.')
input_two = input('Please enter another number')
x = int(input_one)
y = int(input_two)
print(f'Between {x} and {y} the GCD is {get_gcd(x, y)}')
Let’s pass these two numbers 1071 and 462.
The output will be 21.
Old Algorithm and new Data science
Thousand years ago, Euclid made it possible manually, by subtracting. At that time there were no Python control constructs, or while loop.
And certainly, there was no data science. 🙂
Still today this old algorithm is relevant.
Now we can write the same recipe in a different way.
def get_gcd_first_method(number_one, number_two):
if(number_two == 0):
return number_one
else:
temporary_storage = number_one % number_two
return get_gcd_first_method(number_two, temporary_storage)
def get_gcd_second_method(number_one, number_two):
if(number_two == 0):
return number_one
elif(number_one > number_two):
return get_gcd_second_method((number_one - number_two), number_two)
else:
return get_gcd_second_method((number_two - number_one), number_one)
print(get_gcd_first_method(1071, 462))
print(get_gcd_second_method(1071, 462))
We’ve used the recursive method. We’ll learn recursive programming later.
In short, when a program calls the same function we say it works in a recursive way.
As we see in the above image, the intersection between mathematics and python points to machine learning algorithms. However, part of the same intersection also belongs to data science.
As a result, if we try to see data science without algorithms, and separate them, that will be the biggest mistake at the very beginning.
Leave a Reply