Regression is a key concept in machine learning and one that features prominently in the AI-900 Microsoft Azure AI Fundamentals exam. In contrast to classification, which subdivides data into various categories, regression analysis seeks to establish a relationship between dependent and independent variables, making it a suitable technique for predicting numeric values.

### Understanding Regression Analysis

Regression analysis involves implementing statistical techniques that make it possible to predict continuous, real-world quantities, like weight, temperature, and time. It functions by finding the relationship amid variables. In machine learning, this is accomplished by approximating a mapping function from input variables to numerical output variables.

For a regression problem, the algorithm’s model is tasked with predicting a single numeric quantity, such as product price or number of sales. The model will analyse features – characteristics or properties of an item, like size, brand, or material – to generate the outcome.

### Types of Regression in Machine Learning

Regression techniques can be classified into:

**Linear regression:**If the data points can be approximated by a straight line, then a linear drawing fits them best. The aim is to lessen the total difference between actual and predicted responses.- Simple linear regression: Models the relationship between two variables by fitting a linear equation to observed data.
- Multiple linear regression: Models the relationship between two or more features and a response by fitting a linear equation to observed data.

**Polynomial regression:**This utilizes a polynomial equation to capture the relationship between independent and dependent variables.**Ridge regression:**This type of regression adds a degree of bias to the regression estimate, which can decrease variability and increase efficiency.**Lasso regression:**This secures the absolute sum of the regression coefficients under a specified limit, generally denoted by a value ‘s’. Its goal is to procure the subset of predictors that minimises prediction error.

The selection of the regression type will depend on the problem at hand and the nature of the data.

### Examining Near-Real-Time Predictive Analytics

In real-world scenarios, regression can be leveraged for predictive analytics that are near real-time. For instance, in predictive maintenance, regression can be instrumental in predicting how many more cycles an aircraft engine has before it will require maintenance. This is an instance of multiple linear regression where several features (like operational settings, temperature, and pressure) of the engine are used to predict cycles before failure, the outcome.

Be aware that regression is not exclusively used for mapping inputs to continuous values – logistic regression is a machine learning algorithm that maps predicted values to probabilities over a binary outcome, providing a method of performing binary classification.

### Regression and Azure AI

Microsoft Azure AI supports regression, including linear regression, which is available in Azure Machine Learning. Additionally, AutoML in Azure supports various regression models, and will automatically fine-tune hyperparameters, cross-validate, and score your regression models for you, drastically simplifying the process.

### Regression Machine Learning Scenarios Recap

In conclusion, regression is a powerful machine learning technique used for predicting numeric values, and understanding this fundamental concept is crucial for the AI-900 Microsoft Azure AI Fundamentals exam.

Remember, if the aim is to predict numeric values, regression will be the approach to take. But, if the aim is to assign inputs into different categories or classes, then classification algorithms will be the best fit.

## Practice Test

### Regression machine learning algorithms are only used for categorical data predictions.

- 1) True
- 2) False

**Answer:** 2) False

**Explanation:** Regression algorithms are typically used for continuous quantity predictions, not categorical data.

### Regression is often used to predict values, such as sales, price, etc.

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** Regression is a type of supervised learning that is often used to predict continuous values.

### Which of the following are examples of regression machine learning scenarios? Select all that apply.

- 1) Predicting house prices based on square footage.
- 2) Predicting the weather temperature for the next week.
- 3) Classifying emails as spam or not spam.
- 4) Determining customer segments based on their behavior.

**Answer:** 1) Predicting house prices based on square footage, 2) Predicting the weather temperature for the next week.

**Explanation:** The first two options involve predicting continuous values, which is a common use of regression algorithms.

### Logistic regression is used to predict continuous variables.

- 1) True
- 2) False

**Answer:** 2) False

**Explanation:** Logistic regression is used for classification problems, not continuous variable predictions.

### Can regression machine learning be used in Azure Automated Machine Learning?

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** Azure Automated Machine Learning supports both classification and regression machine learning models.

### Is Linear Regression a type of Supervised Learning?

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** Linear Regression is a type of Supervised Learning where we have a dependent variable that needs to be predicted from the independent variables.

### Regression problems are problems with continuous and unbounded outputs.

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** Regression problems indeed aim to predict output of a continuous value.

### Machine learning regression can be used to predict the category of an item.

- 1) True
- 2) False

**Answer:** 2) False

**Explanation:** Regression is typically used for predicting a continuous amount, not a category. Classification problems deal with predicting categories.

