Class RegressionFactory
java.lang.Object
org.tribuo.regression.RegressionFactory
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable,com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>,Serializable,OutputFactory<Regressor>,ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>
A factory for creating
Regressors and RegressionInfos.
It parses the regression dimensions by toStringing the input and calling Regressor.parseString(java.lang.String), unless
the input is a collection, in which case it extracts the elements.
This OutputFactory has mutable state, namely the character which the dimension input is split on.
In most cases the default DEFAULT_SPLIT_CHAR is fine.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charThe default character to split the string form of a multidimensional regressor.static final RegressorDeprecated.Deprecated when regression was made multidimensional by default.static final RegressorThe sentinel unknown regressor, used when there is no ground truth regressor value.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionBuilds a regression factory using the default split characterDEFAULT_SPLIT_CHAR.RegressionFactory(char splitChar) Sets the split character used to parseRegressorinstances from Strings. -
Method Summary
Modifier and TypeMethodDescriptionconstructInfoForExternalModel(Map<Regressor, Integer> mapping) Creates anImmutableOutputInfofrom the supplied mapping.static RegressionFactorydeserializeFromProto(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> RegressorgenerateOutput(V label) Parses the Regressor value either by toStringing the input and callingRegressor.parseString(java.lang.String)or if it's a collection iterating over the elements calling toString on each element in turn and usingRegressor.parseElement(int, java.lang.String).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()voidUsed by the OLCUT configuration system, and should not be called by external code.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 org.tribuo.OutputFactory
generateOutputs
-
Field Details
-
DEFAULT_SPLIT_CHAR
public static final char DEFAULT_SPLIT_CHARThe default character to split the string form of a multidimensional regressor.- See Also:
-
UNKNOWN_REGRESSOR
The sentinel unknown regressor, used when there is no ground truth regressor value. -
UNKNOWN_MULTIPLE_REGRESSOR
Deprecated.Deprecated when regression was made multidimensional by default. UseUNKNOWN_REGRESSORinstead.
-
-
Constructor Details
-
RegressionFactory
public RegressionFactory()Builds a regression factory using the default split characterDEFAULT_SPLIT_CHAR. -
RegressionFactory
public RegressionFactory(char splitChar) Sets the split character used to parseRegressorinstances from Strings.- Parameters:
splitChar- The split character.
-
-
Method Details
-
postConfig
public void postConfig()Used by the OLCUT configuration system, and should not be called by external code.- Specified by:
postConfigin interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
deserializeFromProto
public static RegressionFactory deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException Deserialization factory.- Parameters:
version- The serialized object version.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.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
Parses the Regressor value either by toStringing the input and callingRegressor.parseString(java.lang.String)or if it's a collection iterating over the elements calling toString on each element in turn and usingRegressor.parseElement(int, java.lang.String).- Specified by:
generateOutputin interfaceOutputFactory<Regressor>- Type Parameters:
V- The type of the input value.- Parameters:
label- An input value.- Returns:
- A MultipleRegressor with sentinel variances.
-
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<Regressor>- 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<Regressor>- Returns:
- The appropriate subclass of
MutableOutputInfoinitialised to zero.
-
constructInfoForExternalModel
public ImmutableOutputInfo<Regressor> constructInfoForExternalModel(Map<Regressor, Integer> mapping) Description copied from interface:OutputFactoryCreates anImmutableOutputInfofrom the supplied mapping. Requires that the mapping is dense in the integers [0,mapping.size()) and each mapping is unique.This call is used to import external models, and should not be used for other purposes.
- Specified by:
constructInfoForExternalModelin interfaceOutputFactory<Regressor>- Parameters:
mapping- The mapping to use.- Returns:
- The appropriate subclass of
ImmutableOutputInfowith a single observation of each element.
-
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<Regressor>- Returns:
- An evaluator.
-
getTypeWitness
Description copied from interface:OutputFactoryGets the output class that this factory supports.- Specified by:
getTypeWitnessin interfaceOutputFactory<Regressor>- Returns:
- The output class.
-
hashCode
-
equals
-
getProvenance
- Specified by:
getProvenancein interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
-