MODELCATALOG

The mistakes that do not raise an error.

Gotchas

The mistakes that do not raise an error.

  1. fit_transform on training data, transform on test data

    Calling fit_transform on your test set re-learns the parameters from it and quietly corrupts the evaluation. A Pipeline makes this structurally impossible, which is the main argument for always using one.

  2. LabelEncoder is for targets only

    It takes 1-D input. Using it on feature columns is a common early mistake — reach for OrdinalEncoder there instead.

  3. OneHotEncoder needs handle_unknown='ignore'

    Without it, the first unseen category in production raises an exception. The default is to error.

  4. random_state everywhere you want reproducibility

    Splitters, models, searches. Omit it and your numbers move between runs, and you cannot tell whether a change helped.

  5. n_jobs=-1 is not the default

    Free speedup on random forests, cross-validation and grid search. You have to ask for it.

  6. Convergence warnings are not noise

    max_iter on LogisticRegression and MLPClassifier defaults too low for real data. The warning means the model has not finished fitting.

  7. Sparse output surprises people

    TfidfVectorizer and OneHotEncoder return sparse matrices. Some models refuse them, and calling .toarray() on a large corpus exhausts memory. LinearSVC, LogisticRegression and MultinomialNB all accept sparse input directly.

  8. Feature selection belongs inside the Pipeline

    Selecting features on the full dataset before splitting is leakage. It is easy to do by accident and it inflates results convincingly.