Metrics

The gtime.metrics module contains a collection of different metrics.

gtime.metrics.gmae(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the Geometric Mean Absolute Error between two vectors.

Parameters

y_truearray-like, shape (length, 1), required

The first vector.

y_predarray-like, shape (length, 1), required

The second vector.

Returns

gmae_valuefloat

The geometric mean absolute error between the two vectors.

Examples

>>> from gtime.metrics import gmae
>>> y_true = [0, 1, 2, 3, 6, 5]
>>> y_pred = [-1, 4, 5, 10, 4, 1]
>>> gmae(y_true, y_pred)
2.82
gtime.metrics.log_mse(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the Mean Squared Log Error(MSLE) between two vectors. Note: Log_mse accepts only positive numbers as input

Parameters

y_truearray-like, shape (length, 1), required

The first vector.

y_predarray-like, shape (length, 1), required

The second vector.

Returns

log_msefloat

The mean squared log error between the two vectors.

Examples

>>> from gtime.metrics import log_mse
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> log_mse(y_true, y_pred)
0.244
gtime.metrics.mae(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the Mean Absolute Error(also called, Mean Absolute Deviation(MAD) or Mean Ratio) between two vectors.

Parameters

y_truearray-like, shape (length, 1), required

The first vector.

y_predarray-like, shape (length, 1), required

The second vector.

Returns

mae_valuefloat

The mean absolute error between the two vectors.

Examples

>>> from gtime.metrics import mae
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> mae(y_true, y_pred)
1.033
gtime.metrics.mape(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the Mean Absolute Percentage Error(MAPE) between two vectors.

Parameters

y_truearray-like, shape (length, 1), required.

The first vector.

y_predarray-like, shape (length, 1), required.

The second vector.

Returns

mape_valuefloat

The mean absolute percentage error between the two vectors.

Examples

>>> from gtime.metrics import mape
>>> y_true = [1, 1, 2, 3, 4, 5]
>>> y_pred = [1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> mape(y_true, y_pred)
45.08
gtime.metrics.max_error(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the maximum error between two vectors.

Parameters

y_truearray-like, shape (length, 1), required

The first vector.

y_predarray-like, shape (length, 1), required

The second vector.

Returns

errorfloat

The maximum error between the two vectors.

Examples

>>> from gtime.metrics import max_error
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> max_error(y_true, y_pred)
1.6
gtime.metrics.mse(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the Mean Squared Error(MSE) between two vectors.

Parameters

y_truearray-like, shape (length, 1), required.

The first vector.

y_predarray-like, shape (length, 1), required.

The second vector.

Returns

msefloat

The Mean Squared Error between the two vectors.

Examples

>>> from gtime.metrics import mse
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> mse(y_true, y_pred)
1.20
gtime.metrics.non_zero_smape(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray], raise_error: bool = False) float

Compute the ‘Symmetric Mean Absolute Percentage Error’ (SMAPE) between two vectors without considering the 0 in the true values. Documentation here <https://en.wikipedia.org/wiki/Symmetric_mean_absolute_percentage_error>_.

Parameters

y_truearray-like, shape (length, 1), required

The first vector.

y_predarray-like, shape (length, 1), required

The second vector.

raise_error: bool, optional, default=``False``

Returns

smapefloat

The smape between the two input vectors.

Examples

>>> from gtime.metrics import non_zero_smape
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> non_zero_smape(y_true, y_pred)
0.7864893577539014
gtime.metrics.r_square(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the R squared (Coefficient of Determination) between two vectors.

Parameters

y_truearray-like, shape (length, 1), required

The first vector.

y_predarray-like, shape (length, 1), required

The second vector.

Returns

r_squarefloat

The R squared between the two vectors.

Examples

>>> from gtime.metrics import r_square
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> r_square(y_true, y_pred)
0.586
gtime.metrics.rmse(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the Root Mean Squared Error(RMSE) between two vectors.

Parameters

y_truearray-like, shape (length, 1), required.

The first vector.

y_predarray-like, shape (length, 1), required.

The second vector.

Returns

rmsefloat

The Root Mean Squared Error between the two vectors.

Examples

>>> from gtime.metrics import rmse
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> rmse(y_true, y_pred)
1.098
gtime.metrics.rmsle(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the Root Mean Squared Log Error(RMSLE) between two vectors. Note: RMSLE accepts only positive numbers as input

Parameters

y_truearray-like, shape (length, 1), required.

The first vector.

y_predarray-like, shape (length, 1), required.

The second vector.

Returns

rmsle_valuefloat

The root mean squared log error between the two vectors.

Examples

>>> from gtime.metrics import rmsle
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> rmsle(y_true, y_pred)
0.49
gtime.metrics.smape(y_true: Union[DataFrame, List, ndarray], y_pred: Union[DataFrame, List, ndarray]) float

Compute the ‘Symmetric Mean Absolute Percentage Error’ (SMAPE) between two vectors. Documentation here <https://en.wikipedia.org/wiki/Symmetric_mean_absolute_percentage_error>_.

Parameters

y_truearray-like, shape (length, 1), required

The first vector.

y_predarray-like, shape (length, 1), required

The second vector.

Returns

smapefloat

The smape between the two input vectors.

Examples

>>> from gtime.metrics import smape
>>> y_true = [0, 1, 2, 3, 4, 5]
>>> y_pred = [1.1, 2.3, 0.4, 3.9, 3.1, 4.6]
>>> smape(y_true, y_pred)
0.7864893577539014