Package com.tibco.patterns.learn.api.project

## Class ModelTrainConfig

- java.lang.Object
- - com.tibco.patterns.learn.api.project.ModelTrainConfig

-     public final class ModelTrainConfig
      extends java.lang.Object

  Defines configuration for creating and training a Learn model. Reads/writes data from/to an XML file defined by ModelTrainConfig.xsd schema. Constructs and returns ModelConfig and ConvergenceObserver objects on demand.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ModelTrainConfig​(javax.xml.validation.Schema schema, java.nio.file.Path xmlFile)` | Loads the configuration from xmlFile.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `COErrorRate` | `createCO​(Partition partition, COErrorRate trainCO)` | Creates convergence observer for the given partition.
    `static java.util.Map<Partition,​ConvergenceObserver>` | `createDftObservers()` | Creates default observers for both datasets (COErrorRate and COErrorRateMin).
    `ModelConfig` | `createModelConfig()` | Reads ModelConfig from file.
    `java.util.Map<Partition,​ConvergenceObserver>` | `createObservers()` | Creates observers for both datasets.
    `boolean` | `isRandomOrder()` |
    `void` | `setModelConfig​(ModelConfig mConfig)` | Copies settings from mConfig to the XML structure (modelConfig node).
    `void` | `setTrainConfig​(java.lang.Boolean randomOrder, java.util.Map<Partition,​ConvergenceObserver> observers)` | Copies settings from observers to the XML structure (trainConfig node).
    `java.lang.String` | `toString()` |

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

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

- - ### Constructor Detail

    - #### ModelTrainConfig

          public ModelTrainConfig​(javax.xml.validation.Schema schema,
                                  java.nio.file.Path xmlFile)
                           throws javax.xml.bind.JAXBException

      Loads the configuration from xmlFile. Validates that the file conforms to the schema.
      Throws:
        `javax.xml.bind.JAXBException` - if XML file validation fails.
        `java.lang.IllegalArgumentException` - if the XML file is not found.

  - ### Method Detail

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### setModelConfig

          public void setModelConfig​(ModelConfig mConfig)

      Copies settings from mConfig to the XML structure (modelConfig node). Ignores custom insert scores and remove limits for Dynamic mode.
      Parameters:
        `mConfig` - - values to initialize the model configuration in ModelTrainConfig. If null, modelConfig XML node is removed.

    - #### createModelConfig

          public ModelConfig createModelConfig()

      Reads ModelConfig from file. If options are not specified in the file, they will be initialized to defaults (not based on number of features).
      Returns:
        ModelConfig read from file, or default ModelCofig object if the file does not contain the ModelConfig section.

    - #### setTrainConfig

          public void setTrainConfig​(java.lang.Boolean randomOrder,
                                     java.util.Map<Partition,​ConvergenceObserver> observers)

      Copies settings from observers to the XML structure (trainConfig node). Parameters in training observer are not copied (they are not used to stop the training).
      Parameters:
        `randomOrder` - - value for random order of training examples. If null, randomOrder XML node is removed.
        `observers` - - values to initialize the model configuration in ModelTrainConfig. If null, trainConfig XML node is removed.
      Throws:
        `java.lang.IllegalArgumentException` - if observers contain objects other than COErrorRate or COErrorRateMin.

    - #### isRandomOrder

          public boolean isRandomOrder()

      Returns:
        true if the order of training examples must be randomized before each training iteration or the parameter is not specified; false if it should not be randomized.

    - #### createCO

          public COErrorRate createCO​(Partition partition,
                                      COErrorRate trainCO)

      Creates convergence observer for the given partition.
      Parameters:
        `trainCO` - - observer used to create validation observer (not null). Not used to create the training observer.
      Returns:
        the observer to be used during training, or the default observer if it is not specified in the file.

    - #### createObservers

          public java.util.Map<Partition,​ConvergenceObserver> createObservers()

      Creates observers for both datasets.
      Returns:
        convergence observers to be used for training and validation.

    - #### createDftObservers

          public static java.util.Map<Partition,​ConvergenceObserver> createDftObservers()

      Creates default observers for both datasets (COErrorRate and COErrorRateMin).
      Returns:
        convergence observers to be used for training and validation.