Sunday 24 May 2020

A very basic ML code


Some months back I had this inquisitiveness to learn Machine Learning. I was drowned in the ocean of jargons like Data Science, tensorflow, keras, pytorch, ML, DL, NLP, computer vision, Neural Network, linear regression, logistic regression, classification and/or regression problem, etc...

I was totally confused where to start. I came across many articles and videos explaining how machine learn. Yeah, yeah, yeah I got it. I understand the English behind it. Okay I learned some algorithms, trained some models, used google tensorflow hosted zoo models etc...

But deep down I had this question all the time why are we even using this code?

I seriously needed this mapping of statistical algorithm, this Neural Network diagram and associated equations to programmatic code in my mind.

While jumping into this world of AI, I learned Python. I just love python, there is hell lot of creativity of python community. Why creativity? I was a Java enthusiast and the way we code in python is next level. Simple example - list comprehensions

So, while reading some google articles I realized something which is very basic but its worth for understanding


I opened an excel file, I created column X and filled them with value from 1 to 10

I chose a simple linear equation

y = 4x + 9

and added a column Y in excel and filled with the below formulae in first row of column Y



Now, just imagine, you don't have the equation with you.
Only numbers! Now, I tell you to find the equation.

This may feel Notalgic, because we have solved such problems in school subject Algebra where we were present with number series and we have to identify the equations.

Don't conclude it yet! No we are not going to find equation using ML model (set of code) but go one step further.

We are going to give these set of data (X and Y) to our ML model and ask it to generate equation, keep equation to yourself  and predict what would be the value of Y when X is 14

Then, I opened Jupyter Notebook (Just another fancy way to run python code), created our model in following way.





Enlightened?

Please find this Jupyter notebook code here

-Pankaj Dhapola
Let's Think on it