Package org.tribuo
Class RealInfo
java.lang.Object
org.tribuo.SkeletalVariableInfo
org.tribuo.RealInfo
- All Implemented Interfaces:
Serializable
,Cloneable
,ProtoSerializable<org.tribuo.protos.core.VariableInfoProto>
,VariableInfo
- Direct Known Subclasses:
RealIDInfo
Stores information about real valued features.
Contains sufficient statistics to model the feature as a gaussian, plus the max and min values.
Does not contain an id number, but can be transformed into RealIDInfo
which
does contain an id number.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Protobuf serialization version.protected double
The maximum observed feature value.protected double
The feature mean.protected double
The minimum observed feature value.protected double
The sum of the squared feature values (used to compute the variance).Fields inherited from class org.tribuo.SkeletalVariableInfo
count, name
Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ModifierConstructorDescriptionCreates an empty real info with the supplied name.Creates a real info with the supplied starting conditions.Creates a real info with the supplied starting conditions.Copy constructor.protected
Copy constructor which renames the feature. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Returns a copy of this variable info.static RealInfo
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
double
getMax()
Gets the maximum observed value.double
getMean()
Gets the sample mean.double
getMin()
Gets the minimum observed value.double
Gets the sample variance.int
hashCode()
makeIDInfo
(int id) Generates a VariableIDInfo subclass which represents the same feature.protected void
observe
(double value) Records the value.Rename generates a fresh VariableInfo with the new name.org.tribuo.protos.core.VariableInfoProto
Serializes this object to a protobuf.toString()
double
Sample a value uniformly from the range of this variable.Methods inherited from class org.tribuo.SkeletalVariableInfo
getCount, getName
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
max
protected double maxThe maximum observed feature value. -
min
protected double minThe minimum observed feature value. -
mean
protected double meanThe feature mean. -
sumSquares
protected double sumSquaresThe sum of the squared feature values (used to compute the variance).
-
-
Constructor Details
-
RealInfo
Creates an empty real info with the supplied name.- Parameters:
name
- The feature name.
-
RealInfo
Creates a real info with the supplied starting conditions.All observations are assumed to be of zero.
- Parameters:
name
- The feature name.count
- The number of zeros observed.
-
RealInfo
Creates a real info with the supplied starting conditions.- Parameters:
name
- The feature name.count
- The observation count.max
- The maximum observed value.min
- The minimum observed value.mean
- The mean observed value.sumSquares
- The sum of the squared values (used to calculate variance online).
-
RealInfo
Copy constructor.- Parameters:
other
- The info to copy.
-
RealInfo
Copy constructor which renames the feature. Used to redact the feature name.- Parameters:
other
- The info to copy.newName
- The new name.
-
-
Method Details
-
deserializeFromProto
public static RealInfo 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.VariableInfoProto serialize()Description copied from interface:ProtoSerializable
Serializes this object to a protobuf.- Returns:
- The protobuf.
-
observe
protected void observe(double value) Description copied from class:SkeletalVariableInfo
Records the value.- Overrides:
observe
in classSkeletalVariableInfo
- Parameters:
value
- The observed value.
-
getMin
public double getMin()Gets the minimum observed value.- Returns:
- The minimum value.
-
getMax
public double getMax()Gets the maximum observed value.- Returns:
- The maximum value.
-
getMean
public double getMean()Gets the sample mean.- Returns:
- The sample mean.
-
getVariance
public double getVariance()Gets the sample variance.- Returns:
- The sample variance.
-
copy
Description copied from interface:VariableInfo
Returns a copy of this variable info.- Returns:
- A copy.
-
makeIDInfo
Description copied from interface:VariableInfo
Generates a VariableIDInfo subclass which represents the same feature.- Parameters:
id
- The id number.- Returns:
- A VariableInfo with the same information, plus the id.
-
rename
Description copied from interface:VariableInfo
Rename generates a fresh VariableInfo with the new name. The name forms part of the hashcode so it's immutable in the object.- Parameters:
newName
- The new name.- Returns:
- A VariableInfo subclass with the new name.
-
uniformSample
Description copied from interface:VariableInfo
Sample a value uniformly from the range of this variable.- Parameters:
rng
- The rng to use.- Returns:
- A sample from this variable.
-
equals
- Overrides:
equals
in classSkeletalVariableInfo
-
hashCode
public int hashCode()- Overrides:
hashCode
in classSkeletalVariableInfo
-
toString
- Overrides:
toString
in classSkeletalVariableInfo
-