Package com.tibco.patterns.learn.api.hint

## Class SubsetFamily

- java.lang.Object
- - com.tibco.patterns.learn.api.hint.SubsetFamily

-     public final class SubsetFamily
      extends java.lang.Object

  Stores a family (a set) of RLink subsets. An empty RLink subset cannot be added to the SubsetFamily, because RLink never trains a submodel for such subset (prediction confidence for such subset is always 0), so there is no need to gather such training examples.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SubsetFamily​(FeatureQuery fq)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addFeatureValues​(double[] featureValues)` | Converts feature values to RLink subset.
    `java.util.Set<java.util.List<java.lang.Boolean>>` | `getSubsets()` |
    `boolean` | `isSubsetOfElement​(double[] featureValues)` | Checks if the subset is a subset of this family.
    `static java.lang.String` | `subsetToBinary​(java.util.List<java.lang.Boolean> subset)` |
    `boolean` | `suitableRecord​(java.util.List<java.lang.Boolean> subset, java.util.List<java.lang.String> fieldValues)` | Filters a record in a data table.
    `int[]` | `toInts()` | Converts all subsets int the family to integers.
    `java.lang.String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SubsetFamily

          public SubsetFamily​(FeatureQuery fq)

      Parameters:
        `fq` - - the feature query that generates the full set of feature values

  - ### Method Detail

    - #### toString

          public java.lang.String toString()

      Returns:
        a string with all RLink subsets in this subset family.

    - #### subsetToBinary

          public static java.lang.String subsetToBinary​(java.util.List<java.lang.Boolean> subset)

      Parameters:
        `subset` - - the given subset. Not null.
      Returns:
        the binary representation of the given subset, using symbols: 0 - empty, 1 - non-empty, ? - null (nulls should not be present).

    - #### getSubsets

          public java.util.Set<java.util.List<java.lang.Boolean>> getSubsets()

      Returns:
        unmodifiable set that contains all subsets.

    - #### toInts

          public int[] toInts()

      Converts all subsets int the family to integers. Each bit is 1 if the feature is present and 0 if it is empty. The lowest bit corresponds to the last feature.
      Returns:
        an array of integers representing each subset.
      Throws:
        `java.lang.IllegalStateException` - if more than 31 features are used.

    - #### addFeatureValues

          public void addFeatureValues​(double[] featureValues)

      Converts feature values to RLink subset. Adds the subset to the family, if subset is not empty. If subset is already added, increments its count.
      Parameters:
        `featureValues` - - values for all model features in feature query.
      Throws:
        `java.lang.IllegalArgumentException` - if number of feature values does not match the number of querylets in feature query.

    - #### isSubsetOfElement

          public boolean isSubsetOfElement​(double[] featureValues)

      Checks if the subset is a subset of this family.
      Parameters:
        `featureValues` - - values for all model features in feature query.
      Returns:
        true if the given subset is a subset of one of the subsets stored in this family.
      Throws:
        `java.lang.IllegalArgumentException` - if number of feature values does not match the number of querylets in feature query.

    - #### suitableRecord

          public boolean suitableRecord​(java.util.List<java.lang.Boolean> subset,
                                        java.util.List<java.lang.String> fieldValues)

      Filters a record in a data table. Provides functionality to filter the data table in order to select pairs for the specific RLink subset.
      Parameters:
        `subset` - - the RLink subset that this filter applies to.
        `fieldValues` - - all non-key field values of the table record. The fields must match the allFields parameter used to create feature query and features. Nulls and empty strings are considered to be "empty" values.
      Returns:
        true if the given record is potentially suitable for creating record pairs for the specified subset from this subset family
      Throws:
        `java.lang.IllegalArgumentException` - if subset does not correspond to one of the subsets stored in this subset family.