Blog

Machine_learning_image

Category: Expert stories

Machine Learning Algorithm: Linear Regression

Linear regression is one of the most popular algorithms in both Statistics and Machine Learning. It is the simplest type of Machine Learning Algorithm.

The article on Linear Regression is the first of a set of blog articles that will go into this level of detail about different aspects of Machine Learning.

By Alan Lehane, Developer

Following on from my previous blog: Machine learning in theory:

Creating a full stack application with a Machine Learning Component hosted on Microsoft's Azure Platform

This article will go into more technical detail about a specific type of Machine Learning Algorithm: Linear Regression.

Linear regression is one of the most popular algorithms in both Statistics and Machine Learning. It is the simplest type of Machine Learning Algorithm. This means that it is a good place to start. In this blog, I am going to explain how ML Algorithms work in general using Linear Regression as an example.

This type of algorithm is best used to predict trends or to find correlations in data sets. It is best trained using a supervised learning environment.

One would use a linear Regression algorithm to establish a linear connection between the input variables(x) and an output variable(y). For example, the output variable can be calculated using a linear combination of the input variables.

Linear_regression

What does Training / Learning Mean?

When a linear regression algorithm learns/trains on a data set, basically the algorithm is trying to work out what the Coefficients of the Linear Equation should be.

 

Supervised Learning

Supervised learning refers to the type of dataset used to train the ML algorithm. In a supervised dataset, the output variable(y) of each piece of example data in the dataset is a known value. I will cover unsupervised learning in a future blog.

 

Example – Predicting house prices

If I am training an algorithm to predict house prices in my area, I would gather a dataset of houses that have previously been sold in my area.

I would gather as many features of the sold houses as I could, certain features are more important than others, but all features play some role so the more the better.

Linear_regression_table

In our example, our goal is a linear equation that will predict the selling price of a house in the future.

Linear_regression_2

When training our example the ML Model will iterate through the dataset, inserting the input values into the formula and the model will compare its predicted price to the actual price. If the predicted price and the actual price differ the model will adjust the coefficients and continue.

This process will continue for a set number of iterations or until an accuracy threshold has been achieved. The amount that the coefficient is altered depends on the type of Linear Regression Algorithm used.

Dealing with Non-Discrete Input Variables?

Typically, non-discrete (non-numerical) input or output variables are assigned a numeric value to represent each possible option of the variable.

For example: For the Color input variable, White=1, Yellow=2, Red=3 etc. For binary input variables like Garage: No=-1 & yes=1.

Types of Linear Regression

 

Ordinary Least Squares

Ordinary Least Squares attempts to minimize the sum of the square residuals. Imagine our dataset as a 2d Matrix of points where each point in the matrix is an example in our dataset. OLS attempts to draw a line through the matrix that has the shortest distance from the line to every point in the matrix.

 

Gradient Descent

With Gradient descent the coefficients are initially determined randomly, they are then adjusted depending on the learning rate (α), which is set by the user. The coefficient is adjusted in the direction of reducing the error.

 

Regularization

Regularization attempts to reduce the complexity of the model while also reducing the error at the same time. 2 examples of Regularization are:

 

Lasso Regression

Lasso Regression is a modified OLS that also minimizes the absolute sum of the coefficients.

 

Ridge Regression

Ridge Regression is also a modified OLS that minimizes the squared absolute sum of the coefficients.

 

Conclusion

In this blog, we learned:

  • Detailed Information about Linear Regression
  • Different types of Linear Regression
  • Machine Learning Terminology and Concepts

Alan Lehane, Software Developer
Alan has been working with Aspira for 4 years as a Software Developer, specialising in Data Analytics and Machine Learning. He has provided a wide variety of services to Aspira’s clients including Software Development, Test Automation, Data Analysis and Machine Learning.

 

Blog

More insights

left-arrow
right-arrow

The agile transformation of a large enterprise is a complex process that requires profound changes in leadership, structure, and corporate culture.
Expertise strategy
Projects & Implementation
Tech & Development

Developments of AI in Project Management

This article discusses how the integration of artificial intelligence (AI) and machine learning (ML) into project management is driving a cultural shift towards innovation and agility within organizations.

Tech & Development
Trends

From Sci-fi to Reality: The future of the automotive industry

Discover the future of the automotive industry with insights into the rise of autonomous driving, electric vehicles, and AI innovations. Learn about new regulations, industry challenges, and groundbreaking technologies transforming transportation and car manufacturing.

Data & Analytics
Expertise strategy
Tech & Development

New EU Act on Artificial Intelligence

Learn the ins and outs of the world’s first comprehensive legal framework on AI, the new EU AI Act and its anticipated impact on businesses.

Expert stories
Tech & Development

How to ensure the best collaboration between developer and tester

This article discusses practical strategies to align development requirements with actionable tasks, aiming for more efficient development cycles and better collaboration in the team.

Data & Analytics
Expert stories
Tech & Development

