Package org.tribuo.regression
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>
A factory for creating
Regressor
s and RegressionInfo
s.
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
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
The default character to split the string form of a multidimensional regressor.static final Regressor
Deprecated.Deprecated when regression was made multidimensional by default.static final Regressor
The sentinel unknown regressor, used when there is no ground truth regressor value. -
Constructor Summary
ConstructorDescriptionBuilds a regression factory using the default split characterDEFAULT_SPLIT_CHAR
.RegressionFactory
(char splitChar) Sets the split character used to parseRegressor
instances from Strings. -
Method Summary
Modifier and TypeMethodDescriptionconstructInfoForExternalModel
(Map<Regressor, Integer> mapping) Creates anImmutableOutputInfo
from the supplied mapping.boolean
Generates the appropriateMutableOutputInfo
so the output values can be tracked by aDataset
or other aggregate.<V> Regressor
generateOutput
(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 anEvaluator
suitable for measuring performance of predictions for the Output subclass.Returns the singleton unknown output of type T which can be used for prediction time examples.int
hashCode()
void
Used by the OLCUT configuration system, and should not be called by external code.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods 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_REGRESSOR
instead.
-
-
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 parseRegressor
instances 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:
postConfig
in interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
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:
generateOutput
in 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:OutputFactory
Returns the singleton unknown output of type T which can be used for prediction time examples.- Specified by:
getUnknownOutput
in interfaceOutputFactory<Regressor>
- Returns:
- An unknown output.
-
generateInfo
Description copied from interface:OutputFactory
Generates the appropriateMutableOutputInfo
so the output values can be tracked by aDataset
or other aggregate.- Specified by:
generateInfo
in interfaceOutputFactory<Regressor>
- Returns:
- The appropriate subclass of
MutableOutputInfo
initialised to zero.
-
constructInfoForExternalModel
Description copied from interface:OutputFactory
Creates anImmutableOutputInfo
from 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:
constructInfoForExternalModel
in interfaceOutputFactory<Regressor>
- Parameters:
mapping
- The mapping to use.- Returns:
- The appropriate subclass of
ImmutableOutputInfo
with a single observation of each element.
-
getEvaluator
Description copied from interface:OutputFactory
Gets anEvaluator
suitable for measuring performance of predictions for the Output subclass.Evaluator
instances are thread safe and immutable, and commonly this is a singleton stored in theOutputFactory
implementation.- Specified by:
getEvaluator
in interfaceOutputFactory<Regressor>
- Returns:
- An evaluator.
-
hashCode
public int hashCode() -
equals
-
getProvenance
- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
-