All Categories

Data Science & ML

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

Mean Squared Error (MSE)

Basic
MSE=1ni=1n(yiy^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=1ni=1n(yiy^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=1ni=1nyiy^iMAE = \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(yiy^i)2(yiyˉ)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=2PrecisionRecallPrecision+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+ex\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)=ezij=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^)+(1y)log(1y^)]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θ=ABAB\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(aibi)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=1naibid = \sum_{i=1}^{n}|a_i - b_i|

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

View details

Shannon Entropy

Advanced
H=i=1npilog2piH = -\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=1i=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=xxminxmaxxminx' = \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×logNdftw_{t,d} = tf_{t,d} \times \log\frac{N}{df_t}

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

View details