Exploring AI’s capability for app development

Software developer & emagineer explores the possibilities of building an application prototype with Chat GPT in this step-by-step guide.

Expert stories
Tech & Development

Different approaches to generating front-end code

From simplifying HTTP requests to optimizing data mapping, front-end developer and emagineer Kamil Naja discusses the different approaches to generating front-end code.

Dodging Agile Buzzwords for Meaningful Change
Tech & Development

On-demand webinar: Dodging Agile buzzwords for meaningful change (sign-up)

Watch our on-demand webinar on how to increase time to market by more than 25% while improving quality, featuring Danfoss E-commerce.

webinar graphic
Data & Analytics
Tech & Development

On-demand webinar: Intelligent Automation & Advanced Analytics

Dive deep into the dynamic duo of Intelligent Automation and Advanced Analytics. Discover how they work hand-in-hand to streamline data processing, extract profound insights, and drive impactful business actions.

Expert stories
Tech & Development

Microsoft Dev Box

Join emagineer and software architect Mateusz Pruchniak as he explores Microsoft Dev Box, virtualized solution that enables IT engineers to quickly launch self-service workstations while maintaining centralized management.

illustration: How Intelligent Automation & Analytics Drive Results
Data & Analytics
Tech & Development

On-demand webinar: From Data to Decisions – How Intelligent Automation & Analytics Drive Results

On-demand webinar for attendees:
We dive deep into the dynamic duo of Intelligent Automation and Advanced Analytics. Discover how they work hand-in-hand to streamline data processing, extract profound insights, and drive impactful business actions. The topics will include real-life case studies, expert insights, and the latest trends.

Data & Analytics
Expert stories
Tech & Development

The Future of AI

We constantly hear that AI will take control of everything and that we as humans will become less necessary or even redundant—is that really the case? In the following article, Cloud Administrator and emagineer Paweł Pancerz discusses how this revolution will unfold in the near future.

Client cases
Tech & Development

Voice recognition in vehicles

How does voice recognition function in vehicles, and what technologies and expertise drive its success? Let’s delve into the future by exploring what goes on behind the cockpit.

Code
Expert stories
Succeed as a consultant
Tech & Development

Effective ways to work with Backend

In the realm of front-end solutions, the vital role of back-end applications cannot be overstated. In this article, emagineer Kamil Naja delves into the world of backend development, uncovering effective methods to optimize the process.

Publications
Tech & Development

Ebook: The AI Paradox

Explore how businesses can strike a balance between embracing AI’s immense potential and maintaining the human touch that fosters trust and connection.

code illustration
Data & Analytics
Expert stories
Tech & Development

Machine Learning Algorithm: Logistic Regression

Logistic Regression is a Linear Model for classification; a traditional linear model is used to predict a numerical value. Learn how logistic Regression works and how it differs from Linear Regression.

Strategy, change & transformation
Tech & Development

Invite webinar: Empower Transitions: Cultivating a Knowledge-Sharing Culture in IT

Join us in this webinar as we delve into the intricacies of IT transitions, spotlighting the key players: the customer, the outgoing vendor, and the incoming vendor.

Data & Analytics
Expert stories
Tech & Development

How to leverage Robotic Process Automation (RPA) to drive business growth

Automation and RPA is on the rise as businesses vie to remain competitive. Understand the factors driving this trend as companies work to stay ahead of the curve.

Illustration of idea with a light bulb on top of an ipad
Data & Analytics
Tech & Development
Trends

The role of artificial intelligence is transforming the banking industry

Artificial intelligence (AI) is revolutionising the banking industry by transforming how banks operate, interact with their customers, and influence decisions. A key benefit often discussed is the noteworthy cost savings leveraged by AI tools, but what are the others?

Illustration of a decision tree
Data & Analytics
Tech & Development

Example of non-Linear Machine Learning Algorithms: Decision Trees

In this blog, I give a simple overview and an example of a non-linear Algorithm, Decision Trees, how they work and how they are created. Part of the Machine Learning Blog Series.

Data & Analytics
Expert stories
Tech & Development

Machine Learning Algorithm: Linear Regression

Linear regression is one of the most popular algorithms in both Statistics and Machine Learning. It is the simplest type of Machine Learning Algorithm. This means that it is a good place to start. In this blog, Allan Lehane is going to explain how ML Algorithms work in general using Linear Regression as an example.

Expertise strategy
Tech & Development

The Complete Guide to Migrating Monolithic Applications to Microservices on the Cloud

As organizations strive to deliver high-quality software and services at scale, many are turning to a microservices architecture as a way to break down monolithic applications into smaller, more manageable components.

Expert stories
Tech & Development

Creating a full stack application with a Machine Learning Component hosted on Microsoft’s Azure Platform

In this article we are going to discuss how a Machine Learning algorithm works in theory and I’m also going to discuss an example of a full stack application with a Machine Learning Component, which is hosted on Microsoft Azure.