def f1_score(y, y_pred):
    """F1 score

    f1_score = 2 * precision*recall / (precision + recall)
    
    Parameters:
    -----------
    y : vector, shape (n_samples,)
    The target labels.

    y_pred : vector, shape (n_samples,)
    The predicted labels.
    
    Returns:
    --------
    f1_score : float
    
    """

    p = precision(y, y_pred)
    r = recall(y, y_pred)

    return 2*p*r / (p+r)