Wednesday, December 13, 2017

Learning - Machine Learning

It all started with a nudge in the Intelligent Algorithms class in my college days. IIT Delhi. My Alma mater. One of my close friends used to be very excited about neural networks. The course he had taken, the languages he spoke, I could not fathom a word. Luckily, I took a course wherein I had to do load forecasting, and thus was introduced to the world of Machine Learning.

I had first learnt Neural Networks rather than traditional machine learning. Neural networks, a dense layer of interconnected 'neurons', is called so probably taking inspiration from the analogy such a matrix model exhibits to the concepts of neuroscience. Neural networks are foundations for deep learning, however, the field of Machine Learning is inspired from statistics and is completely different.

Machine Learning is the ability of a 'model' to predict a result within certain acceptable error margin. Generally, we solve two kinds of problem with ML techniques.

  1. Regression
  2. Classification
Regression is a more common problem for the prediction of data related to time series. For instance, predict electrical load in an area for tomorrow or predict sales at a cookie store this Christmas. For all other kind of predictions, Classification comes in handy. For example, predict whether it will rain today or not.

There are many basic and advanced techniques available for both Regression and Classification. However, to understand Machine Learning as a concept, I would suggest understanding Linear Regression, Logistic Regression and Support Vector Machine. Most of these concepts can also be implemented using curve fitting and mathematical optimization, however, such solutions tend to 'overfit' i.e. skew towards certain features.

Learning some advanced machine learning techniques should follow after these basic ones especially when one wants to solve real problems in ML. Some advanced techniques like Matrix Factorization, Multinomial Logistic Regression, etc are very commonly used. It can be argued that these algorithms are generally available on the internet, so why invest time learning what they do?

Today, every corporation, however small, generates tremendous amount of data. This raw data needs to be sanitized and formatted in the way these machine learning algorithms understand. Most importantly, one needs to analyze and create 'train', 'test' and 'validation' set. Generating an appropriately randomized well distributed data set is of utmost importance.

Training data set is the one used for training the model. Validation set is used for optimizing hyper parameters of the model, so that acceptable predictions are made using limited resources. Test set is the data on which the model needs to be tested for accuracy or error. Always follow this thumb rule of dividing the data in Set 1 and Set 2, with Set 2 being the smaller set. Call Set 2 as validation set. From Set 1 divide training and testing set. Mixing up set 2 with other sets would create a bias to the hyper-parameters - regularization and learning rates. This bias can harm the accuracy of and time taken by the model to converge to an acceptable error margin.

Actually, 'learning' Machine Learning through basic concepts gives you the confidence to train bigger models, especially ensemble of various ML models. It is also equally important to first understand your data and sanitize it according to algorithm that you might plan use. Just for the sake of enhancing emphasis on thorough understanding of basic concepts in machine learning, I would like to mention that whole of Deep Learning is based on the simple concept of Logistic Regression!

Happy Learning!

Friday, August 25, 2017

Blood banks bleed their patients

"Donate 2 unit of positive blood group or 1 unit of negative. And don't bring B+ or O+. Also get government requisition form or pay 500 rupees."

Unfortunately, I had to visit my hometown Patna. My grandmother was severely ill. Severe anaemia. She had been admitted to Patna Medical College and Hospital(PMCH), supposedly the best treatment available in Bihar. Getting the news at 2 PM, me and my doctor brother rushed to Patna in the next flight. Patna airport, though, very close to the city, is devoid of any transportation after sun goes down. We walked and walked, found an auto, reached PMCH by 10 PM.

The hospital

As you would expect, Emergency Gate is NOT on the front side of the hospital. God knows who in the right mind decided that. It will take you an additional 5 minutes to reach Emergency ward after reaching the hospital. That's enough time for doctors to save a critical patient, but who cares. Anyways, we found the emergency ward, after a bit of queries from random strangers. Hey, mind your step. There are patients that have been assigned mattresses in the alley. Some "lucky" ones, do get a bed in "verandah". If the patient and their attendants are long enough in alley and constantly rant then that might fetch a bed in the ward. And the ward. Dear God. Much lesser people were lined up in Hitler's Jewish ghetto.

And the hospital management

My brother, upon reading the diagnosis and treatment, asks for medical reports. Oh! That has not been received yet. An emergency patient has not received her report after being in the ward(sorry! "verandah") for more than 10 hours. Well my brother is a doctor in a government medical hospital in New Delhi he had some experience how a typical government hospital functions in India. Luckily, he has his stethoscope with him. He put it on his neck. Goes to path lab, asks for the report sternly. It is now prepared within 2 mins, gets the report. And anything else, sir ? Goes to ECG- yes sir let's do it now. X-ray- sir report is ready, please take it. Ultrasound- sir report. Alright, alright, alright the stethoscope works. 11 PM - all reports and medicines in hand.

Anyways, all reports suggest severe anaemia only. Now we need 4 units of blood. Blood group, O negative. Negative blood in blood bank is difficult to come by, even rarer is O negative. It's understood. However, the biggest blood bank in the state, PMCH, does not have it either. And yes it's late night so Red Cross Society is closed. And it's Saturday, so it won't be open till Monday. But we need blood now. Somehow, after tens of calls and rummaging through blood banks pleading to their security guards in late night, we find one unit blood in Jay Prabha Blood bank. We are asked to come in the morning at 9:00.

Blood requistion

We reached Jay Prabha at 8:45 AM. It was open as opposed to the timing of 9:00 AM on a Saturday, so credit to that. To get one unit of negative blood there were two pre-conditions mentioned by them:
  1. One unit of negative blood or two units of positive blood needs to be donated
  2. Donated blood should not be B+ or O+
Aghast upon listening to these conditions, we pondered how will we  find so many donors, and not a B+ or O+. All of my family is B+ and O+, save my brother. We could take only one unit blood. Apprehensively, we waited for Monday to get another unit from Red Cross Society. And luckily there was a donation at PMCH on Friday which was made available to us after incessant requests to their Blood bank. As pathetic as this experience was, even pathetic are the rules for requisite of Blood units from blood bank. Donations should never be barred on the basis of their groups.

"Blood Coins"

Generally, all of us have made several blood donations for National Social Service in our school and college days as volunteers. Why not just link the donation to AADHAR Number? Keep a track of donation as "blood coin" by that person. When requisition is made by her, look up the records. If sufficient blood coins are available, honour the requisition and deduct blood coins. Even better, if the requisition is approved by OTP of the blood currency holder, as phone number is linked to AADHAR.  It's extremely difficult for a family in emergency room to run around and find donors instead of tending to the patient.

I think this is a better step in blood management. When my family went through such an ordeal, I had this thought. I hope Chief Minister of Bihar or Prime Minister of India stumbles upon this post somehow, someday. Sincere small steps like this might even end the big corruption in Blood Banks where an O negative blood is sold in private emergency hospitals for as high as 10,000 rupees and is unavailable for patients in Government Hospital at the same time.

Learning - Machine Learning

It all started with a nudge in the Intelligent Algorithms class in my college days. IIT Delhi. My Alma mater. One of my close friends used ...