The best way to fix an undefinedmetricwarning is to set the precision and F-score to 0.0 for labels with no predicted samples.