lightweight_mmm
lightweight_mmm copied to clipboard
Non zero mean scaling - Not working
I've used "lambda x: jnp.mean(x[x > 0])" in place of "jnp.mean"
media_scaler = preprocessing.CustomScaler(divide_operation=lambda x: jnp.mean(x[x > 0]))
It throws "NonConcreteBooleanIndexError: Array boolean indices must be concrete; got ShapedArray(bool[82])" error.
please help me out, how to do scaling only for non zero values in a column.
Also , how to change the axis (row/column) for scaling)?
Thanks a lot for flagging this! I just wanted to share a link to our new "support" section in the readme to give you some more information on how we can and cannot support such issues at the moment.
For this particular issue, the documentation for the NonConcreteBooleanIndexError has some potential workarounds you could try!
@msdhina This works for a single vector but wouldn't work if you pass multiple columns
I tried the code below by referring to the documentation @michevan suggested.
def nonzero_mean(arr):
return jnp.nanmean(jnp.where(arr != 0, arr, jnp.nan))
media_scaler = preprocessing.CustomScaler(divide_operation=nonzero_mean)
I first converted zero values to NaN by jnp.where()
and calculated the mean excluding NaN values by jnp.nanmean()
I think this works but still need someone to verify since I'm not a good coder 😅
did anyone make it work?
Did it worked? Im trying to fix this, do you have any alternative for zero data
Did it worked? Im trying to fix this, do you have any alternative for zero data
I tried this solution and the scaling works but not the training, got a ValueError: Normal distribution got invalid loc parameter.