Implementing F1 score
To compute the length of a set difference, you only need to subtract the length of the intersection from the length of the set.
You could make use of the intersection when computing the differences. Subtracting the intersection gives the same result but processes fewer elements.

tags = set(tags)
predicted = set(predicted)

tp = len(tags &amp; predicted)
fp = len(predicted) - tp 
fn = len(tags) - tp


Note that I added spaces around operators to improve readability. I also used the &amp; operator instead of the intersection method as a matter of preference.