# Topological Deep Learning & Machine Learning

# What has happened so far?

We explained that Topological Data Analysis is Superior to Pixel Based Methods like Deep Learning…

Then we went through some theory behind Topological Data Analysis and saw some examples using the toolkit Scikit-tda…

And then finally we saw some quick examples with a toolkit called Gudhi…

and now here we are…

Lets talk about two things…

- Topology + Machine learning
- Topology + Deep Learning

And the most important thing is to structure our thoughts and not go all over the place. So that we can make a clear and crisp use case for integrating topology with machine learning and deep learning. And there is no confusion as to how to go about doing it.

# And how do we start doing that? We start with e.g. Betti Numbers.

I’m sure you would have gone through the previous articles and understand what are betti numbers. But to summarize again…

Betti numbers are a series of numbers that describe a shape.

For the purposes of this article, we don’t need to know anything more than — every different shape will have a different set of betti numbers b0-bn where n is the nth betti number.

To integrate Topology we will feed betti numbers into our backend Machine Learning and Deep Learning algorithms.

And we will also assume that our shapes are going to be only so complex so we will only feed the first ’n’ betti numbers e.g. 5 betti numbers corresponding to our shapes e.g. b0, b1, b2, b3, b4 only.

And we also know that since betti numbers count the number of holes in nth dimension. And there is no limit to the number of holes. We will assume that the max number of holes we will consider (max complexity of our shapes) will be for example 10.

So each of the betti numbers b0, b1, b2, b3, b4 can be from 0–10 both inclusive.

Now we also understand that we have to fit these numbers appropriately into our backend Machine Learning and Deep Learning numbers. We understand that some backend algorithms would be able to process a betti number between 0–10 as is. But deep learning would take a number between 0.0–1.0 so we will scale our betti numbers (normalize their values) from 0.0–1.0 so 0 will be 0.0, 1 will be 0.1, 2 will be 0.2, 10 will be 1.0.

**So what is the big idea?**

- Betti numbers describe shapes
- If we can feed betti numbers into our backend Machine Learning / Deep Learning algorithms we will be able to create algorithms that learn something based on shapes (and not pixel image data)
- That should (would) be superior to all our Image Pixel based Machine Learning and Deep Learning Algorithms we have been building so far.

Cool! Lets move ahead…

# Topology + Machine Learning

Firstly, we will say that Machine Learning is primarily about just 3 things regression, clustering and classification. Aha! That simple.

**What is Regression?**

Regression is a fancy term for curve fitting i.e. fitting a curve through our data points.

Now we have to essentially note that regression can be used to fit curves through data points in ’n’ dimensions. It doesn’t HAVE TO BE 2 or 3 dimensions.

The way we fit a curve is by minimizing the error term which corresponds to the amount of error in fitting the curve to the data points.

To measure distance in ’n’ dimensions we use something like Euclidean Distance.

where p1, p2, p3… & q1, q2, q3… are coordinates in ’n’ dimensions

Our 5 betti numbers b0, b1, b2, b3, b4 corresponding to one shape are simply coordinates of a point B in 5 dimensions. Aha!

Which means we can simply apply regression algorithms on it (in 5 dimensions) and we can simply use betti numbers with their actual values bn = 0- infinity (we don’t even have to cap them at 10 for example, nor do we have to normalize them. Yay!)

That was a no brainer!

**What is Classification?**

Basically we try to predict the class of something (dependant variable) based on a couple of known values (independant variable)

So in the example above we try to classify the flower’s species based on Sepal Length, Sepal Width, Petal Length and Petal Width.

If we had to classifiy something we are seeing with a camera (and we have its betti numbers) into football, bat, frisbee etc.

We can simply go ahead and use the betti numbers b0, b1, b2, b3 ,b4 in our algorithm alongside any other variables if needed to make the prediction. And we can simply use betti numbers with their actual values bn = 0- infinity (we don’t even have to cap them at 10 for example, nor do we have to normalize them. Yay!)

**What is Clustering?**

**Clustering** is the task of dividing the population or data points into a number of groups such that data points in the same groups are more similar to other data points in the same group and dissimilar to the data points in other groups.

The essential point to note is that clustering algorithms use some form of distance measure (e.g. euclidean) and work naturally with data points in ’n’ dimensions.

Our 5 betti numbers b0, b1, b2, b3, b4 corresponding to one shape are simply coordinates of a point B in 5 dimensions. Hmmm!

Which means we can simply apply clustering algorithms on it (in 5 dimensions) and we can simply use betti numbers with their actual values bn = 0- infinity (we don’t even have to cap them at 10 for example, nor do we have to normalize them. Yay!)

# And now, finally Deep Learning!

Instead of worry about and going into nitty gritties of CNN’s, RNN’s, LSTM’s (which are types of deep neural networks).

Lets just see the figure above.

We need to give our input variables in the input layer and we will automagically (without getting into the theory and practice of how deep neural networks work) get our results in the variables of the output layer.

Now we basically have two options…

- We only feed our 5 (or n) betti numbers in the input layers and work only using them.
- We feed our 5 (or n) betti numbers in the input layers along with ‘m’ other variables.

Whatever it be…

We have to realise that the input variables are between 0.0–1.0 so each of the betti numbers b0, b1, b2, b3, b4 can be from 0–10 (or bMax) both inclusive.

And we will normalize the betti numbers betti numbers b0, b1, b2, b3, b4 to 0.0–1.0 by dividing them by 10 or (bMax).

**Voila!**

We have successfully integrated (albeit very naively) Topology into our Machine Learning and Deep Learning models.

# About us

This is our website http://automatski.com