Package org.tribuo.regression
Class Regressor.DimensionTuple
java.lang.Object
org.tribuo.regression.Regressor
org.tribuo.regression.Regressor.DimensionTuple
- All Implemented Interfaces:
Serializable
,Iterable<Regressor.DimensionTuple>
,Output<Regressor>
,ProtoSerializable<org.tribuo.protos.core.OutputProto>
- Enclosing class:
- Regressor
A
Regressor
which contains a single dimension, used internally
when the model implementation doesn't natively support multi-dimensional
regression outputs.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.tribuo.regression.Regressor
Regressor.DimensionTuple
-
Field Summary
Fields inherited from class org.tribuo.regression.Regressor
DEFAULT_NAME, TOLERANCE
Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ConstructorDescriptionDimensionTuple
(String name, double value) Creates a dimension tuple from the supplied name and value.DimensionTuple
(String name, double value, double variance) Creates a dimension tuple from the supplied name, value and variance. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Deep copy of the output up to its immutable state.static Regressor.DimensionTuple
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
Regressors are equal if they have the same number of dimensions and equal dimension names.boolean
fullEquals
(Regressor other) Compares other to this output.getDimension
(String name) Returns a dimension tuple for the requested dimension, or optional empty if it's not valid.Returns a comma separated list of the dimension names.getName()
Returns the name.getSerializableForm
(boolean includeConfidence) Generates a String suitable for writing to a csv or json file.double
getValue()
Returns the value.double
Returns the variance.int
hashCode()
All regressors have a hashcode based on only the dimension names.iterator()
org.tribuo.protos.core.OutputProto
Serializes this object to a protobuf.int
size()
Returns the number of dimensions in this regressor.toString()
Methods inherited from class org.tribuo.regression.Regressor
createFromPairList, extractNames, fullEquals, getDimension, getDimensionNamesString, getNames, getValues, getVariances, parseElement, parseString, parseString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
DimensionTuple
Creates a dimension tuple from the supplied name, value and variance.- Parameters:
name
- The dimension name.value
- The dimension value.variance
- The variance of the value, if known. OtherwiseDouble.NaN
.
-
DimensionTuple
Creates a dimension tuple from the supplied name and value. Sets the variance toDouble.NaN
.- Parameters:
name
- The dimension name.value
- The dimension value.
-
-
Method Details
-
deserializeFromProto
public static Regressor.DimensionTuple 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
.
-
size
public int size()Description copied from class:Regressor
Returns the number of dimensions in this regressor. -
toString
-
getDimension
Description copied from class:Regressor
Returns a dimension tuple for the requested dimension, or optional empty if it's not valid.- Overrides:
getDimension
in classRegressor
- Parameters:
name
- The dimension name.- Returns:
- A tuple representing that dimension.
-
iterator
- Specified by:
iterator
in interfaceIterable<Regressor.DimensionTuple>
- Overrides:
iterator
in classRegressor
-
copy
Description copied from interface:Output
Deep copy of the output up to its immutable state. -
getName
Returns the name.- Returns:
- The name.
-
getValue
public double getValue()Returns the value.- Returns:
- The value.
-
getVariance
public double getVariance()Returns the variance.- Returns:
- The variance.
-
getSerializableForm
Description copied from interface:Output
Generates a String suitable for writing to a csv or json file.- Specified by:
getSerializableForm
in interfaceOutput<Regressor>
- Overrides:
getSerializableForm
in classRegressor
- Parameters:
includeConfidence
- Include whatever confidence score the label contains, if known.- Returns:
- A String representation of this Output.
-
fullEquals
Description copied from interface:Output
Compares other to this output. Uses all score values and the strings.- Specified by:
fullEquals
in interfaceOutput<Regressor>
- Overrides:
fullEquals
in classRegressor
- Parameters:
other
- Another output instance.- Returns:
- True if the other instance has value equality to this instance. False otherwise.
-
equals
Description copied from class:Regressor
Regressors are equal if they have the same number of dimensions and equal dimension names. -
hashCode
public int hashCode()All regressors have a hashcode based on only the dimension names. -
getDimensionNamesString
Description copied from class:Regressor
Returns a comma separated list of the dimension names.- Overrides:
getDimensionNamesString
in classRegressor
- Returns:
- The dimension names comma separated.
-
serialize
public org.tribuo.protos.core.OutputProto serialize()Description copied from interface:ProtoSerializable
Serializes this object to a protobuf.- Specified by:
serialize
in interfaceProtoSerializable<org.tribuo.protos.core.OutputProto>
- Overrides:
serialize
in classRegressor
- Returns:
- The protobuf.
-