CLFMixin#

class fl_sim.models.CLFMixin[源代码]#

基类:object

Mixin class for classifiers.

predict(input: Tensor | ndarray, thr: float | None = None, class_map: Dict[int, str] | None = None, batched: bool = False) → list[源代码]#

Predict the class labels.

参数:
  • input (torch.Tensor or numpy.ndarray) -- The input data.

  • thr (float, optional) -- The threshold for multi-label classification. None for single-label classification.

  • class_map (dict, optional) -- The mapping from class index to class name.

  • batched (bool, default False) -- Whether the input is batched.

返回:

labels -- The predicted class labels.

返回类型:

list

predict_proba(input: Tensor | ndarray, multi_label: bool = False, batched: bool = False) → ndarray[源代码]#

Predict probabilities for each class.

参数:
  • input (torch.Tensor or numpy.ndarray) -- The input data.

  • multi_label (bool, default False) -- Whether the model is a multi-label classifier.

  • batched (bool, default False) -- Whether the input is batched.

返回:

proba -- The predicted probabilities.

返回类型:

numpy.ndarray