paddlets.metrics.metrics

class MSE(mode: str = 'normal')[源代码]

基类:Metric

均方误差(mse).

参数

mode (str) – 支持的metric模式, 支持normal(非概率预测)、prob(概率预测)和anomaly(异常检测)三种模式

_NAME

Metric名称.

类型

字符串

_MAXIMIZE

用于标识优化方向.

类型

布尔值

metric_fn(y_true: ndarray, y_score: ndarray) float[源代码]

均方误差(mse).

参数
  • y_true (np.ndarray) – 真实目标值.

  • y_score (np.ndarray) – 模型预测值.

返回

均方误差值, 非负的浮点值(最优值为0.0)

返回类型

float

class MAE(mode: str = 'normal')[源代码]

基类:Metric

平均绝对误差(mae).

参数

mode (str) – 支持的metric模式, 支持normal(非概率预测)、prob(概率预测)和anomaly(异常检测)三种模式

_NAME

Metric名称.

类型

字符串

_MAXIMIZE

用于标识优化方向.

类型

布尔值

metric_fn(y_true: ndarray, y_score: ndarray) float[源代码]

平均绝对误差(mae).

参数
  • y_true (np.ndarray) – 真实目标值.

  • y_score (np.ndarray) – 模型预测值.

返回

平均绝对误差值, 非负的浮点值(最优值为0.0)

返回类型

float

class LogLoss(mode: str = 'normal')[源代码]

基类:Metric

对数损失(交叉熵损失).

参数

mode (str) – 支持的metric模式, 支持normal(非概率预测)、prob(概率预测)和anomaly(异常检测)三种模式

_NAME

Metric名称.

类型

字符串

_MAXIMIZE

用于标识优化方向.

类型

布尔值

metric_fn(y_true: ndarray, y_score: ndarray) float[源代码]

对数损失(交叉熵损失).

参数
  • y_true (np.ndarray) – 真实目标值.

  • y_score (np.ndarray) – 模型预测值.

返回

对数损失(交叉熵损失).

返回类型

float

class QuantileLoss(q_points: List[float] = [0.1, 0.5, 0.9], quantile_level: Optional[Union[ndarray, List[float]]] = None, mode: str = 'prob')[源代码]

基类:Metric

分位数损失,参照论文:Bayesian Intermittent Demand Forecasting for Large Inventories .

分位数损失,当``q=0.5``时,退化为MAE损失。

参数
  • q_points (List[float]) – 分位点,默认值为None。在预测评估阶段,如果指定`q_points`,输出dict包含分位点对应的分位数损失。

  • mode (str) – 支持的metric模式, 支持normal(非概率预测)、prob(概率预测)和anomaly(异常检测)三种模式

metric_fn(y_true: ndarray, y_pred_sample: ndarray) Union[float, dict][源代码]

分位数损失。

参数
  • y_true (np.ndarray) – 真实目标值.

  • y_score (np.ndarray) – 模型预测值.

返回

分位数损失。

返回类型

float

class ACC(mode: str = 'anomaly')[源代码]

基类:Metric

准确率得分(acc)

参数

mode (str) – 仅支持异常检测

_NAME

Metric名称.

类型

字符串

metric_fn(y_true: ndarray, y_score: ndarray) float[源代码]

准确率得分(acc)

参数
  • y_true (np.ndarray) – 真实目标值.

  • y_score (np.ndarray) – 模型预测值.

返回

准确率得分, 非负的浮点值(最优值为1.0)

返回类型

float

class Precision(mode: str = 'anomaly')[源代码]

基类:Metric

精确率得分(precision)

参数

mode (str) – 仅支持异常检测

_NAME

Metric名称.

类型

字符串

metric_fn(y_true: ndarray, y_score: ndarray, **kwargs) float[源代码]

精确率得分(precision)

参数
  • y_true (np.ndarray) – 真实目标值.

  • y_score (np.ndarray) – 模型预测值.

返回

精确率得分, 非负的浮点值(最优值为1.0)

返回类型

float

class Recall(mode: str = 'anomaly')[源代码]

基类:Metric

召回率得分(recall)

参数

mode (str) – 仅支持异常检测

_NAME

Metric名称.

类型

字符串

metric_fn(y_true: ndarray, y_score: ndarray, **kwargs) float[源代码]

召回率得分(recall)

参数
  • y_true (np.ndarray) – 真实目标值.

  • y_score (np.ndarray) – 模型预测值.

返回

召回率得分, 非负的浮点值(最优值为1.0)

返回类型

float

class F1(mode: str = 'anomaly')[源代码]

基类:Metric

F1得分(f1)

参数

mode (str) – 仅支持异常检测

_NAME

Metric名称.

类型

字符串

metric_fn(y_true: ndarray, y_score: ndarray, **kwargs) float[源代码]

F1得分(f1)

参数
  • y_true (np.ndarray) – 真实目标值.

  • y_score (np.ndarray) – 模型预测值.

返回

F1得分, 非负的浮点值(最优值为1.0)

返回类型

float

class MetricContainer(metrics: Union[List[str], List[Metric]], prefix: str = '')[源代码]

基类:object

包含若干Metric的容器.

参数
  • metrics (List[str]|List[Metric]) – Metric或etric名称的列表.

  • prefix (str) – 为Metric名称增加前缀.

_prefix

为Metric名称增加前缀.

类型

字符串

_metrics

Metric实例的列表.

类型

List[Metric]

_names

与评估集名称关联的Metric名称列表.

类型

List[str]