Machine Learning and Predictive Modeling
So, what do we mean when we refer to Machine Learning? **Machine learning** is a part of artificial intelligence (AI) that focuses on developing algorithms that enable computers to learn from data and make predictions or decisions without being explicitly programmed. In other words, machine learning is about creating systems that can automatically learn and improve from experience. We can think of machine learning as teaching computers to learn from examples. Instead of giving them specific instructions for every task, we show them lots of examples (data) and let them figure out patterns on their own. It is like teaching a dog new tricks by showing it what to do and rewarding it when it gets it right. Therefore, our purpose is to “feed” our computer (or machine) with data in order for the machine to learn the patterns and provide us with an output. This final “product” is called a “machine learning algorithm”.
When we want to create a machine learning algorithm, we rely on predictive (or statistical) modeling and complex mathematics in order to guide the machine to learn the patterns from the data. Although they rely on statistics, these predictive modeling methodologies can also be referred as machine learning methodologies or techniques. For instance, in the next chapter we explain how we can create a machine learning algorithm based on the *KNN* methodology, a simple but effective machine learning technique. So, although machine learning and predictive modeling may seem similar terms, the latter actually is much broader. We can imagine a predictive model as a specific mathematical equation, which could be used in different machine learning algorithms.
But how could a machine learning algorithm use a mathematical equation in different ways? Well, a machine learning algorithm includes also other steps before or during the “teaching” process. So, even with the same data and predictive model, we can create different machine learning algorithms that can also be used for different purposes.
So, machine learning algorithms can identify patterns, classify information, and make predictions or decisions, often finding insights that humans might overlook or not have the capacity to process. It’s widely used in various fields, including image and speech recognition, natural language processing, healthcare, finance, and many others.
Supervised and Unsupervised Learning:
Machine Learning can be distinguished into two different categories: *Supervised Learning* and *Unsupervised Learning*. **Supervised Learning** is the type of machine learning that has a specific target (or dependent) variable. In our data set regarding customer churn, our target variable can be the “Churn” variable since our goal is to predict whether a customer churns or not. **Unsupervised Learning** is the type of machine learning that does not have any target variable. For instance, with the data set regarding customer churn, we could use the variables “Recency”, “Frequency” and “Monetary_Value” to create different clusters of the customers, such as “Good”, “Normal” and “Bad” customers. Because there is no specific target in this case, there is almost never a direct way to say whether our results are good or bad, in contract to supervised learning in which if we could always predict the correct value of our target variable most of the time, we know that we did a very good job.
Supervised Learning Types
As we mentioned, with supervised learning, we want to predict the outcome of a specific variable. The problems that we try to solve with supervised learning can be *regression* or *classification*. On the one hand, **regression** problems are the ones in which the target variable is continuous. For instance, we want to predict the net sales of our company in the next calendar year. Because this can be any number, our goal is to be as close to the actual value as possible. For instance, if the net sales were actually 350 million, we know that we did a good job if we had predicted net sales of 349.5 million, even if technically we did not predict the exact actual value correctly. On the other hand, **classification** problems are the ones in which the target variable is categorical. Although in R, the data type of a categorical variable can be character, factor or even numeric (as with the “Churn” variable), we know that each value means something different. For instance, the “Churn” variable has a value of 1 if a customer churns and 0 otherwise.
Classification problems can also be broken down into two different categories, based on the *nature of the problem*, or two different categories, based on the *nature of the output*. Because we talk about different values of a categorical variable, it is possible that our target variable has more that two categories, something that is known as a **multi-class classification**. For example, we would have a multi-class classification problem if we wanted to predict the “Frequency_Level” variable that has three different categories. When our target variable has only two classes, we say that we have a **binary classification** problem. Because machine learning algorithms can classify information, we may refer to these algorithms as **classifier**, a term that often used in academic research.
So, based on the target variable, we can have binary or multi-class classification. We mentioned though that classification problems can also be distinguished into two different categories based on their output. Instead of providing a specific class label (e.g. a customer churns or not), we can also provide a **probability outcome**, which would reflect our estimated probability that a customer churns. Although typically this is used for machine learning algorithms of classification, the procedure can be seen as we have a regression problem, since the probability can literally be any number within the boundaries of 0 and 1.
Regarding the terminology, we need to remember that the variable of interest (the one that we try to predict) can be called as target or dependent variable while the variables that we use to predict this dependent variable can be called predictors or independent variables.
Unsupervised Learning Types
Unsupervised Learning is the type of machine learning that we can use when we are interesting in **clustering** or **dimensionality reduction**. **Clustering** is about grouping our observations in different categories based on their similarities with each other. For instance, we can group our customers in different clusters such as “Frequent buyers” and “Newcomers”. In that case, we would use variables such as number of historical purchases to cluster the customers into segments that would make sense. **Dimensionality reduction** is about, as a the name implies, decreasing the mutli-dimensional space. In simpler and practical terms, we try to combine our variables into fewer variables that make more sense. For instance, suppose that we have a data set regarding information of patients and we have two columns that measure weight and body mass index (BMI). BMI is a metric that takes into account the weight and the height of a person and reflects a number based on which we can conclude whether a person is overweight, average or underweight (e.g. high BMI indicates that a person is overweight). In this case, it would probably be much better to just keep only one column or use unsupervised learning to combine the weight and the BMI columns into one (we should not forget that the BMI column still includes information about the height as well).
