How to change FillMissing to a constant in procs for tabular data?

The example on the docs is about performing a transformation on the entire dataset. How can I change the

procs = [FillMissing, Categorify, Normalize]

So that FillMissing uses a value that I would want? Does the different way to do FillMissing affect anything?

1 Like

From the source it looks like you should be able to subclass FillMissing like so and change the fill_stragety then set the fill_val to whatever you like

from fastai.tabular import *

@dataclass
class MyFillMissing(FillMissing):
    fill_strategy:FillStrategy=FillStrategy.CONSTANT
    add_col:bool=True
    fill_val:float=0.
3 Likes

Here’s another way to do it:

from functools import partial
procs = [partial(FillMissing, fill_strategy=FillStrategy.CONSTANT, fill_val=0.), Categorify, Normalize]
1 Like