Machine Learning: If It’s Testable It’s Teachable
Tags: showdev, testing, machinelearning
Published: 2022-05-26 11:26:53



Ever wondered how you went to YouTube to watch just a 5 minutes video but ended up there for 3 hours? Or saw an advertisement on some page of exactly the same thing that you have been planning to buy for last 15 days and ended up finally buying it! Isn’t it great how your computer knows what you have been desiring? Well, it’s not your computer but the bots, the algorithmic bots that have been watching you all the time. Even now! Yes, that’s absolutely true. So the question comes, how these bots are made, and how software testing concepts come into play here.

It wasn’t very long ago when humans used to create algorithmic blogs that behaved like the real artificial intelligence. Simple and long code that basically said do this if this… or do that if that… for a while worked perfectly, and in many day to day activities it still works. However, as more and more people came on internet creating bigger and bigger datasets this approach simply didn’t work everywhere. Because some problems are just big enough to be taught by humans.

Let’s consider an example where you are shown two pictures one is of a dog and another is number 5 and you are asked what is what? Being an human you just know that yes, this is a dog and that is number 5 but how will the machine or the bots know?

We have to create a complex algorithm that will tell them to crawl the image pixel by pixel and find patterns in that picture that matches pixel patterns usually found in known dog images and give an estimated guess. Human brains have a complex wiring of neurons that learns every second. Similarly we will have to create complex bots with evolving pattern recognition intelligence which they develop over time as they keep learning.

***Do you know [CSS Shapes Level 1](https://www.lambdatest.com/web-technologies/css-shapes?utm_source=devto&utm_medium=organic&utm_campaign=may26_sd&utm_term=sd&utm_content=web_technologies) allows you to create shapes with CSS, like rounded corners and circles. An area is defined and text can flow around this shape.***

## How Do They Learn?

Human programmers create a teacher bot and a builder bot who have simpler brains. Builder bot builds student bots and keeps and discards them based on their test grades.

![](https://cdn-images-1.medium.com/max/2000/0*viQPideOKhGFmDm4.jpg)

The teacher bot himself cannot distinguish between a dog and a 5 but it can test student bots whether they are right in identifying or not. Now you get why [automated testing](https://www.lambdatest.com/automation-testing?utm_source=devto&utm_medium=organic&utm_campaign=may26_sd&utm_term=sd&utm_content=webpage) is so important.

We give teacher bots a bunch of photos of dogs and 5s and an answer key of which is what. Based on this the teacher bot takes test of student bots and gives them the grades. Based on the test data, the builder bot keeps building on different student bots by adjusting different permutations and combinations of student bots algorithm mechanics, sometimes it even at random sees what sticks and what not. And the teacher bot keeps taking their tests and assigning them the grades. And the cycle continues.

The teacher bot keeps testing, and based on the grades of the student bots, the builder bot keeps the best performing bots and ruthlessly discards the rest.

The **test**, build, **test** cycle keeps on repeating in a loop and their grades are assessed and once the bot with approx 99.9% accuracy (or call them grades) is built the cycle is stopped.

Now the question that comes to our minds is ‘How many times the automated cycle of test, build, and test is repeated?’. Well, it repeats as many times it is necessary till the bot with the best grades is built. The best bot is the best algorithm to distinguish between a dog and 5.

***Check this out [CSS position:sticky](https://www.lambdatest.com/web-technologies/css-sticky?utm_source=devto&utm_medium=organic&utm_campaign=may26_sd&utm_term=sd&utm_content=web_technologies): A lightweight polyfill which uses native CSS APIs to keep your “fixed” and “relative” elements stick to their desired position when the page is scrolled.***

## So What’s The Problem?

Now we have picked up the best algorithm to distinguish between a dog and the number 5 then what is the problem that may occur? If we give the bot a video of a dog or 5 upside down or letter ‘S’ instead of 5 will the bot still be able to figure that out? No.

## How to Solve it?

To solve this, the humans have to create longer automated test cases with more number of questions for the student bots to pass, including even the wrong and the right scenarios so that it gets prepared for the worst cases too. Since longer tests ensures better bots.

As there is not a single bot or some ten or twenty questions but millions of bots and zillions of questions so how does the test, build, test cycle repeat? In that case you have to automate the process and keep on testing the same.

When a final bot is built it works and it is the only one which survives among the all as it is the only one whose algorithm was 0.01% better than the other bot. The algorithm that the student bot has built is not known by the teacher bot, not by the human overseer and not by even the student bot itself! It. Just. Works!

How the bot thinks or works, what it thinks is not really knowable.

Let’s come back to the YouTube example that we have discussed. We can understand this better now. The task here given to the student bots is to record the watch time of a user while keeping engaged and the student bot who keeps the user engaged for the longest watch time will score the highest. The teacher bots assess all the student bots and the student bots keep on giving recommendations to the users so that the user remain engaged. The one who gives the best recommendations and keep the user engaged is the one with the best algorithm.

***Hey! Do you know [CSS-Table](https://www.lambdatest.com/web-technologies/css-table?utm_source=devto&utm_medium=organic&utm_campaign=may26_sd&utm_term=sd&utm_content=web_technologies) is a library used to represent elements as tables, rows, and cells in a much more fluid manner.***

## Have You Come Across A Machine Learning Example Yet?

Believe it or not, we’ve all come across a real-time situation where bots have interacted with us using machine learning. Be it CAPTCHA collection, or customer care support. As a matter of fact, customer support is one area where machine learning has been adopted on wide scale by small companies and big enterprizes alike. We’ve all been aware of the constraints hanging around the customer chat support. You need to respond to customers in a jiffy and that can be especially tough for a global business who is aiming to provide 24/7 customer support as you need to make sure you have numerous representatives ready to help your customers all day & night. Fortunately, there are companies like Acquire’s chatbot which have helped numerous businesses amplify their customer experience by using their chatbots technology.

Which is the best example you could think of for machine learning bots? Let us know in the comments.

We’ve seen that the teacher bot is just testing the student bots and they are learning from the tests. So, in one line we can say that ***Machine learning is teachable if it is testable***.