the-algorithm/src/java/com/twitter/search/common/encoding/features/SingleBytePositiveFloatNormalizer.java
twitter-team ef4c5eb65e Twitter Recommendation Algorithm
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
2023-03-31 17:36:31 -05:00

36 lines
1.0 KiB
Java

package com.twitter.search.common.encoding.features;
/**
* Normalizes using the logic described in {@link SingleBytePositiveFloatUtil}.
*/
public class SingleBytePositiveFloatNormalizer extends ByteNormalizer {
@Override
public byte normalize(double val) {
return SingleBytePositiveFloatUtil.toSingleBytePositiveFloat((float) val);
}
@Override
public double unnormLowerBound(byte norm) {
return SingleBytePositiveFloatUtil.toJavaFloat(norm);
}
/**
* Get the upper bound of the raw value for a normalized byte.
* @deprecated This is wrongly implemented, always use unnormLowerBound(),
* or use SmartIntegerNormalizer.
*/
@Override @Deprecated
public double unnormUpperBound(byte norm) {
return 1 + SingleBytePositiveFloatUtil.toJavaFloat(norm);
}
/**
* Return the the post-log2 unnormalized value. This is only used for some legacy Earlybird
* features and scoring functions.
*/
public double unnormAndLog2(byte norm) {
return SingleBytePositiveFloatUtil.toLog2Double(norm);
}
}