DEV Community

Aadit Kamat
Aadit Kamat

Posted on

Some basic Machine Learning concepts

Background

Machine learning is a discipline that uses mathematical tools like linear algebra, statistics and calculus under the hood to mainly explore problems related to prediction: predict the price of an index fund, predict the weather tomorrow and so on.

The field has grown in popularity and sees application in a diverse number of fields today largely due to two factors: growing computational power and larger, high-quality data sets (big data) that allow us to make better predictions.

Machine Learning tries to solve two categories of problems: estimation and generalization.

Estimation refers to the problem of trying to guess the value of a variable when you are faced with noisy data, which is usually the case when you are dealing with real-world data. This is a problem that appears commonly in statistics.

Generalization, on the other hand, is based upon the principle of induction: you can formulate hypothesis (prediction) about future data based on past data.

Supervised and Unsupervised Learning

Most Machine Learning algorithms fall under two categories: Supervised Learning and Unsupervised Learning.

As the name suggests, Supervised Learning algorithms require input (supervision) from the humans before they can be executed. Humans provide this input in the form of labelled examples in the training data set.

Some types of supervised learning algorithms:

  1. Classification: The output of the algorithm for each data point is the category to which the data point should belong. The classification can be binary when two categories are involved or multi-class when multiple categories are involved. Examples: Tagging someone based on previously labelled photos, recommending new songs based on feedback for songs in the history

  2. Regression: The output of the algorithm for each data point lies within a range of values in a continuous domain. Examples: Predicting height and weight, predicting weather of a place on a certain day

Unsupervised Learning algorithms, on the other hand, try to identify underlying patterns in the data instead of relying on human input to detect these patterns. Some types of unsupervised learning algorithms are as follows:

  1. Clustering: identify clusters of data points that are closely related by virtue of being closely located in a n-dimensional landscape such as a scatterplot

  2. Density estimation: Given a set of data points, identify the probability of the random variable representing the Independent and Identically Distributed (IID) population from which these data points are drawn

  3. Dimensionality reduction: While visualizing points in higher dimensions, it usually helps to boil the distribution down to lower dimensions (fewer variables involved in the prediction) and that is where dimensionality reduction techniques come in handy.

Evaluation

We need some way to tell whether our predictions are in the right direction or not. When we have access to the actual values of the mathematical function representing the data that we are trying to learn, we make use of loss or error functions to see how far our estimates are from the actual values. A good prediction is one that tries to minimize the loss function.

Before we do this, however, we usually split our input data for a learning algorithm into three sets: training data, test data and validation data. The training data is used by the machine learning algorithm to form a prediction which is then tested out on the test data set. The validation data sets come in handy to ensure that the model is not overfitting the training data. This happens when the model has many parameters and learns the training data set exactly (memorizes it) which leads to a zero error on the test data set.

The types of loss functions that you typically encounter are:

  1. Absolute function ( yactualyguess|y_{actual} - y_{guess}| )
  2. Square function ( (yactualyguess)2(y_{actual} - y_{guess})^2 )
  3. Linear function( (yactualyguess)(y_{actual} - y_{guess}) )

Model selection

The model for a given data set is very specific to that dataset: the parameters for that model have specific values. It is usually picked from a class of models. For example, linear functions form a model class, while the linear function used as a classifier for the data set is a model selected from that class.

Learning algorithm

It is easy to confuse Machine Learning algorithms with Machine Learning models because the terms are often used in conjunction. They are related concepts, but they are vastly different from each other.

Learning algorithms are usually designed such that you start with a naive model in a learning algorithm. The learning algorithm then looks to optimize the model by varying the hyperparameters (also known as "hyperparameter tuning"): parameters specific to the algorithms that are not accessible to the models. This kind of optimisation enables models to be able to describe the data better, for example, by trying to minimize the loss function.

Top comments (0)