def jaccard_distance(set1, set2):
    """Calculate Jaccard distance between two sets.

    Parameters
    ----------
    set1 : set
        Input set.
    set2 : set
        Input set.

    Returns
    -------
    float
        Jaccard distance between `set1` and `set2`.
        Value in range `[0, 1]`, where 0 is min distance (max similarity) and 1 is max distance (min similarity).
    """
    union_cardinality = len(set1 | set2)
    if union_cardinality == 0:
        return 1.0
    return 1.0 - float(len(set1 & set2)) / float(union_cardinality)
