public final class HashedFeatureMap extends ImmutableFeatureMap
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.idMap, size
m
Modifier and Type | Method and Description |
---|---|
static HashedFeatureMap |
generateHashedFeatureMap(FeatureMap map,
Hasher hasher)
Converts a standard
FeatureMap by hashing each entry
using the supplied hash function Hasher . |
VariableIDInfo |
get(String name)
Gets the
VariableIDInfo
for this name. |
int |
getID(String name)
Gets the id number for this feature, returns -1 if it's unknown.
|
void |
setSalt(String salt)
The salt is not serialised with the
Model . |
generateIDs, generateIDs, get, size
iterator, keySet, toReadableString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public VariableIDInfo get(String name)
ImmutableFeatureMap
VariableIDInfo
for this name. Returns null if it's unknown.get
in class ImmutableFeatureMap
name
- The name to lookup.public int getID(String name)
getID
in class ImmutableFeatureMap
name
- The name of the feature.public void setSalt(String salt)
Model
.
It must be set after deserialisation to the same value from training time.
If the salt is invalid it will throw IllegalArgumentException
.
salt
- The salt value. Must be the same as the one from training time.public static HashedFeatureMap generateHashedFeatureMap(FeatureMap map, Hasher hasher)
FeatureMap
by hashing each entry
using the supplied hash function Hasher
.
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.
map
- The FeatureMap
to hash.hasher
- The hashing function.HashedFeatureMap
.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.