Mathematical Notations for Machine Learning (Markdown)

Krishna K
3 min readOct 17, 2020

--

Learning to write Mathematical notations is critical, when you are taking a note in your Machine Learning classes or building a custom ML algorithm.

Advantage of Markdown approach: you may use any IDE to write Markdown.

This article is focused on how to write mathematical notations for ML. So, I won’t be covering details of each algorithm. you will find most commonly used notations and how to write them below

Simple Linear Regression:

Using one variable to predict a value of other variable

$\hat{y}$ = $\theta_0 + \theta_1 x_1$
output

Mean Squared Error:

Mean of all Residual Errors shows how poorly the line fits with the data set

MSE = $\frac{1}{n} \Sigma_{i=1}^n({y}-\hat{y})^2$
output

Logistic Regression & Thresholds:

$\Theta^T$ X = $\theta_0$ + $\theta_1$ * $$x_1$$Threshold: (Step function)
- $\hat{y}$ = 0 if $\Theta^T$ X < 0.5
- $\hat{y}$ = 1 if $\Theta^T$ X $\ge$ 0.5
output

Sigmoid function:

$\Sigma(\Theta^TX)$ = $$\frac{1} {1 + e^-\Theta^Tx }$$
$\hat{y}$ = $\Sigma(\Theta^T X)$
output

Cost function:

$Cost(\hat{y}$, y) =  $\frac{1}{2}(\Sigma(\theta^TX)-y)^2$
output

Mean squared error for cost function:

J($\theta$) = $\frac{1}{m} \Sigma_{i=1}^{m} Cost(\hat{y}, y)$
output

Logistic Regression Cost function:

$J(\Theta)$ = -$\frac{1}{m} \Sigma_{i=1}^my^ilog(\hat{y}^i) + (1-y^i)log(1-\hat{y}^i)$
output

Finally, once you get used to writing mathematical notation for markdown it is much fun to work on Machine Learning algorithms

Happy Coding

For further learning — please checkout resources below:

--

--

Krishna K
Krishna K

Written by Krishna K

Data Scientist, The World Bank. I blog about data science, machine learning, and building web apps & APIs.