Spot the bug in the feature pipeline

from Natural language processing
Python 3.14 intermediate 4 min 2 issues to find

Find the leakage risks in this generated feature pipeline.

Python
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.model_selection import train_test_split

def prepare(rows):
    texts = [row["text"] for row in rows]
    labels = [row["label"] for row in rows]
    features = TfidfVectorizer().fit_transform(texts)
    return train_test_split(
        features, labels, test_size=0.2, random_state=42
    )
Open in playground
Report an error