Skip to content
Quantoros

A sparse count matrix fits in RAM until centering. Why, and how would you scale it safely?

Classic MLLevel: IntermediateSparse scaling

A sparse count matrix fits in RAM until centering. Why, and how would you scale it safely?

Hints
  • Follow what happens to a zero entry.
  • Separate centering from rescaling.

Answer

Subtracting nonzero means turns implicit zeros into nonzero entries. Use StandardScaler(with_mean=False) or MaxAbsScaler and retain sparse storage.

Source and licence: scikit-learn 1.7.2 — preprocessing · BSD-3-Clause · answer: Quantoros editorial

Related questions