Saturday, March 3, 2018

IoT and Machine Learning

It was the year 1996 when I first brushed through the concept of statistics. I never knew that a boring field like this could very well be useful over making graphs. I always thought statistics to be a tool of a good argument to start with eg when I start a debate on poverty I throw a statistic that as per last survey around 27% of the population is below the poverty line. Never I could imagine that statistics was such a powerful tool until I studied it not as a subject but with more interest some months ago in my second semester of MBA.  Today's premise of my blog actually is more centered around statistics. Yes Mean, Median, Variance, Standard Deviation, Co-relation etc etc etc. I would like to simplify another aspect of IoT and that is Machine learning. 

Before I do that let me give you a hypothetical situation. 

Suppose you have a house that has a toaster, an alarm on your mobile, a microwave, a refrigerator, a dishwasher, a washing machine and an air-conditioner.  Now everyday more or less you wake up at 6 when the alarm rings you turn off the air-conditioner, then you go for a shower not before you have started the washing machine and the dishwasher at around say 6:15 AM. Post the shower you come out and you toast two breads in the toaster and have some baked potatoes in the microwave. These event happen around 6:45 AM and by 7:15 AM as you are having your breakfast you turn on your television to see the news in say NDTV.  At 8:00 AM you leave for your office.  More or less your routine remains the same from Monday to Friday and you are usually following this unless some untoward incident happens or it is a weekend or it is a holiday. 

Imagine that all your machines would get this pattern, well close to it with some anomalies and one fine day they themselves do the routine without your intervention. At 6:00 AM the Air-Con turns off on its own, the geyser turns on for the hot water. As you go into the bathroom say at around 6:15 AM the washing machine and the dishwasher turn on on their own to do the chores. As you are out of the bathroom by  6:45 AM you have your breads toasted and potatoes baked in the Microwave (Assuming you have them already in the toaster before) and as you take the plate to the drawing room you have your television turned on to NDTV talking you through the important breaking news of the day. 

Seems very very spooky, actually horrifying and to some extent like a sci-fi movie. Well, this not entirely, but partly is possible by means of Machine Learning. 

What is Machine Learning? 

Experts have talked a lot about this and if I would be adding some more technical details to it, I will not do any good. It would be more like adding a drop of water in an ocean. So let me do the reverse. Let me take a drop from the ocean and explain you how the entire ocean water is like. Machine Learning is an innovative way of making a machine aware of the patterns of events based on past events, timings and trends.  Basically if you turn on a machine every day say at 7:00 AM and turn it off at 7:00 PM and this is continuously fed to the machine as two events with respect to time then the machine would  learn a response some-what like the picture below. 


As you can see this is a pretty flat picture of the machine getting turned on and off. This is a fixed pattern and this can be fed to the machine and one fine day the machine can work on its own to turn on at 7AM and turn off at 7PM.  The information that is fed to the machine is the knowledge that you give it to work as per the inputs automatically and to take a decision of turning off or turning on. In short you make the machine learn about a pattern of it working and taking decision automatically.  The process in which the machine is able to make sense of the data that is fed to it by means of some external source or its own internal operations so as to take a decision of its own about some of its processes is called "Machine Learning". 

The example above is a pretty basic example of machine learning and in a practical world this is not the way it always happens. Also time is not the only dimension on which the decision of turning on a process or turning off a process depends on. There are many dimensions into place. 

Eg a thermostat of an airconditioner responds to the ambient temperature and the expected temperature settings automatically. In this case the AC is learning about the ambient temperature and is adjusting the compressor working as per that constantly and this is an example of machine response to machine learning automatically. Same goes with the refrigerator. A washing machine can take a decision on the amount of water that it needs to take in for washing based on the load of the clothes and this is also an example of machine learning. So you see my friends machine learning is not a very alien subject. It is not a subject that we are not knowing or we are not aware off. It is the same as taking feedback of an output and then adjusting the input as per the expectation and go on automatically. 

So then why so much brouhaha over Machine Learning? Well here is the difference. 

Whatever examples I have given you till now are about machines that are stand alone. A washing machine can take a decision for itself, and it cannot intrude or pass on the message that it has stopped to the microwave or some other machines for them to use the washing machine result as an input. A level of machine learning in this case is about automation of an entire set of machines in a house or in an enterprise as if it is a part of the same process. So machines do not work in Silos but in a collective way. 

Since this is somewhat like a symphony or like an orchestra you can also call this as Machine Orchestration. 

Randomness: 

