Understanding Regularization in Machine Learning

Written by Coursera Staff • Updated on

Learn what machine learning is and why regularization is an important strategy to improve your machine learning models. Plus, learn what bias-variance trade-off is and how lambda values play in regularization algorithms.

[Featured Image] A group of machine learning engineers gather around a desk to talk about regularization.

Machine learning is an exciting field projected to grow over the next decade. Learning about machine learning algorithms and methods, such as regularization, can build your knowledge base in this expanding field and open yourself to new opportunities. In this article, we explore what machine learning is, which errors regularization addresses, and careers to consider when entering the machine learning space.

What is machine learning?

Machine learning is a subset of artificial intelligence (AI) focused on building systems that can imitate human decision-making and thinking. It involves algorithms that can identify underlying patterns within data, make predictions, or help make decisions. You’ve likely seen machine learning algorithms used daily, like streaming service suggestions, predictive texts, language translation services, and even autonomous vehicles.

Machine learning differs from traditional computer programs because the algorithms can make decisions and inferences without being explicitly programmed to perform specific tasks. Instead, the algorithm is “trained” on certain data or tasks and given feedback on performance. Over time, the machine learns from the feedback and can generalize to more complex data sets or operations. This learning process is either classified as supervised or unsupervised machine learning. 

Supervised machine learning

Supervised machine learning models have labeled data sets that guide the learning process. The algorithm uses the training data to learn how to predict new data. Over time, the machine expands beyond the training data set and applies the method to additional inputs. Supervised machine learning algorithms typically use methods such as logistic regression, linear regression, decision trees, or neural networks.

Unsupervised machine learning

Unsupervised machine learning is a training method where the machine learns the structure and patterns in the data on its own. Instead of being given the guidance of a trained data set and desired outcomes, the algorithm independently identifies the underlying features of the data. When building an unsupervised learning algorithm, you will likely use clustering, association rule learning, probability density, dimensionality reduction, or similar methods.

What is overfitting?

In machine learning, a machine learning model is overfitting when it only produces accurate outputs on its training data but not on new data. This can happen with supervised machine learning in cases where the training data set is too limited and specific, the training data set has a high volume of irrelevant information (noise), the training period on a small set of data is too long, or the complexity of the model is too high and learns the noise alongside the main training data. 

For example, let’s say you are training your machine learning model to identify the color red. To train the model to identify the color red, you pull several photos from the internet that contain the color red. However, you don’t realize that most of the photos in your training set are of flowers. Instead of learning the color red by itself, the model associates “red” with flowers. When you show the model pictures of a red coat or a red flag, an overfitted model would not recognize the color. 

To determine whether your model is overfitting, you should test your model on a set of data outside of your training data. This is a “test” data set. If your model is overfitting, you will likely see a low error rate in your training data set and a high error rate in your test data. 

What is regularization in machine learning?

Regularization is a set of methods used to reduce overfitting in machine learning models. The overall idea of regularization is to help models determine the key features of the data set without fixating on noise or irrelevant detail. Regularization methods typically focus more on generalizability outside of training data sets than the accuracy of the model. The result of regularization is a more balanced model. It may not perform perfectly on the training data, as it's not overly complex, but it will likely do better on new, unseen data, which is the ultimate goal of a practical machine learning model.

Bias-variance trade-off

As mentioned previously, an overfitted model is likely to have high training data accuracy but low testing data accuracy. Training data accuracy is lower with regularization, but testing data accuracy rises. This is a “bias-variance trade-off.” 

The term “bias” in regularization refers to the difference between the predicted and actual values. This is inherent to your algorithm model. As bias increases, the model predicts values that are farther away from the actual values of the training data set. 

When moving to test data, you can measure the “variance” of the model. This represents how specialized your model is regarding the training data itself. If variance increases, the model's predicted values on new testing data are farther away from the actual value. While the goal is for both bias and variance to be low, regularization focuses on lowering variance at the expense of bias being higher. 

Choosing a lambda value

In machine learning, lambda (λ) is a key parameter in regularization. The lambda value (also known as the regularization rate) you choose relates to how much complexity is allowed in the model without penalty. A higher lambda value means a stronger penalty, simplifying the model, while a lower lambda allows for more complexity.

Careers that use regularization

As you learn more about machine learning and techniques used within this field, you may decide to pursue a career in this area. Machine learning is a rapidly growing field utilized in a wide range of industries, leading to a variety of career opportunities. When deciding the right fit for you, consider the following careers that use machine learning:

  • Data scientist: Data scientists use data methods, such as machine learning, to build predictive models and make inferences. As a data scientist, the average annual base salary is $120,508 [1].

  • Machine learning engineer: Machine learning engineers design and maintain machine learning models using statistics, computer programming, and software engineering expertise. As a machine learning engineer, you can expect an average annual base salary of $127,712 [2]. 

  • AI research scientist: AI research scientists explore new methods and technologies in artificial intelligence and machine learning. An AI research scientist's average annual base salary is $140,823 [3].

Learn more on Coursera.

You can continue exploring machine learning with exciting courses on Coursera offered by leading universities and industry professionals. If you want to build a strong basis in machine learning and artificial intelligence foundations, consider the Supervised Machine Learning: Regression and Classification beginner-level course offered by DeepLearning.AI.

Article sources

1

Glassdoor. “How much does a Data Scientist make?, https://www.glassdoor.com/Salaries/data-scientist-salary-SRCH_KO0,14.htm.” Accessed March 20, 2024. 

Keep reading

Updated on
Written by:

Editorial Team

Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...

This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.