### Which of the following are true about the mean square error (MSE) in regression analysis?

- 1) The MSE is calculated by taking the average of the squared differences between the predicted and actual values.
- 2) The lower the MSE, the better the accuracy of the regression model.
- 3) The MSE can be negative.
- 4) All of the above.

**Answer:** 1) The MSE is calculated by taking the average of the squared differences between the predicted and actual values, 2) The lower the MSE, the better the accuracy of the regression model.

**Explanation:** The MSE is a measure of prediction accuracy in regression analysis. It is always non-negative, and lower values are better.

### In the context of machine learning, regression models can be built using Azure Machine Learning designer.

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** Azure Machine Learning designer supports a wide variety of machine learning tasks, including regression.

### The output of a regression machine learning model is categorical.

- 1) True
- 2) False

**Answer:** 2) False

**Explanation:** The output of a regression model is numerical or continuous, not categorical.

### Overfitting is a scenario where a regression model performs well on training data but poorly on unseen data.

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** Overfitting is a common problem in machine learning where a model learns the detail and noise in the training data to the extent that it negatively impacts the performance of the model on new data.

### You can improve the performance of a regression model by introducing more features.

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** Sometimes, introducing more relevant features can improve the accuracy of a model, but it risks making the model too complex, which could lead to overfitting.

### Regression machine learning scenarios in Azure are mostly applied to scenarios with clear cause-effect relationships.

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** In most cases, regression models are used when there is a supposed cause-effect relationship between the independent and dependent variables.

### Is it possible to use regression techniques for time series data analysis in Azure AI?

- 1) True
- 2) False

**Answer:** 1) True

**Explanation:** Regression techniques can be applied to time series data to predict future values based on past trends.

## Interview Questions

### What does regression in machine learning refer to?

Regression in machine learning is a type of supervised learning approach in which the model learns from observed data to predict continuous output variables.

### How does linear regression work in machine learning?

Linear regression works by fitting a linear equation to observed data so as to determine the relationship between the dependent and independent variables. The goal is to find the line that best fits the points in the dataset.

### In a regression machine learning scenario, what is a dependent variable?

A dependent variable, also known as the outcome or response variable, is the variable we seek to predict or explain using the model.

### Which Azure Machine Learning service provides tools to run regression analysis?

Azure Machine Learning Studio provides tools to run Regression Analysis. It is a robust and simplified cloud-based tool allowing developers and data scientists to build, train and deploy models rapidly.

### Is the Azure Machine Learning service used for classification tasks as well?

Yes, the Azure Machine Learning service can be used for both Classification and Regression tasks.

### What is multivariate regression?

Multivariate regression is a method used in machine learning when there are more than one independent variable, meaning that there are multiple variables influencing the output.

### When should regression be used in machine learning?

Regression should be used when we want to predict a continuous output variable from the input variables. It is usually used when the covariates and the output have a linear relationship.

### What types of regression does Azure machine learning support?

Azure Machine Learning supports multiple types of regression, including Linear Regression, Decision Forest Regression, Boosted Decision Tree Regression, and others.

### Can regression analysis be used with time series data in Azure Machine Learning?

Yes, regression analysis can be used with time series data in Azure Machine Learning, although other techniques that specifically handle temporal data, like ARIMA, might be better suited.

### What is Poisson regression and does Azure support it?

Poisson regression is used for models where the dependent variable is a count and follows a Poisson distribution. Yes, Azure does support Poisson regression.

### What are examples of continuous output in a regression machine learning scenario?

Continuous output variables in a regression scenario could be things like predicting sales amounts, predicting house prices, or estimating product demand.

### What is decision tree regression in machine learning?

Decision Tree Regression is a machine learning algorithm where a tree-like model of decisions is built to predict the value of a target variable by learning decision rules inferred from the data features.

### What is the purpose of splitting data into training and test sets in a regression scenario?

In a regression scenario, the purpose of splitting data into training and test sets is to assess the model’s predictive performance. The model learns from the training set, and its predictive power is validated on the unseen test set.

### What happens if I use regression techniques on a classification task in machine learning?

Using regression techniques on a classification problem could yield less accurate results because the output of the regression model is continuous, while classification problems require a categorical output.

### Can regression models handle categorical data in Azure Machine Learning?

Yes, categorical data can be used in regression models in Azure Machine Learning, but they usually need to be encoded or transformed beforehand, using techniques like one-hot encoding.