A Gentle Introduction Into Machine Learning
What is Machine Learning?
Before getting into machine learning, I just want to give a brief introduction to artificial intelligence. So what is Artificial intelligence (AI)? AI is the branch of computer science that aims to build intelligent machines. By intelligence, we are trying to build machines which can behave as intelligently as a human or build machines which can behave in the best possible manner. The word behaviour can be divided into two categories as thinking and acting. With this, AI can be briefly classified as below. I won’t go deeper into these things as the focus of this article is not the AI.
Machine learning is an application of artificial intelligence which gets computers to act without being explicitly programmed. Computers observe and recognize patterns in their input data and act upon the gained experience for future data. The primary objective of machine learning is to allow computer systems to learn automatically without any human intervention or assistance.
Why Should We Use Machine Learning?
Machine learning is needed for tasks that are too complex for humans to code. The majority of these tasks are impossible to code. To get a better understanding of why we need machine learning, let’s consider some of the uses of it. Self-driving cars, google map traffic alerts, anomaly and fraud detection systems, translation systems, virtual assistants, recommendation systems and suggestions on facebook/ Netflix/ google are few popular applications of machine learning. Just imagine how much amount of data involved in each of these cases and it is even not possible to think of these tasks without machine learning. Consider a suggestion or a recommendation system for an example. The system makes suggestions for each user for his/ her own patterns. Typically there are millions of users for a suggestion system and it is not possible to hard code recommendation logic for each of them which is well personalized for the user.
Supervised and Unsupervised Learning
So the question now we have is, how exactly these machines learn?. There are two popular methods for machine learning which are supervised learning and unsupervised learning. It is estimated over the past few years that about 70 percent of the machine learning applications are supervised learning and 10 to 20 percent of them are unsupervised learning. The rest of the ML applications are semi-supervised learning and reinforcement learning. Let’s dive a little deeper into these two widely used categories.
Supervised machine learning is the ML procedure where we have input variables/ data and an output variable and, we are trying to learn the mapping from input variables to the output variable. As the first step, we build and train a ML model for some existing dataset which is labelled for all possible output values. Then, later on, we use this trained model to infer results for new data. The system could be able to predict targets for any new data after sufficient training. A good supervised learning algorithm contains methods to compare its predictions with the correct labels (while training a model) and find errors to modify the algorithm accurately.
The process starts with a bunch of data which are classified into intended classes (i.e. labelled). First, the algorithm divides the dataset into two sets namely the training set and testing set (Sometimes you may find examples where data is divided into three categories namely training, test and cross-validation sets). Typically we keep training to test ratio equal to 4:2. But there’s no such rule saying we should keep this ratio. But this split should be done preventing overfitting and underfitting scenarios. Overfitting is where the model fits the data too well and underfitting is where the model doesn’t fit the data well. Both overfitting and underfitting lead to poor prediction accuracies. Supervised learning can be further classified into regression problems and classification problems. In regression problems, outputs are actual objects whereas in classification problems outputs are categories. Some supervised learning algorithms are listed below.
- Logistic Regression
- Support Vector Machine (SVM)
- K Nearest Neighbors
- Naive Bayes
- Linear Regression
- Polynomial Regression
Unlike in supervised machine learning, unsupervised machine learning doesn’t have the labelled data. As the name suggests it is an uninformed algorithm where we only have input data and no output variable. The primary objective of unsupervised ML is to model the underlying structure of the data to learn more about data. The algorithm draws inferences from the dataset instead of figuring out the correct output.
Unsupervised machine learning can be further classified into clustering problems and association problems. Clustering is where we find similarities in data points and group them together. Association is where we discover rules which describe large portions of data points. The most popular unsupervised learning algorithms are listed below.
- K Means Clustering
- Hierarchical Clustering
- Density-based Clustering
- Hidden Markov Models
What is Required for a Good Machine Learning Model
When you look at machine learning, you might think it’s very hard to study. You may even think those algorithms are too complex. Well, even though algorithms are complex, the good thing is all of these methods are pre-implemented. You just have to use some popular existing library like Tensorflow, Pytorch, LightGBM or Scikit Learn (there are many more libraries) and simply implement the algorithm for your need by importing required methods. You can even use a high-level library like Keras and implement the algorithm much more easily.
So the problem is not with implementing the algorithm, but end of the day all of them are algorithms. Algorithms just work with numbers or binary data. Every one of the above-mentioned algorithms learns from features in the data and infer conclusions. So the most important requirement for ML is data preparation which sometimes referred to as feature engineering. We should pre-process data in a meaningful way in which a machine learning model could be able to identify patterns in data points. This drives you to implement a good accurate machine learning system.