You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemall.apache.org by Makoto Yui <yu...@gmail.com> on 2017/02/13 06:11:58 UTC

Re: RescaleUDF null value

Hi Yuming,

`rescale` function should return null if input value contains null.
So, if(value is null, null, rescale(value, min_value, max_value)) is a
workaround.

Due to unboxing, NPE would be happen.

So, better to fix the implementation to avoid unboxing (evaluate
method w/ primitive values) and handle null values in
https://github.com/apache/incubator-hivemall/blob/master/core/src/main/java/hivemall/ftvec/scaling/RescaleUDF.java#L39

|    public FloatWritable evaluate(final float value, final float min,
final float max) {
|        return val(min_max_normalization(value, min, max));
|    }
|
|    @Nullable
|    public FloatWritable evaluate(final Float value, final Float min,
final Float max) throws HiveException {
|        if(value == null) {
|            return null;
|        }
|        if(min == null) throw new HiveException("min should not be null");
|        if(max == null) throw new HiveException("max should not be null");
|
|        return val(min_max_normalization(value.floatValue(),
min.floatValue(), max. floatValue()));
|    }

BTW, it's better to move this thread to users@hivemall.incubator.apache.org.

Thanks,
Makoto

2017-02-13 14:08 GMT+09:00 Yuming Wang <wg...@gmail.com>:
> hi:
>
> How to deal with
> <http://www.baidu.com/link?url=gXuNJjK_D8dbqNxLwXQO4KfU9lIUyyE6Cyt54hx68EVKcnohBk0ZyRbBAje7p4Kgt7h34FGpwk8YEnqAVspGw4iP0esmMTaUPkVfdaqsRNi>
> null
> value here?
>
> https://github.com/apache/incubator-hivemall/blob/master/core/src/main/java/hivemall/ftvec/scaling/RescaleUDF.java#L81