الانتقال إلى المحتوى
Machine LearningFeature Engineering· 6 دقائق للقراءة

More Features Can Make a Model Worse: Noise and the Curse of Dimensionality

Every column you add is one more thing the model must learn to ignore, from the same number of rows.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
  • scikit-learn 1.9
محتويات المقال

A diagnostics team has a k-nearest neighbors model built on 30 tumor measurements, with a cross-validated accuracy of 0.965. A data engineer joins 100 more columns from the data warehouse: "The model will figure out what's useful." None of the new columns has anything to do with the diagnosis, and accuracy falls to 0.917. Nothing crashed, no warning appeared, and the new pipeline is bigger and slower to boot.

The common misconception

Many developers assume that adding features gives the model more information and can only help. The reasoning is appealing:

  • A model can always ignore a useless feature by giving it a weight of zero, so extra columns look free.
  • "More data is better" feels like it should apply to columns as well as rows.
  • Some models really are fairly tolerant: tree ensembles and regularized linear models often shrug off a few weak features, which reinforces the instinct.

The half-truth: a model could ignore a useless feature. In practice it has to learn that the feature is useless, from the same limited rows, and it learns that imperfectly. Some models don't learn per-feature weights at all.

What actually happens

Every feature is something the model must either use or learn to ignore, and both cost something.

A model has to learn what to ignore

A model estimates its weights from the training rows, and in a finite sample even a random column lines up with the target by chance here and there. So a useless feature gets a small, nonzero role fitted to those coincidences: that's , one column at a time. scikit-learn's permutation importance example shows it clearly: it adds a column of random numbers to the Titanic data, and a random forest's built-in importance ranks it among the most important features, because the forest has enough capacity to use it to overfit.

Google's Rules of Machine Learning give the budget in one line: the number of feature weights you can learn in a linear model is roughly proportional to the amount of data you have. Its example for a small dataset: 1,000 examples, a dozen features.

Distances add up every column

k-nearest neighbors has no weights to turn down. It predicts from the training rows closest to the new one, and the distance adds up differences across all columns. After StandardScaler, every column counts the same, so with 30 real columns and 100 unrelated ones, most of each distance comes from columns that say nothing about the tumor. The "nearest" neighbors are increasingly chosen by noise.

Python
import numpy as npfrom sklearn.datasets import load_breast_cancerfrom sklearn.model_selection import StratifiedKFold, cross_val_scorefrom sklearn.neighbors import KNeighborsClassifierfrom sklearn.pipeline import make_pipelinefrom sklearn.preprocessing import StandardScalerX, y = load_breast_cancer(return_X_y=True)  # 30 real measurementsextra = np.random.default_rng(0).normal(size=(len(X), 100))  # unrelatedX_all = np.hstack([X, extra])  # "the model will figure out what's useful"cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=0)knn = make_pipeline(StandardScaler(), KNeighborsClassifier())for name, data in [("30 features", X), ("130 features", X_all)]:    score = cross_val_score(knn, data, y, cv=cv).mean()    print(f"{name:<12} accuracy {score:.3f}")# 30 features  accuracy 0.965# 130 features accuracy 0.917

Same model, same rows, and 100 extra columns cost almost five points of accuracy. The model has more information in the sense that the old columns are still there. It just can't find them under the new ones.

The curse of dimensionality

The scikit-learn nearest neighbors guide says it directly: in high-dimensional spaces, the method becomes less effective due to the so-called . As dimensions grow, the space grows so fast that the same number of rows covers it ever more thinly, and "near" stops meaning much. Speed suffers too: the guide notes that KD-tree search, very fast below about 20 dimensions, becomes inefficient as dimensions grow.

It's not only KNN

Distance-based models feel it first, but not alone. In scikit-learn's univariate feature selection example, 20 noise columns are added to the 4 iris measurements. A linear SVM on all 24 scores 0.789; after keeping the 4 best features, 0.868. Without selection, the example observes, the SVM puts large weights on the real features but also uses many of the non-informative ones.

Selection belongs inside the pipeline

keeps the columns that carry signal. The second script uses SelectKBest with an ANOVA F-test and lets GridSearchCV choose how many columns to keep, inside each training fold. It keeps 20 columns, none of them noise, and accuracy returns to 0.963. scikit-learn also offers L1-based SelectFromModel, RFECV and SequentialFeatureSelector; the user guide recommends running any of them in a Pipeline.

MythReality
A useless feature just gets a weight of zeroIt gets a small role fitted to chance patterns in the training rows
KNN finds the most similar rowsIt finds rows similar across all columns, noise included: 0.965 fell to 0.917
Only distance-based models careA linear SVM in scikit-learn's example fell from 0.868 to 0.789 with 20 noise columns
Columns are free, like extra informationThe rows you need grow with the features: "1,000 examples, a dozen features"

How to apply it in your project

  1. Start from a baseline you trustMeasure a model on the features you understand, then add new columns in groups and keep only the groups that improve the cross-validated score.
  2. Put selection in the pipelineUse SelectKBest, SelectFromModel or RFECV as a pipeline step, and tune how many features to keep with GridSearchCV.
  3. Watch the ratio of features to rowsGoogle's rule of thumb for a thousand rows is about a dozen features. Hundreds of columns on that much data asks the model to find signal in noise.
  4. Match the model to the widthFor wide data, prefer regularized linear models or tree ensembles over plain KNN, or reduce dimensions first, for example with NeighborhoodComponentsAnalysis in front of KNN.
  5. Delete what you don't useThe Rules of ML call unused features technical debt. Remove them from the pipeline and the data feeds, not just from the model.

Key takeaways

  • Extra features aren't free: the model must learn to ignore each one, and finite data makes that imperfect.
  • Distance-based models suffer most: 100 unrelated columns took KNN from 0.965 to 0.917 accuracy.
  • The data you need grows with the number of features, the core of the curse of dimensionality.
  • Select features inside cross-validation; here it kept 20 real columns and restored 0.963.

📚 المصادر

  1. Feature selection — scikit-learn User Guide
  2. Univariate Feature Selection — scikit-learn examples
  3. Nearest Neighbors — scikit-learn User Guide
  4. Permutation Importance vs Random Forest Feature Importance (MDI) — scikit-learn examples
  5. Rules of Machine Learning (rules #21 and #22) — Google for Developers

التعليقات (0)