How to Teach a Machine to Calculate Addition of Two Numbers using Artificial Intelligence in 3 steps

--

Teaching a machine

If you are familiar with any programming language. An addition program is the first and one of the easiest tasks that a beginner might love to do and To do so one and only Instruction (c=a+b) is given to the computer in any language to perform this task. This is quite easy guys.

Question

But have you ever thought that Computer can learn the addition of two numbers by simply just watching the data without explicitly programmed?

If Not? Read this article till the end. You will fall in love with machines by their capabilities.

There are a few steps that we need to follow. So let’s Get started…

Step 1 — Create a Dataset

This is the dataset that we will prepare for the computer’s brain training. Let’s make one dataset. I made the simple dataset a and b are the dependent variables and sum is an independent variable. Open Microsoft Excel and add these entries in it.

Dataset: This is a sample dataset that defines the relationship between two variables and the computer will learn from this data:

Dataset for the machine’s training

We can simplify the dataset by simply adding the + and =: Now this data would be easy. Right: save this dataset with add.csv, Extension must be CSV. because it is very easy to use CSV in python pandas. Our first step 1 is completed.

Simplified dataset

Step 2 — Training: Giving this dataset to Computer for training.

  • We will use Jupyter notebook, python, sci-kit learn library to implement the Linear regression.
  • Import : The Required Libraries. like pandas, numpy, sklearn, matplotlib.
Required Imports
  • Read: the dataset using pandas python. This will create the same output that we made using the excel file with the name add.csv.
Reading the dataset using python.
  • Training of data: This will train the model according to the dataset.
Training of data

Step 3: Prediction from the Model:

In this, we will test our model with unknown data. which should not be the same as we provided in the add.csv. Let's do it quickly.

Predictions

As we can see that our computer has learned to add two numbers with just data. I haven't given the equation c=a+b.

The main idea behind this is linear regression, In this, we used the multivariate Linear regression. If you are not familiar with these terms checkout my Youtube Playlist for this.

HOPE YOU ENJOYED THIS BLOG

--

--

Wakeupcoders - Digital Marketing & Web App Company
Analytics Vidhya

We make your business smarter and broader through the power of the internet. Researcher | Web developer | Internet of things | AI | www.wakeupcoders.com