---
source: https://iinventedlight.com/library/notes/sklearn-preprocessing-scaling.md
title: "Feature scaling with sklearn.preprocessing"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING); prose restates or closely paraphrases cited source lines"
license_family: sklearn-bsd3
rule_check: "needs rule check (family not in auto-publish rule; check.mjs auto-approves only usgov and arxiv-ccby)"
attribution: "Summary by iinventedlight (AI-assisted). Sources: scikit-learn docs, 8.3. Preprocessing data — scikit-learn 1.9.1 documentation, BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING); scikit-learn docs, 12. Common pitfalls and recommended practices — scikit-learn 1.9.1 documentation, BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: scikit-learn"
tags: ['scikit-learn', 'preprocessing', 'scaling']
sources:
  - id: S1
    title: "8.3. Preprocessing data — scikit-learn 1.9.1 documentation"
    publisher: scikit-learn docs
    url: https://scikit-learn.org/stable/modules/preprocessing.html
    accessed: 2026-11-04
    license: "BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING)"
  - id: S2
    title: "12. Common pitfalls and recommended practices — scikit-learn 1.9.1 documentation"
    publisher: scikit-learn docs
    url: https://scikit-learn.org/stable/common_pitfalls.html
    accessed: 2026-11-04
    license: "BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING)"
---
# Feature scaling with sklearn.preprocessing

**Answer:** The sklearn.preprocessing package provides several common utility functions and transformer classes to change raw feature vectors into a representation that is more suitable for the downstream estimators. (S1)

## Standardization

- In practice we often ignore the shape of the distribution and just transform the data to center it by removing the mean value of each feature, then scale it by dividing non-constant features by their standard deviation. (S1)
- StandardScaler implements the Transformer API to compute the mean and standard deviation on a training set so as to be able to later re-apply the same transformation on the testing set. (S1)
- An alternative standardization is scaling features to lie between a given minimum and maximum value, often between zero and one; this can be achieved using MinMaxScaler. (S1)
- If some outliers are present in the set, robust scalers or other transformers can be more appropriate. (S1)

## Use them consistently

- If these data transforms are used when training a model, they also must be used on subsequent datasets, whether it's test data or data in a production system. (S2)
- Both train and test subsets should receive the same preprocessing transformation, but these transformations should only be learnt from the training data. (S2)

## Claims
- id: C1
  claim: sklearn.preprocessing provides transformer classes.
  source: S1
  evidence: "The sklearn.preprocessing package provides several common"
- id: C2
  claim: Robust scalers suit data with outliers.
  source: S1
  evidence: "If some outliers are present in the set, robust scalers or other transformers can"
- id: C3
  claim: Transforms used in training must be used later too.
  source: S2
  evidence: "must be used on subsequent datasets"
- id: C4
  claim: MinMaxScaler or MaxAbsScaler do range scaling.
  source: S1
  evidence: "This can be achieved using MinMaxScaler or MaxAbsScaler"

## Sources
- [S1] 8.3. Preprocessing data — scikit-learn 1.9.1 documentation. scikit-learn docs. https://scikit-learn.org/stable/modules/preprocessing.html . License: BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING). Accessed 2026-11-04.
- [S2] 12. Common pitfalls and recommended practices — scikit-learn 1.9.1 documentation. scikit-learn docs. https://scikit-learn.org/stable/common_pitfalls.html . License: BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
