<commit_before>---
published: true
key: 04-02-2022
title: Linear Regression
tag:
  - Linear Regression
  - Machine Learning
---
## Linear Regression
Linear regression is a statistical method that tries to show a relationship between variables. It looks at different data points and plots a trend line. Linear regression attempts to model the relationship between two variables by fitting a linear equation to observed data. One variable is considered to be an explanatory variable, and the other is considered to be a dependent variable. For example, a modeler might want to relate the weights of individuals to their heights using a linear regression model. 
Simply stated, the goal of linear regression is to fit a line to a set of points. When the target variable that we’re trying to predict is continuous, we call the learning problem a regression problem.

![regression.png]({{site.baseurl}}/images/regression.png)

Let’s suppose we want to model the above set of points with a line. To do this we’ll use the standard y = mx + b line equation where m is the line’s slope and b is the line’s y-intercept. To find the best line for our data, we need to find the best set of slope m and y-intercept b values.

### Hypothesis
To describe the supervised learning problem slightly more formally, our goal is, given a training set, to learn a function h : X → Y so that h(x) is a “good” predictor for the corresponding value of y. For historical reasons, this function h is called a hypothesis.

![regression_hypothesis.png]({{site.baseurl}}/images/regression_hypothesis.png)

To perform supervised learning, we must decide how we’re going to represent functions/hypotheses h in a computer. As an initial choice, let’s say we decide to approximate y as a linear function of x:

![regression_hypothesis_equation.png]({{site.baseurl}}/images/regression_hypothesis_equation.png)

Here, the θ i ’s are the parameters (also called weights)

![regression_hypothesis_weight.png]({{site.baseurl}}/images/regression_hypothesis_weight.png)<commit_msg>Create 2022-02-04-linear-regression.md<commit_after>---
published: true
key: 04-02-2022
title: Linear Regression
tag:
  - Linear Regression
  - Machine Learning
---
## Linear Regression
Linear regression is a statistical method that tries to show a relationship between variables. It looks at different data points and plots a trend line. Linear regression attempts to model the relationship between two variables by fitting a linear equation to observed data. One variable is considered to be an explanatory variable, and the other is considered to be a dependent variable. For example, a modeler might want to relate the weights of individuals to their heights using a linear regression model. 
Simply stated, the goal of linear regression is to fit a line to a set of points. When the target variable that we’re trying to predict is continuous, we call the learning problem a regression problem.

![1_fX95txC9xSwSPeP6ch2nmg.gif]({{site.baseurl}}/images/1_fX95txC9xSwSPeP6ch2nmg.gif)

![regression.png]({{site.baseurl}}/images/regression.png)

Let’s suppose we want to model the above set of points with a line. To do this we’ll use the standard y = mx + b line equation where m is the line’s slope and b is the line’s y-intercept. To find the best line for our data, we need to find the best set of slope m and y-intercept b values.

### Hypothesis
To describe the supervised learning problem slightly more formally, our goal is, given a training set, to learn a function h : X → Y so that h(x) is a “good” predictor for the corresponding value of y. For historical reasons, this function h is called a hypothesis.

![regression_hypothesis.png]({{site.baseurl}}/images/regression_hypothesis.png)

To perform supervised learning, we must decide how we’re going to represent functions/hypotheses h in a computer. As an initial choice, let’s say we decide to approximate y as a linear function of x:

![regression_hypothesis_equation.png]({{site.baseurl}}/images/regression_hypothesis_equation.png)

Here, the θ i ’s are the parameters (also called weights)

![regression_hypothesis_weight.png]({{site.baseurl}}/images/regression_hypothesis_weight.png)
{'fraction_non_alphanumeric': 0.06416984732824428, 'fraction_numerical': 0.008587786259541985, 'mean_word_length': 4.7754820936639115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1197960', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1095, 'n_words': 581}