Class ModHashCodeHasher
java.lang.Object
org.tribuo.hash.Hasher
org.tribuo.hash.ModHashCodeHasher
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable,com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>,Serializable,ProtoSerializable<org.tribuo.protos.core.HasherProto>
Hashes names using String.hashCode(), then reduces the dimension.
ModHashCodeHasher does not serialize the salt in its serialized forms, and thus the salt must be set after deserialization.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProtobuf serialization version.Fields inherited from class org.tribuo.hash.Hasher
MIN_LENGTHFields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionModHashCodeHasher(int dimension, String salt) Constructs a ModHashCodeHasher with the supplied parameters.ModHashCodeHasher(String salt) Constructs a ModHashCodeHasher with a fixed dimensionality of 100. -
Method Summary
Modifier and TypeMethodDescriptionstatic ModHashCodeHasherdeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization constructor.booleancom.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenanceHashes the supplied input using the hashing function.inthashCode()voidUsed by the OLCUT configuration system, and should not be called by external code.org.tribuo.protos.core.HasherProtoSerializes this object to a protobuf.voidThe salt is transient, it must be set **to the same value as it was trained with** after theModelis deserialized.toString()Methods inherited from class org.tribuo.hash.Hasher
deserialize, validateSalt
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
ModHashCodeHasher
Constructs a ModHashCodeHasher with a fixed dimensionality of 100.- Parameters:
salt- The salt value.
-
ModHashCodeHasher
Constructs a ModHashCodeHasher with the supplied parameters.- Parameters:
dimension- The dimensionality.salt- The salt value.
-
-
Method Details
-
deserializeFromProto
public static ModHashCodeHasher deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException Deserialization constructor.Note the salt must be set after the hasher has been deserialized.
- Parameters:
version- The version number.className- The class name.message- The serialized data.- Returns:
- The deserialized object.
- Throws:
com.google.protobuf.InvalidProtocolBufferException- If the protobuf could not be parsed from themessage.
-
serialize
public org.tribuo.protos.core.HasherProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Returns:
- The protobuf.
-
postConfig
public void postConfig() throws com.oracle.labs.mlrg.olcut.config.PropertyExceptionUsed by the OLCUT configuration system, and should not be called by external code.- Throws:
com.oracle.labs.mlrg.olcut.config.PropertyException
-
hash
Description copied from class:HasherHashes the supplied input using the hashing function.If the salt is not set then this throws
IllegalStateException. -
setSalt
-
getProvenance
public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance() -
toString
-
equals
-
hashCode
-