Class Regressor
- All Implemented Interfaces:
- Serializable,- Iterable<Regressor.DimensionTuple>,- Output<Regressor>
- Direct Known Subclasses:
- Regressor.DimensionTuple
Output for n-dimensional real valued regression.
 
 In addition to the regressed values, it may optionally contain
 variances. Otherwise the variances are set to Double.NaN.
 
 Within a DataSource or Dataset
 each Regressor must contain the same set of named dimensions. The dimensions stored in a
 Regressor are sorted by the natural ordering of their names (i.e., using the String comparator).
 This allows the use of direct indexing into the elements.
 
 Note fullEquals(org.tribuo.regression.Regressor) compares the dimensions, the regressed values and the
 variances. However unlike Double.equals(java.lang.Object), if the two variances being compared are
 set to the sentinel value of Double.NaN, then they are considered equal.
 
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classARegressorwhich contains a single dimension, used internally when the model implementation doesn't natively support multi-dimensional regression outputs.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringDefault name used for dimensions which are unnamed when parsed from Strings.static final doubleThe tolerance value for determining if two regressed values are equal.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a regressor from the supplied named values.Constructs a regressor from the supplied named values.Constructs a regressor containing a single dimension, usingDouble.NaNas the variance.Constructs a regressor containing a single dimension.Regressor(Regressor.DimensionTuple[] dimensions) Constructs a regressor from the supplied dimension tuples.
- 
Method SummaryModifier and TypeMethodDescriptioncopy()Deep copy of the output up to it's immutable state.static RegressorcreateFromPairList(List<com.oracle.labs.mlrg.olcut.util.Pair<String, Double>> dimensions) Creates a Regressor from a list of dimension tuples.booleanRegressors are equal if they have the same number of dimensions and equal dimension names.static String[]extractNames(OutputInfo<Regressor> info) Extracts the names from the supplied Regressor domain in their canonical order.booleanfullEquals(Regressor other) Compares other to this output.getDimension(int idx) Returns a dimension tuple for the requested dimension index.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.getDimensionNamesString(char separator) Returns a delimiter separated list of the dimension names.String[]getNames()The names of the dimensions.getSerializableForm(boolean includeConfidence) Generates a String suitable for writing to a csv or json file.double[]Returns the regression values.double[]The variances of the regressed values, if known.inthashCode()Regressor's hashcode is based on the hash of the dimension names.iterator()parseElement(int idx, String s) Parses a string of the form:static RegressorParses a string of the form:static RegressorparseString(String s, char splitChar) Parses a string of the form:intsize()Returns the number of dimensions in this regressor.toString()Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Field Details- 
TOLERANCEpublic static final double TOLERANCEThe tolerance value for determining if two regressed values are equal.- See Also:
 
- 
DEFAULT_NAMEDefault name used for dimensions which are unnamed when parsed from Strings.- See Also:
 
 
- 
- 
Constructor Details- 
RegressorConstructs a regressor from the supplied named values. ThrowsIllegalArgumentExceptionif the arrays are not all the same size.- Parameters:
- names- The names of the dimensions.
- values- The values of the dimensions.
- variances- The variances of the specified values.
 
- 
RegressorConstructs a regressor from the supplied named values. UsesDouble.NaNas the variances.- Parameters:
- names- The names of the dimensions.
- values- The values of the dimensions.
 
- 
RegressorConstructs a regressor from the supplied dimension tuples.- Parameters:
- dimensions- The named values to use.
 
- 
RegressorConstructs a regressor containing a single dimension, usingDouble.NaNas the variance.- Parameters:
- name- The name of the dimension.
- value- The value of the dimension.
 
- 
RegressorConstructs a regressor containing a single dimension.- Parameters:
- name- The name of the dimension.
- value- The value of the dimension.
- variance- The variance of this value.
 
 
- 
- 
Method Details- 
sizepublic int size()Returns the number of dimensions in this regressor.- Returns:
- The number of dimensions.
 
- 
getNamesThe names of the dimensions. Always sorted by their natural ordering.- Returns:
- The names of the dimensions.
 
- 
getValuespublic double[] getValues()Returns the regression values.The index corresponds to the index of the name. In a single dimensional regression this is a single element array. - Returns:
- The regression values.
 
- 
getVariancespublic double[] getVariances()The variances of the regressed values, if known. If the variances are unknown (or not set by the model) they are filled withDouble.NaN.The index corresponds to the index of the name. In a single dimensional regression this is a single element array. - Returns:
- The variance of the regressed values.
 
- 
toString
- 
getDimensionReturns a dimension tuple for the requested dimension, or optional empty if it's not valid.- Parameters:
- name- The dimension name.
- Returns:
- A tuple representing that dimension.
 
- 
getDimensionReturns a dimension tuple for the requested dimension index.- Parameters:
- idx- The dimension index.
- Returns:
- A tuple representing that dimension.
- Throws:
- IndexOutOfBoundsException- if the index is outside the range.
 
- 
iterator- Specified by:
- iteratorin interface- Iterable<Regressor.DimensionTuple>
 
- 
copy
- 
getSerializableFormDescription copied from interface:OutputGenerates a String suitable for writing to a csv or json file.- Specified by:
- getSerializableFormin interface- Output<Regressor>
- Parameters:
- includeConfidence- Include whatever confidence score the label contains, if known.
- Returns:
- A String representation of this Output.
 
- 
fullEqualsDescription copied from interface:OutputCompares other to this output. Uses all score values and the strings.- Specified by:
- fullEqualsin interface- Output<Regressor>
- Parameters:
- other- Another output instance.
- Returns:
- True if the other instance has value equality to this instance. False otherwise.
 
- 
equals
- 
hashCode
- 
getDimensionNamesStringReturns a comma separated list of the dimension names.- Returns:
- The dimension names comma separated.
 
- 
getDimensionNamesStringReturns a delimiter separated list of the dimension names.- Parameters:
- separator- The separator to use.
- Returns:
- The dimension names.
 
- 
extractNamesExtracts the names from the supplied Regressor domain in their canonical order.- Parameters:
- info- The OutputInfo to use.
- Returns:
- The dimension names from this domain.
 
- 
parseStringParses a string of the form:dimension-name=output,...,dimension-name=output oroutput,...,output where output must be readable byDouble.parseDouble(java.lang.String). If there are no dimension names specified then they are automatically generated based on the position in the string.- Parameters:
- s- The string form of a multiple regressor.
- Returns:
- A regressor parsed from the input string.
 
- 
parseStringParses a string of the form:dimension-name=output<splitChar>...<splitChar>dimension-name=output oroutput<splitChar>...<splitChar>output where output must be readable byDouble.parseDouble(java.lang.String). If there are no dimension names specified then they are automatically generated based on the position in the string.- Parameters:
- s- The string form of a regressor.
- splitChar- The char to split on.
- Returns:
- A regressor parsed from the input string.
 
- 
parseElementParses a string of the form:dimension-name=output-double oroutput-double where the output must be readable byDouble.parseDouble(java.lang.String). If there is no dimension name then one is constructed by appending idx toDEFAULT_NAME.- Parameters:
- idx- The index of this string in a list.
- s- The string form of a single dimension from a regressor.
- Returns:
- A tuple representing the dimension name and the value.
 
- 
createFromPairList
 
-