Let’s learn to build a basic AI/ML model in 4 minutes (Part 1)

Share it with your other non-technical friends
Reading Time: 4 minutes


No jargon is used and harmed in writing this tutorial.

This is a “no-jargon” attempt to explain the basics of machine learning to non-tech people. In case you find any jargon, please report it to me and I’ll take corrective measures.

Who this article is for?

People who believe Machine Learning is some extraordinary technology that only technical people would understand.

Read this article and know the truth.

What if I say, anybody can learn Machine Learning and it is nothing more than class 12th’s basic maths? 

Well, the above statement might not be entirely true but the fact is not entirely false either.

So, let us create a basic ML model in the next 4 minutes and see it for ourselves. 

Read, how I learned AI as a non-tech person in 4 months for free

Building the model

We will build a prediction model which would take 2 parameters – Temperature and Humidity and predict whether it will rain or not.

You must have heard that Machine learning needs previous data to learn from. Suppose we have 1000 such previous data points shown in the table below

S.No.TemperatureHumidityWould rain?

In the first step, we need to plot these points on a graph like below:

Nothing complicated till now, right? Just basic graph plotting.

By looking at this graph, do you have any solution to solve this problem? Just spend 2 minutes thinking about it before you proceed.

Ok, let us move ahead.

We can observe that we can separate these points more or less into 2 groups.

So, let us draw a line and separate these points in such a way that on one side of the line, we have points that rained and on the other side we have points that ‘did not rain’

The idea to draw a line is simple – we want to make 2 groups – ‘Rain Yes’ and ‘Rain No’

So, the next time when you get a new set of data points (temperature and humidity), you just need to check on which side of the line they would lie.

If the point is on the ‘rain yes’ side, you can simply predict – it will rain and vice versa.

Basically, the line solves the problem.

So, the whole game now is to draw that line that separates the points into 2 groups perfectly (or almost perfectly). 

but wait, what do you mean by drawing a line?

Recall the equation of a line that we learned in school

Its y = mx + c

Where m is the slope and c is the intercept

We have multiple y’s and multiple x’s in our dataset and hence we can find multiple m’s and c’s.

But for the perfect line, we need to find the optimal values, Right?

Once we have the optimal line, we have our Basic machine-learning model in place.

It has learned from the previous data and now it is ready to predict.

Yes, that’s our basic ML model!!

How to calculate optimal m and c?

We could do it manually but then what’s the use of computers and programming languages we have?

So, we have Python libraries that can help us in finding these variables to draw the best line. It’s a very simple code. 

Building a model = Finding the best line

Yep, it is as simple as that. 

Validating the model

Now, the problem is – when you have the best line, how would you confirm that this is actually the best-optimized solution?

You can only validate the model with new data, but without figuring out the best model, how can you implement it for practical use?

The answer is – to validate, what you would do is instead of giving 100% of previous data for calculating m and c, you split it and keep a portion (let’s say 20%) with you for testing.

Now, once you have the best line with the 80% data (aka training data), you would check the model with the reserved set of entries (aka test data). 

In our example, we had 1000 data points, we can use 800 to build the model and 200 to validate it.

This would help you understand whether your model is actually an optimal solution or not.

Accuracy of model

Now, while validating, let’s say out of 200 test data, we got 40 predictions wrong, so our loss is 20% and the accuracy of our model is 80%. 

So, Is this accuracy acceptable? can we make this model more accurate?

If the model is less accurate that means there is some scope for improvement in finding the optimized m and c.

In order to improve the accuracy of a model, a loss function is written in terms of weights (m and c)

This function is then partially differentiated wrt its weights to get the optimized value.

Remember, I told you it involves class 12’s Mathematics.

Don’t worry if you don’t understand how it is done. Just keep in mind that we can improve the model’s accuracy by doing so.

Now, we could write code to do all these calculations but thankfully we have libraries with pre-written code to use.

So, that’s it. That was the basic ML concept for you.

As I said at the start, Machine learning is simple and anybody can learn it.

Part – 2: Making things complex

Now you would say that this was a very basic model.

For doing complex tasks you need complex models and anybody can’t build those.

Well, you might not be entirely false but the fact is you are not entirely true either.

Let’s add complexity to the above problem and see it ourselves in part 2 of this article.

Thanks for choosing to read it completely. I can try to simplify any AI concept for you.

In case you want me to simplify any AI topic, please let me know on LinkedIn – https://www.linkedin.com/in/nikhileshtayal/

And in case you want to practically build AI tools, check out our Build It Yourself series

AI+LLM Courses

If you would like to learn AI + LLM in a very simple language, we provide instructor-led coaching, check out the details here.

Here are the 3 courses

  1. AI + LLM coaching for IT Tech professionals
  2. AI + LLM coaching for IT Functional professionals
  3. Applied LLM coaching for Tech professionals and students

Happy learning!

Share it with your other non-technical friends
Nikhilesh Tayal
Nikhilesh Tayal
Articles: 35