<commit_before>---
layout: post
title: "Linear Regression"
author: "HzCeee"
categories: Machine Learning
tags: [ML Algorithm]
image:
  feature: 
  teaser: 
  credit:
  creditlink:
---

Given a training set with $m$ training examples $\{ (x^{(i)}, y^{(i)}); i = 1, \cdots , m \}$ where $x^{(i)} = (x_1^{(i)}, x_2^{(i)}, \cdots , x_n^{(i)})^T$ and $y^{(i)}$ denotes the target variable, to learn a function $h : \mathcal{X} \mapsto \mathcal{Y}$ so that $h(x)$ is a good predictor for the corresponding value of $y$.

Approximate $y$ as a linear function of $x$, then

$$
h_{\theta}(x) = \theta_0 + \theta_1 x_1 + \theta_2 x_2 + \cdots + \theta_n x_n
$$

To simplify the notation, let $h_{\theta}(x) = h(x)$ and $\theta$ be the $n + 1$-dimensional vector as $\theta = (\theta_0, \theta_1, \cdots, \theta_n)^T$ and introduce the intercept term $x_0 = 1$, so that

$$
h(x) = \sum_{i = 0}^{n} \theta_i x_i = \theta^T x \\\\
x = (x_0, x_1, \cdots, x_n)^T
$$

where $n$ is the number of features (not counting $x_0$).

Define the design matrix $X$ to be $m$-by-$n + 1$:

$$
X =
\begin{bmatrix}
x^{(1)}_0 & x^{(1)}_1 & \cdots & x^{(1)}_n \\\\
x^{(2)}_0 & x^{(2)}_1 & \cdots & x^{(2)}_n \\\\
\vdots \\\\
x^{(m)}_0 & x^{(m)}_1 & \cdots & x^{(m)}_n \\\\<commit_msg>Update 2017-08-30-Linear-Regression.md<commit_after>---
layout: post
title: "Linear Regression"
author: "HzCeee"
categories: Machine Learning
tags: [ML Algorithm]
image:
  feature: 
  teaser: 
  credit:
  creditlink:
---

Given a training set with $m$ training examples $\\{ (x^{(i)}, y^{(i)}); i = 1, \cdots , m \\}$ where $x^{(i)} = (x_1^{(i)}, x_2^{(i)}, \cdots , x_n^{(i)})^T$ and $y^{(i)}$ denotes the target variable, to learn a function $h : \mathcal{X} \mapsto \mathcal{Y}$ so that $h(x)$ is a good predictor for the corresponding value of $y$.

Approximate $y$ as a linear function of $x$, then

$$
h_{\theta}(x) = \theta_0 + \theta_1 x_1 + \theta_2 x_2 + \cdots + \theta_n x_n
$$

To simplify the notation, let $h_{\theta}(x) = h(x)$ and $\theta$ be the $n + 1$-dimensional vector as $\theta = (\theta_0, \theta_1, \cdots, \theta_n)^T$ and introduce the intercept term $x_0 = 1$, so that

$$
h(x) = \sum_{i = 0}^{n} \theta_i x_i = \theta^T x \\\\
x = (x_0, x_1, \cdots, x_n)^T
$$

where $n$ is the number of features (not counting $x_0$).

Define the design matrix $X$ to be $m$-by-$n + 1$:

$$
X =
\begin{bmatrix}
x^{(1)}_0 & x^{(1)}_1 & \cdots & x^{(1)}_n \\\\
x^{(2)}_0 & x^{(2)}_1 & \cdots & x^{(2)}_n \\\\
\vdots \\\\
x^{(m)}_0 & x^{(m)}_1 & \cdots & x^{(m)}_n \\\\
{'fraction_non_alphanumeric': 0.23410975128306355, 'fraction_numerical': 0.026845637583892617, 'mean_word_length': 3.4849557522123895, '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': '4653851', 'n_tokens_mistral': 1062, 'n_tokens_neox': 992, 'n_words': 319}