Why scikit learn's fit transform is probably not for you
The article discusses the fit transform paradigm in scikit-learn and its potential drawbacks. It argues that this approach conflates the roles of object creation and usage, which may not suit all codebases. The author suggests separating the factory and object into distinct classes for cleaner code.
- ▪Scikit-learn's fit transform paradigm allows for zero-cost chaining of transformations.
- ▪The article critiques how this paradigm mixes object instantiation with usage, potentially complicating code.
- ▪The author proposes a design change by separating the factory and the object into two distinct classes.
Hacker News (Newest) files mainly under programming. We currently carry 5,306 of its stories.
Story provenance
Source · retrieval · rights · ranking — open for full record
inspect →
Attribution is not the same as permission. This drawer separates discovery metadata, excerpts, WeSearch-generated summaries, reuse status, and whether the publisher receives the visit. Nothing here claims a legal grant the publisher has not made.
Record
| Original publisher | Stéphan Tulkens |
| Canonical URL | https://stephantul.github.io/blog/fit-transform/ |
| Publication time | Fri, 22 May 2026 04:31:40 +0000 |
| Retrieval time | 2026-05-22T05:02:00.539Z |
| Last seen | 2026-05-22T05:02:00.539Z |
| Headline source | Publisher (no WeSearch rewrite) |
| Excerpt source | publisher body |
| Excerpt method | First ~120 words (~800 chars) of extracted publisher body, fair-use limited. |
| Summary | WeSearch · cerebras-chat (WeSearch summarizer) |
| Summary source text | contentText |
| Citation coverage | Summary is a WeSearch-generated derivative; primary citation is the original publisher URL. |
| Cluster | gcpeHg7vQ6wg |
| Cluster logic | Grouped by semantic title/content similarity across sources within a rolling window. Same-publisher template collisions are excluded from coverage comparison. |
| Ranking reason | Story pages are not engagement-ranked. Hub feeds use recency, with optional source-diversified chronological ordering (cap consecutive stories per source). No personalized ranking. |
| Publisher visit | Yes — open original |
| Substitutes article? | No — link-out required for full text |
Rights status (four layers)
WeSearch handling by dimension
| Indexing | May the item be indexed (stored, ranked, made findable)? | Allowed |
| Snippet | May a short excerpt of the publisher's text be shown? | Allowed |
| AI summary | May WeSearch generate its own short summary of the article? | Limited |
| Retrieval / RAG | May the content be exposed for third-party retrieval-augmented generation? | Not asserted |
| Model training | May the content be used to train AI models? | Not asserted |
| Commercial reuse | May the content be reused commercially? | Not permitted |
Basis: Derived from the published RSS/Atom feed. Contact: [email protected]. Reviewed: 2026-07-24.
Opening excerpt (first ~120 words) tap to expand
Scikit-learn's fit transform paradigm is probably not for you python | May 17, 2026 If you’ve ever used code from scikit-learn, you will have seen the following pattern: import numpy as np from sklearn.preprocessing import StandardScaler X = np.random.randn((100, 32)) scaler = StandardScaler() scaler.fit(X) X_transformed = scaler.transform(X) # Or equivalently X_transformed = scaler.fit_transform(X) For all scikit-learn transformers (1), the fit call sets the internal state of the object, while the transform call uses the set internal state to transform some data into something else. (2) This paradigm is really useful because it allows for zero-cost chaining: any sequence of transformations can be fit_transformed by simply calling fit_transform on all transformations in sequence.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Stéphan Tulkens.