All Categories

Data Science & ML

Machine learning metrics, loss functions, and statistical learning formulae.

This Data Science & ML formula category brings together the key metrics, loss functions, and statistical learning equations used to build, evaluate, and improve machine learning models. It’s designed to help students, exam-takers, and working data professionals quickly understand and apply essential formulas like MSE, precision, recall, F1 score, and activation functions, which are crucial for measuring performance and making better predictions in real-world projects.

Mean Squared Error (MSE)

Basic
MSE=1n∑i=1n(yi−y^i)2MSE = \frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2

Average of squared differences between predicted and actual values.

View details

Root Mean Squared Error (RMSE)

Basic
RMSE=1n∑i=1n(yi−y^i)2RMSE = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2}

Square root of MSE, in the same units as the target variable.

View details

Mean Absolute Error (MAE)

Basic
MAE=1n∑i=1n∣yi−y^i∣MAE = \frac{1}{n}\sum_{i=1}^{n}|y_i - \hat{y}_i|

Average of absolute differences between predictions and actual values.

View details

Coefficient of Determination (R²)

Intermediate
R2=1−∑(yi−y^i)2∑(yi−yˉ)2R^2 = 1 - \frac{\sum(y_i-\hat{y}_i)^2}{\sum(y_i-\bar{y})^2}

Proportion of variance in the target explained by the model.

View details

Classification Accuracy

Basic
Accuracy=TP+TNTP+TN+FP+FNAccuracy = \frac{TP + TN}{TP + TN + FP + FN}

Fraction of predictions that are correct.

View details

Precision

Intermediate
Precision=TPTP+FPPrecision = \frac{TP}{TP + FP}

Of all positive predictions, the fraction that were correct.

View details

Recall (Sensitivity)

Intermediate
Recall=TPTP+FNRecall = \frac{TP}{TP + FN}

Of all actual positives, the fraction correctly identified.

View details

F1 Score

Intermediate
F1=2⋅Precision⋅RecallPrecision+RecallF_1 = 2\cdot\frac{Precision \cdot Recall}{Precision + Recall}

Harmonic mean of precision and recall.

View details

Specificity

Intermediate
Specificity=TNTN+FPSpecificity = \frac{TN}{TN + FP}

Of all actual negatives, the fraction correctly identified.

View details

Sigmoid Function

Intermediate
σ(x)=11+e−x\sigma(x) = \frac{1}{1 + e^{-x}}

Maps any real number to the range (0, 1); used in logistic regression.

View details

Softmax Function

Advanced
σ(zi)=ezi∑j=1Kezj\sigma(z_i) = \frac{e^{z_i}}{\sum_{j=1}^{K} e^{z_j}}

Converts a vector of scores into a probability distribution.

View details

ReLU Activation

Basic
f(x)=max⁡(0,x)f(x) = \max(0, x)

Rectified Linear Unit: outputs the input if positive, else zero.

View details

Binary Cross-Entropy Loss

Advanced
L=−1n∑[ylog⁡(y^)+(1−y)log⁡(1−y^)]L = -\frac{1}{n}\sum[y\log(\hat{y}) + (1-y)\log(1-\hat{y})]

Loss function for binary classification.

View details

Gradient Descent Update

Advanced
θ=θ−α∇J(θ)\theta = \theta - \alpha \nabla J(\theta)

Iterative optimization step to minimize a cost function.

View details

Cosine Similarity

Intermediate
cos⁡θ=A⋅B∥A∥∥B∥\cos\theta = \frac{A \cdot B}{\|A\|\|B\|}

Measures similarity between two vectors by the angle between them.

View details

Euclidean Distance

Basic
d=∑i=1n(ai−bi)2d = \sqrt{\sum_{i=1}^{n}(a_i - b_i)^2}

Straight-line distance between two points in n-dimensional space.

View details

Manhattan Distance

Basic
d=∑i=1n∣ai−bi∣d = \sum_{i=1}^{n}|a_i - b_i|

Distance measured along axes at right angles (taxicab geometry).

View details

Shannon Entropy

Advanced
H=−∑i=1npilog⁡2piH = -\sum_{i=1}^{n} p_i \log_2 p_i

Measures the uncertainty or information content of a distribution.

View details

Gini Impurity

Intermediate
Gini=1−∑i=1npi2Gini = 1 - \sum_{i=1}^{n} p_i^2

Probability of misclassifying a random element; used in decision trees.

View details

Z-Score Normalization

Basic
z=x−μσz = \frac{x - \mu}{\sigma}

Standardizes features to zero mean and unit variance.

View details

Min-Max Normalization

Basic
x′=x−xminxmax−xminx' = \frac{x - x_{min}}{x_{max} - x_{min}}

Rescales features to the range [0, 1].

View details

Bias-Variance Decomposition

Advanced
Error=Bias2+Variance+σ2Error = Bias^2 + Variance + \sigma^2

Total expected error decomposes into bias, variance, and irreducible noise.

View details

Categorical Cross-Entropy

Advanced
L=−∑i=1Kyilog⁡(y^i)L = -\sum_{i=1}^{K} y_i \log(\hat{y}_i)

Loss for multi-class classification with one-hot labels.

View details

TF-IDF Weight

Intermediate
wt,d=tft,d×log⁡Ndftw_{t,d} = tf_{t,d} \times \log\frac{N}{df_t}

Term importance: frequency in a document scaled by rarity across documents.

View details