Loss metrics¶
Module that contains commonly used loss-functions in machine learning. The following functions are defined:
- scripts.metrics._loss.ae(y, p)¶
Absolute error.
Absolute error can be defined as follows:
\[\sum_i^n abs(y_i - p_i)\]where \(n\) is the number of provided records.
- Parameters
y (
ndarray) – One dimensional array with ground truth values.p (
ndarray) – One dimensional array with predicted values.
- Returns
Absolute error as desribed above.
- Return type
float
- scripts.metrics._loss.cross_entropy(y, p)¶
Cross-entropy is a measure of the difference between two probability distributions for a given random variable or set of events. (source)
- Parameters
y (
ndarray) – One dimensional array with ground truth values.p (
ndarray) – One dimensional array with predicted values.
- Returns
Cross entropy score.
- Return type
float
- scripts.metrics._loss.se(y, p)¶
Squared error.
Sqaured error can be defined as follows:
\[\sum_i^n (y_i - p_i)^2\]where \(n\) is the number of provided records.
- Parameters
y (
ndarray) – One dimensional array with ground truth values.p (
ndarray) – One dimensional array with predicted values.
- Returns
Squared error as desribed above.
- Return type
float
Notes
Usually used for regression problems.
- scripts.metrics._loss.zero_one_loss(y, p)¶
Number of incorrectly classified records.
- Parameters
y (
ndarray) – One dimensional array with ground truth values.p (
ndarray) – One dimensional array with predicted values.
- Returns
Number of misclassified records.
- Return type
int