Class HashedFeatureMap
java.lang.Object
org.tribuo.FeatureMap
org.tribuo.ImmutableFeatureMap
org.tribuo.hash.HashedFeatureMap
- All Implemented Interfaces:
Serializable,Iterable<VariableInfo>
A
FeatureMap used by the HashingTrainer to
provide feature name hashing and guarantee that the Model
does not contain feature name information, but still works
with unhashed features names.- See Also:
-
Field Summary
Fields inherited from class org.tribuo.ImmutableFeatureMap
idMap, sizeFields inherited from class org.tribuo.FeatureMap
m -
Method Summary
Modifier and TypeMethodDescriptionstatic HashedFeatureMapgenerateHashedFeatureMap(FeatureMap map, Hasher hasher) Converts a standardFeatureMapby hashing each entry using the supplied hash functionHasher.Gets theVariableIDInfofor this name.intGets the id number for this feature, returns -1 if it's unknown.voidThe salt is not serialised with theModel.Methods inherited from class org.tribuo.ImmutableFeatureMap
generateIDs, generateIDs, get, sizeMethods inherited from class org.tribuo.FeatureMap
iterator, keySet, toReadableString, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
get
Description copied from class:ImmutableFeatureMapGets theVariableIDInfofor this name. Returns null if it's unknown.- Overrides:
getin classImmutableFeatureMap- Parameters:
name- The name to lookup.- Returns:
- The VariableInfo, or null.
-
getID
Gets the id number for this feature, returns -1 if it's unknown.- Overrides:
getIDin classImmutableFeatureMap- Parameters:
name- The name of the feature.- Returns:
- A non-negative integer if the feature is known, -1 otherwise.
-
setSalt
The salt is not serialised with theModel. It must be set after deserialisation to the same value from training time.If the salt is invalid it will throw
IllegalArgumentException.- Parameters:
salt- The salt value. Must be the same as the one from training time.
-
generateHashedFeatureMap
Converts a standardFeatureMapby hashing each entry using the supplied hash functionHasher.This preserves the index ordering of the original feature names, which is important for making sure test time performance is good.
It guarantees any collisions will produce an feature id number lower than the previous feature's number, and so can be easily removed.
- Parameters:
map- TheFeatureMapto hash.hasher- The hashing function.- Returns:
- A
HashedFeatureMap.
-