class_docstr: The `Jaccard index`_, also known as Intersection over Union and the Jaccard similarity coefficient
  (originally coined coefficient de communauté by Paul Jaccard), is a statistic used for comparing the
  similarity and diversity of sample sets. The Jaccard coefficient measures similarity between finite sample sets,
  and is defined as the size of the intersection divided by the size of the union of the sample sets:
  
  .. math:: J(A, B) = \frac{A \cap B}{A \cup B}
  
  Args:
      class_weights: 1. or ``np.array`` of class weights (``len(weights) = num_classes``).
      class_indexes: Optional integer or list of integers, classes to consider, if ``None`` all classes are used.
      smooth: value to avoid division by zero
      per_image: if ``True``, metric is calculated as mean over images in batch (B),
          else over whole batch
      threshold: value to round predictions (use ``>`` comparison), if ``None`` prediction will not be round
  
  Returns:
     A callable ``iou_score`` instance. Can be used in ``model.compile(...)`` function.
  
  .. _`Jaccard index`: https://en.wikipedia.org/wiki/Jaccard_index
  
  Example:
  
  .. code:: python
  
      metric = IOUScore()
      model.compile('SGD', loss=loss, metrics=[metric])
class_docstr_tok: ["The","`","Jaccard","index","`","_",",","also","known","as","Intersection","over","Union","and","the","Jaccard","similarity","coefficient","(","originally","coined","coefficient","de","communaut\u00e9","by","Paul","Jaccard",")",",","is","a","statistic","used","for","comparing","the","similarity","and","diversity","of","sample","sets",".","The","Jaccard","coefficient","measures","similarity","between","finite","sample","sets",",","and","is","defined","as","the","size","of","the","intersection","divided","by","the","size","of","the","union","of","the","sample","sets",":","..","math",":",":","J","(","A",",","B",")","=","\\frac","{","A","\\cap","B","}","{","A","\\cup","B","}","Args",":","class_weights",":","1.","or","``","np.array","``","of","class","weights","(","``","len","(","weights",")","=","num_classes","``",")",".","class_indexes",":","Optional","integer","or","list","of","integers",",","classes","to","consider",",","if","``","None","``","all","classes","are","used",".","smooth",":","value","to","avoid","division","by","zero","per_image",":","if","``","True","``",",","metric","is","calculated","as","mean","over","images","in","batch","(","B",")",",","else","over","whole","batch","threshold",":","value","to","round","predictions","(","use","``",">","``","comparison",")",",","if","``","None","``","prediction","will","not","be","round","Returns",":","A","callable","``","iou_score","``","instance",".","Can","be","used","in","``","model.compile","(","...",")","``","function",".","..","_","`","Jaccard","index","`",":","https",":","\/\/en.wikipedia.org\/wiki\/Jaccard_index","Example",":","..","code",":",":","python","metric","=","IOUScore","(",")","model.compile","(","'SGD","'",",","loss=loss",",","metrics=","[","metric","]",")"]
code: def __init__(
      self,
      class_weights=None,
      class_indexes=None,
      threshold=None,
      per_image=False,
      smooth=SMOOTH,
      name=None,
  ):
      name = name or "iou_score"
      super().__init__(name=name)
      self.class_weights = (
          class_weights if class_weights is not None else 1
      )
      self.class_indexes = class_indexes
      self.threshold = threshold
      self.per_image = per_image
      self.smooth = smooth
  
file_path: segmentation_models/segmentation_models/metrics.py
imports: from .base import Metric
  from .base import functional
label_desc: Use image node_id 1 to create a new IOUScore object from inherited base classes: Metric with example: obj = IOUScore(class_weights, class_indexes, threshold, per_image, smooth, name)