Needless to say that when so many machines are involved in making the decisions based on many machines that are integrated the pattern will not be a constant pattern all the time. I mean the example that I had given before of your routine would not be same clock to clock every day. You have to be a robot to do that every day. Some day you may wake up at 6 and some day say even at 5:30 or some day at 6:30 and if the entire sequence of machine orchestration is based on your waking up time at 6:00 then things may go wrong. Like when you woke up at 5:30 you may be just going to the bathroom to see the geyser not on and having a cold shower or if you wake up at 6:30 you may see your washing machine started but no clothes inside. Basically randomness in a pattern can create havoc and so anomalies have to be accounted for. That is why machine learning does not depend on any one dimensional variable.  as you can see that if the X axis is the independent variable and the Y axis is the dependent variable then due to randomness of events there cannot be any fixed pattern that could be established. 

This randomness is much higher as and when the time duration is short. 

How to overcome randomness? 

As we discussed above randomness in machine learning is definitely a big problem. We will not be able to establish patterns. So how to remove these randomness so that we have a fully automated process by the machines so that there is virtually no error of them working automatically and there is a full fledged accuracy to the level of 99% that they work on their own. Well there are many ways of doing that. 

1. Introducing more independent variables: In a two dimensional plot we would not be able to show this however if the outcome of a dependent variables depends on many independent variables with conditions of any one or all of them have to be true then the probability of randomness would decrease. Let us take our example that we had taken before about you getting up for the office. Now in this case we do not keep only time as an independent variable. We also have a motion sensor in the house and some CCTV cameras in your house that record your movement. Now we put a condition that when you get up the motion sensor gives an input and looking at the time the AC decides that you have got up and then turns the AC Off and turns the geyser on. However if you are delayed going to the bathroom the temperature of the geyser is lowered so that you have the perfect temperature. It is only when you drop your clothes in the washing machine and you go to the washroom and turn on the shower the washing machine turns on. So in this case the shower is telling the washing machine that you are already under the shower so washing machine can turn on. Washing machine tells this to the dishwasher to turn on. In this case we see that the operation of all the machines are relative to the operations of others. This process goes on to create a kind of a chain reaction process till you are out of the house for the office. 

2. Studying the pattern over the days: Another way of reducing randomness is not to increase the number of variables that are independent but then to study the pattern for a long time and develop a kind of an algorithm inside the machine with some error margins. As the number of samples and inputs become higher the accuracy increases and the margin or error reduces substantially. It is a common rule in statistics that with the increase of the sample size the standard level or error reduces. Sampling error due to randomness comes down. In our case the sample size increases as we see this routine happening daily again and again and again. Every day the machines record something in them and develop a pattern. When they see that the relative error of two consecutive events have become considerably less than what it was before then it develops an algorithm of automation. 


However, nowadays we want immediate result of everything. We live in an age where we believe that 9 women can give birth to a child in one month, well on a lighter note. So option -2 alone is not viable as the entire system would take sometimes a lot of time to just learn the patterns. Also the moment it sees a spike or a variance the learning process would start again till there is normalization of the error margin. This would mean that the machines would more and more number of times just keep on learning and never do the things we want to do them on their own. So we need a combination of option -1 and option-2 to reduce the randomness in the machine learning techniques. 

Machine Orchestration and Integration:

A central process that manages the working of the machines on their own based on the independent variable inputs and respective machine algorithms is called as a machine orchestrator and the process is called machine orchestration.  Look at the picture below to understand more in detail about the same. 


There is a central Machine Orchestrator of the brain that is controlling different machines by giving customary commands for the processes. However the Orchestrator is not self sufficient. It gets inputs from the independent variables. Also the machines interact with each other with their controllers so that each of them can talk to themselves and to the central orchestrator. The custom algorithm that is developed in the machine is communicated to the orchestrator. The custom algorithm, in red is a result of all the independent variables and the orchestrator also has a feedback of the same. So in case there is an anomaly the orchestrator has the intelligence to change the process flow or to even shut the process for a manual override. 

Summary:

So all in all machine learning is a process where the machines learn to become self sufficient in a step by step manner. Just like us humans from the day we are born to as we gradually age learn different things and responses to various situations. Machine learning is the same way in which a machine can be made this way of course with a great help from one of the most effective sciences, statistics and predictive analysis. 

So you see my friends, a time is coming when machines are going to be if not more intelligent in decision making then at least capable of decision making at least for the routine processes. Who knows one fine day they might even give us a competition. 

We will have more topics on this as I keep on exploring the fascinating world of Internet of Things, IoT. 

Till then keep evolving. 

Cheers, 

Kalyan