---
title: "Discussion on \"Why we use fit_transform() for Training Data but only transform() for Testing Data\" | Hashnode"
description: "Discussion on \"Why we use fit_transform() for Training Data but only transform() for Testing Data\". When you start working with machine learning pipelines, one of the first things you’ll notice is that we often write code like this:\nfrom sklearn.preprocessing import StandardScaler  \n\nscaler = StandardScaler()\n\n# Training set\nX_train_scaled = scaler..."
url: "https://hashnode.com/posts/why-we-use-fittransform-for-training-data-but-only-transform-for-testing-data/68caefe7904cde8f3e033c20"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Why we use fit\_transform() for Training Data but only transform() for Testing Data](https://sukrit00.hashnode.dev/why-we-use-fittransform-for-training-data-but-only-transform-for-testing-data?utm_source=hashnode&utm_medium=feed)

When you start working with machine learning pipelines, one of the first things you’ll notice is that we often write code like this: from sklearn.preprocessing import StandardScaler scaler = StandardScaler() # Training set X\_train\_scaled = scaler...

Sep 17, 2025 · 3 min read · sukrit00.hashnode.dev  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#machine-learning](https://hashnode.com/tag/machine-learning)
-   [#data-science](https://hashnode.com/tag/data-science)
-   [#data](https://hashnode.com/tag/data)
-   [#sklearn](https://hashnode.com/tag/sklearn)
-   [#traintestsplit](https://hashnode.com/tag/traintestsplit)

## Written by

[Sukrit Deb](https://hashnode.com/@sukrit00)

@sukrit00

  
[View profile](https://hashnode.com/@sukrit00)

An average explorer.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
