shiba/metrics.py
def f1(prediction, target):
    """
    prediction: thresholded prediction (zeros or ones)
    """
    EPS = 1e-10
    intersection = (prediction * target).sum().float()
    union = (prediction.sum() + target.sum()).float()
    return (2 * (intersection + EPS) / (union + 2 * EPS)).item()

    prediction: thresholded prediction (zeros or ones)
    
thresholded prediction (zeros or ones)
thresholded prediction ( zeros or ones )
def f1(prediction, target):
    EPS = 1e-10
    intersection = (prediction * target).sum().float()
    union = (prediction.sum() + target.sum()).float()
    return (2 * (intersection + EPS) / (union + 2 * EPS)).item()
def f1 ( prediction , target ) : EPS = 1e-10 intersection = ( prediction * target ) . sum ( ) . float ( ) union = ( prediction . sum ( ) + target . sum ( ) ) . float ( ) return ( 2 * ( intersection + EPS ) / ( union + 2 * EPS ) ) . item ( )
prediction: thresholded prediction (zeros or ones)
prediction : thresholded prediction ( zeros or ones )
"""
    prediction: thresholded prediction (zeros or ones)
    """
prediction
target