Class ClusteringFactory
java.lang.Object
org.tribuo.clustering.ClusteringFactory
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable,com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>,Serializable,OutputFactory<ClusterID>,ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>
A factory for making ClusterID related classes.
Parses the ClusterID by calling toString on the input then parsing it as an int.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClusterIDThe sentinel unassigned cluster id, used when there is no ground truth clustering.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionClusteringFactory is stateless and immutable, but we need to be able to construct them via the config system. -
Method Summary
Modifier and TypeMethodDescriptionconstructInfoForExternalModel(Map<ClusterID, Integer> mapping) Unlike the other info types, clustering directly uses the integer IDs as the stored value, so this mapping discards the cluster IDs and just uses the supplied integers.static ClusteringFactorydeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.booleanGenerates the appropriateMutableOutputInfoso the output values can be tracked by aDatasetor other aggregate.<V> ClusterIDgenerateOutput(V label) Generates a ClusterID by calling toString on the input, then calling Integer.parseInt.Gets anEvaluatorsuitable for measuring performance of predictions for the Output subclass.Gets the output class that this factory supports.Returns the singleton unknown output of type T which can be used for prediction time examples.inthashCode()org.tribuo.protos.core.OutputFactoryProtoSerializes this object to a protobuf.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable
postConfigMethods inherited from interface org.tribuo.OutputFactory
generateOutputs
-
Field Details
-
UNASSIGNED_CLUSTER_ID
The sentinel unassigned cluster id, used when there is no ground truth clustering.
-
-
Constructor Details
-
ClusteringFactory
public ClusteringFactory()ClusteringFactory is stateless and immutable, but we need to be able to construct them via the config system.
-
-
Method Details
-
deserializeFromProto
public static ClusteringFactory deserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.- Parameters:
version- The serialized object version.className- The class name.message- The serialized data.- Returns:
- The deserialized object.
-
serialize
public org.tribuo.protos.core.OutputFactoryProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Specified by:
serializein interfaceProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>- Returns:
- The protobuf.
-
generateOutput
Generates a ClusterID by calling toString on the input, then calling Integer.parseInt.- Specified by:
generateOutputin interfaceOutputFactory<ClusterID>- Type Parameters:
V- The type of the input.- Parameters:
label- An input value.- Returns:
- A ClusterID representing the data.
-
getUnknownOutput
Description copied from interface:OutputFactoryReturns the singleton unknown output of type T which can be used for prediction time examples.- Specified by:
getUnknownOutputin interfaceOutputFactory<ClusterID>- Returns:
- An unknown output.
-
generateInfo
Description copied from interface:OutputFactoryGenerates the appropriateMutableOutputInfoso the output values can be tracked by aDatasetor other aggregate.- Specified by:
generateInfoin interfaceOutputFactory<ClusterID>- Returns:
- The appropriate subclass of
MutableOutputInfoinitialised to zero.
-
constructInfoForExternalModel
public ImmutableOutputInfo<ClusterID> constructInfoForExternalModel(Map<ClusterID, Integer> mapping) Unlike the other info types, clustering directly uses the integer IDs as the stored value, so this mapping discards the cluster IDs and just uses the supplied integers.- Specified by:
constructInfoForExternalModelin interfaceOutputFactory<ClusterID>- Parameters:
mapping- The mapping to use.- Returns:
- An
ImmutableOutputInfofor the clustering.
-
getEvaluator
Description copied from interface:OutputFactoryGets anEvaluatorsuitable for measuring performance of predictions for the Output subclass.Evaluatorinstances are thread safe and immutable, and commonly this is a singleton stored in theOutputFactoryimplementation.- Specified by:
getEvaluatorin interfaceOutputFactory<ClusterID>- Returns:
- An evaluator.
-
getTypeWitness
Description copied from interface:OutputFactoryGets the output class that this factory supports.- Specified by:
getTypeWitnessin interfaceOutputFactory<ClusterID>- Returns:
- The output class.
-
hashCode
-
equals
-
getProvenance
- Specified by:
getProvenancein interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
-