def f1_score(real_labels, predicted_labels):
    """
    Information on F1 score - https://en.wikipedia.org/wiki/F1_score
    :param real_labels: List[int]
    :param predicted_labels: List[int]
    :return: float
    """
    assert len(real_labels) == len(predicted_labels)
    
    # tp = true-positive
    # fp = false positive
    # fn = false negative
    tp = float(sum(1 for x,y in zip(real_labels, predicted_labels) if (x == 1 and y ==1)))
    fp = float(sum(1 for x,y in zip(real_labels, predicted_labels) if (x == 0 and y ==1)))
    fn = float(sum(1 for x,y in zip(real_labels, predicted_labels) if (x == 1 and y ==0)))
    
    # define precision and recall
    if ((tp+fp)==0) or ((tp+fn)==0):
        precision = 0
        recall = 0
    else:
        precision = tp/(tp+fp)
        recall = tp/(tp+fn)
    
    # define and return f1-score
    if precision + recall == 0:
        f1 = 0
    else:
        f1 = 2 * ((precision*recall)/(precision + recall))
    return f1