Skip to content

Commit

Permalink
Merge pull request #18 from mthorrell/better-equations
Browse files Browse the repository at this point in the history
Better equations
  • Loading branch information
mfrasco authored Apr 20, 2018
2 parents 72941c1 + ea092b5 commit 426aa55
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ If you notice anything wrong with the **Metrics** package or have any ideas on h

## What Metrics are Included in this Package?

All functions in the **Metrics** package take at least two arguments: `actual` and `predicted`. In the table below, I abbreviate `actual` as $x$ and `predicted` as $y$ for the sake of mathematical brevity.
All functions in the **Metrics** package take at least two arguments: `actual` and `predicted`. In the table below, I abbreviate `actual` as x and `predicted` as y for the sake of mathematical brevity.

| Metric Type | Metric Name | Function Name | Formula |
| ---- | ------------------------ | ---- | ------------------------------- |
| regression | Squared Error | se | $(x_i - y_i) ^ 2$ |
| regression | Mean Squared Error | mse | $\frac{1}{n} \sum_{i=1}^n (x_i - y_i) ^ 2$ |
| regression | Root Mean Squared Error | rmse | $\sqrt{\frac{1}{n} \sum_{i=1}^n (x_i - y_i)^ 2}$ |
| regression | Absolute Error | ae | $\lvert x_i - y_i \rvert$ |
| regression | Mean Absolute Error | mae | $\frac{1}{n} \sum_{i=1}^n \lvert x_i - y_i \rvert$ |
| regression | Absolute Percent Error | ape | $\frac{\lvert x_i - y_i \rvert}{x_i}$ |
| regression | Mean Absolute Percent Error | mape | $\frac{1}{n} \sum_{i=1}^n \frac{\lvert x_i - y_i \rvert}{x_i}$ |
| regression | Symmetric Mean Absolute Percent Error | smape | $\frac{2}{n} \sum_{i=1}^n \frac{\lvert x_i - y_i \rvert}{\lvert x_i \rvert + \lvert y_i \rvert}$ |
| regression | Squared Log Error | sle | $\big(\ln(1 + x_i) - \ln(1 + y_i)\big) ^ 2$ |
| regression | Mean Squared Log Error | msle | $\frac{1}{n} \sum_{i=1}^n \big(\ln(1 + x_i) - \ln(1 + y_i)\big) ^ 2$ |
| regression | Root Mean Squared Log Error | rmsle | $\sqrt{\frac{1}{n} \sum_{i=1}^n \big(\ln(1 + x_i) - \ln(1 + y_i)\big) ^ 2}$ |
| regression | Relative Squared Error | rse | $\Big[\sum_{i=1}^n (x_i - y_i) ^ 2\Big] / \Big[\sum_{i=1}^n (x_i - \bar{x}) ^ 2\Big]$ |
| regression | Root Relative Squared Error | rse | $\sqrt{\Big[\sum_{i=1}^n (x_i - y_i) ^ 2\Big] / \Big[\sum_{i=1}^n (x_i - \bar{x}) ^ 2\Big]}$ |
| regression | Relative Absolute Error | rse | $\Big[\sum_{i=1}^n \lvert x_i - y_i \rvert\Big] / \Big[\sum_{i=1}^n \lvert x_i - \bar{x} \rvert\Big]$ |
| time series | Mean Absolute Scaled Error | mase | $\Big[\sum_{i=1}^n \lvert x_i - y_i \rvert\Big] / \Big[\frac{n}{n - m} \sum_{i=1+m}^n \lvert x_i - x_{i-m} \rvert \Big]$|
| classification | Classification Error | ce | $\frac{1}{n} \sum_{i=1}^n I(x_i \neq y_i)$ |
| classification | Accuracy | accuracy | $\frac{1}{n} \sum_{i=1}^n I(x_i = y_i)$ |
| classification | F1 Score | f1 | $\frac{2 * \text{precision} * \text{recall}}{\text{precision} + \text{recall}}$ |
| binary classification | Area Under ROC Curve | auc | $\int_0^1 [1 - G_1(G^{-1}_0(1 - v))] dv$. `help(auc)` for details. |
| binary classification | Log Loss | ll | $x_i * \ln(y_i) + (1 - x_i) * \ln(1 - y_i)$ |
| binary classification | Mean Log Loss | logloss | $\frac{1}{n} \sum_{i=1}^n x_i * \ln(y_i) + (1 - x_i) * \ln(1 - y_i)$ |
| regression | Squared Error | se | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%28x_i-y_i%29%5E2) |
| regression | Mean Squared Error | mse | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20%28x_i%20-%20y_i%29%20%5E%202) |
| regression | Root Mean Squared Error | rmse | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Csqrt%7B%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20%28x_i%20-%20y_i%29%5E%202%7D) |
| regression | Absolute Error | ae | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Clvert%20x_i%20-%20y_i%20%5Crvert) |
| regression | Mean Absolute Error | mae | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20%5Clvert%20x_i%20-%20y_i%20%5Crvert) |
| regression | Absolute Percent Error | ape | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B%5Clvert%20x_i%20-%20y_i%20%5Crvert%7D%7Bx_i%7D) |
| regression | Mean Absolute Percent Error | mape | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20%5Cfrac%7B%5Clvert%20x_i%20-%20y_i%20%5Crvert%7D%7Bx_i%7D) |
| regression | Symmetric Mean Absolute Percent Error | smape | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B2%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20%5Cfrac%7B%5Clvert%20x_i%20-%20y_i%20%5Crvert%7D%7B%5Clvert%20x_i%20%5Crvert%20+%20%5Clvert%20y_i%20%5Crvert%7D) |
| regression | Squared Log Error | sle | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cbig%28%5Cln%281%20+%20x_i%29%20-%20%5Cln%281%20+%20y_i%29%5Cbig%29%20%5E%202) |
| regression | Mean Squared Log Error | msle | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20%5Cbig%28%5Cln%281%20+%20x_i%29%20-%20%5Cln%281%20+%20y_i%29%5Cbig%29%20%5E%202) |
| regression | Root Mean Squared Log Error | rmsle | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Csqrt%7B%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20%5Cbig%28%5Cln%281%20+%20x_i%29%20-%20%5Cln%281%20+%20y_i%29%5Cbig%29%20%5E%202%7D) |
| regression | Relative Squared Error | rse | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5CBig%5B%5Csum_%7Bi%3D1%7D%5En%20%28x_i%20-%20y_i%29%20%5E%202%5CBig%5D%20/%20%5CBig%5B%5Csum_%7Bi%3D1%7D%5En%20%28x_i%20-%20%5Cbar%7Bx%7D%29%20%5E%202%5CBig%5D) |
| regression | Root Relative Squared Error | rse | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Csqrt%7B%5CBig%5B%5Csum_%7Bi%3D1%7D%5En%20%28x_i%20-%20y_i%29%20%5E%202%5CBig%5D%20/%20%5CBig%5B%5Csum_%7Bi%3D1%7D%5En%20%28x_i%20-%20%5Cbar%7Bx%7D%29%20%5E%202%5CBig%5D%7D) |
| regression | Relative Absolute Error | rse | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5CBig%5B%5Csum_%7Bi%3D1%7D%5En%20%5Clvert%20x_i%20-%20y_i%20%5Crvert%5CBig%5D%20/%20%5CBig%5B%5Csum_%7Bi%3D1%7D%5En%20%5Clvert%20x_i%20-%20%5Cbar%7Bx%7D%20%5Crvert%5CBig%5D) |
| time series | Mean Absolute Scaled Error | mase | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5CBig%5B%5Csum_%7Bi%3D1%7D%5En%20%5Clvert%20x_i%20-%20y_i%20%5Crvert%5CBig%5D%20/%20%5CBig%5B%5Cfrac%7Bn%7D%7Bn%20-%20m%7D%20%5Csum_%7Bi%3D1+m%7D%5En%20%5Clvert%20x_i%20-%20x_%7Bi-m%7D%20%5Crvert%20%5CBig%5D)|
| classification | Classification Error | ce | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20I%28x_i%20%5Cneq%20y_i%29) |
| classification | Accuracy | accuracy | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20I%28x_i%20%3D%20y_i%29) |
| classification | F1 Score | f1 | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B2%20*%20%5Ctext%7Bprecision%7D%20*%20%5Ctext%7Brecall%7D%7D%7B%5Ctext%7Bprecision%7D%20+%20%5Ctext%7Brecall%7D%7D) |
| binary classification | Area Under ROC Curve | auc | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cint_0%5E1%20%5B1%20-%20G_1%28G%5E%7B-1%7D_0%281%20-%20v%29%29%5D%20dv). `help(auc)` for details. |
| binary classification | Log Loss | ll | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20x_i%20*%20%5Cln%28y_i%29%20+%20%281%20-%20x_i%29%20*%20%5Cln%281%20-%20y_i%29) |
| binary classification | Mean Log Loss | logloss | ![equation](https://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bi%3D1%7D%5En%20x_i%20*%20%5Cln%28y_i%29%20+%20%281%20-%20x_i%29%20*%20%5Cln%281%20-%20y_i%29) |

0 comments on commit 426aa55

Please sign in to comment.