def weeds_prec(x_row, y_row):
    """
    WeedsPrec(x -> y) = (\sigma_c \in Fx,y w_x(c)) / (\sigma_c \in Fx w_x(c))
    Fx,y is the mutual contexts (non-zero entries) of x and y rows in the ppmi matrix
    w_x(c) is the weight of feature c in x's feature vector, i.e. ppmi(x, c)
    Fx is the row of x in the ppmi matrix
    :param x_row: x's row in the co-occurrence matrix
    :param y_row: y's row in the co-occurrence matrix
    :return:
    """

    # Get the mutual contexts: use y as a binary vector and apply dot product with x:
    # If c is a mutual context, it is 1 in y_non_zero and the value ppmi(x, c) is added to the sum
    # Otherwise, if it is 0 in either x or y, it adds 0 to the sum.
    y_row.to_ones()
    numerator = x_row.multiply(y_row).sum() # dot-product

    # The sum of x's contexts (for ppmi) is the sum of x_row.
    denominator = x_row.sum()

    return 0.0 if denominator == 0 else numerator * (1.0 / denominator)