Ordinal Encoder with Unknown Categories

easy
Unit 4 · Preprocessing & Features0/3 to milestone

Implement OrdinalEncoder for a single column of strings:

  • fit(values): assign codes 0, 1, 2, ... to categories in sorted order; return self
  • transform(values): map to codes; categories never seen in training become -1
  • inverse_transform(codes): map back; -1 becomes None
#preprocessing#categorical2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Ordinal Encoder with Unknown Categories · TechGradify