OptionsHandler

dbn.data

## Class OptionsHandler

- java.lang.Object
- - dbn.data.OptionsHandler

-     public class OptionsHandler
      extends java.lang.Object

  This class handles the user's options of the main class. It is a control class that takes the user's parameters and converts them to objects of their appropriate class. Then the user can get all the parameters using the getters without any additional process. There is a set of parameters that this handler can convert and the options have specific codes.
  The options are:
  `-path "folder/path/"` the path where train, test and info files are placed.
  `-train "train/ARFF/file.arff"` the train dataset in ARFF format. If path option is set, user mustn't put the path again.
  `-test "test/ARFF/file.arff"` the test dataset in ARFF format. If path option is set, user mustn't put the path again.
  `-load "DBN/file.dbn"` the path where the `DeepBeliefNetwork` has been saved. The `path` option doesn't concern this option.
  `-info "XML/file.xml"` the info XML file. If path option is set, user mustn't put the path again. User can use `targets` option instead.
  `-targets integer` the number of targets (labels). User can use `info` option instead.
  `-ge integer` the number of greedyEpochs that the classifier will repeat the greedy learning for every RBM.
  `-be integer` the number of greedyEpochs that the classifier will repeat the back-propagation training for every instance.
  `-m double` the momentum parameter. This parameter specifies the urge value.
  `-lr double` an annealing parameter that handles the step size. A big learning rate will occur a fast gradient descent and undesired solutions.
  `-wcost double` the weight cost option focuses to the weights of the neural network.
  `-l [first layer's number of features] ... [last layer's number of features]` the number of units on each layer.
  `-threshold [double]` this option sets the value of the threshold.
  `-debug` if this option is set, the program prints the process of the training task.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OptionsHandler()` The constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getBPEpochs()` Gets number of back-propagation training epochs.
    `static mulan.data.MultiLabelInstances` | `GetData(java.lang.String path)` Gets an ARFF path and returns the `MultiLabelInstances` object for the specific file. Throws an `InvalidDataFormatException` when the file is not in the appropriate format.
    `boolean` | `getDebug()` Informs if user has chosen the option "debug".
    `static java.lang.String` | `GetFileName(java.lang.String path)` Gets as a parameter a file path `String` and returns the name of the file without the path and the ending.
    `int` | `getGreedyEpochs()` Gets number of greedy training epochs.
    `int[]` | `getLayers()` Gets an array with the number of units for each layer.
    `double` | `getLearningRate()` Gets the learning rate.
    `double` | `getMomentum()` Gets the momentum.
    `DeepBeliefNetwork` | `getNN()` Gets the `DeepBeliefNetwork`.
    `java.lang.String` | `getTestPath()` Gets the testing set's path.
    `mulan.data.MultiLabelInstances` | `getTestSet()` Gets the testing dataset in a `MultiLabelInstances` form.
    `double` | `getThreshold()` Gets the threshold.
    `java.lang.String` | `getTrainPath()` Gets the training set's path.
    `mulan.data.MultiLabelInstances` | `getTrainSet()` Gets the training dataset in a `MultiLabelInstances` form.
    `double` | `getWeightCost()` Gets a value of the regularization cost term for weights decay.
    `void` | `setArgs(java.lang.String[] args)` Sets all the fields values using the user's set options. Throws `IOException` when the input files are not set or invalid. Throws `Exception` for other reasons.

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

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

- - ### Constructor Detail

    - #### OptionsHandler

          public OptionsHandler()

      The constructor. Initializes the map to contain all the necessary options.

  - ### Method Detail

    - #### setArgs

          public void setArgs(java.lang.String[] args)
                       throws java.io.IOException,
                              java.lang.Exception

      Sets all the fields values using the user's set options.
      Throws `IOException` when the input files are not set or invalid.
      Throws `Exception` for other reasons.
      Parameters:
        `args` - the users options
      Throws:
        `java.io.IOException`
        `java.lang.Exception`

    - #### GetData

          public static mulan.data.MultiLabelInstances GetData(java.lang.String path)
                                                        throws mulan.data.InvalidDataFormatException

      Gets an ARFF path and returns the `MultiLabelInstances` object for the specific file.
      Throws an `InvalidDataFormatException` when the file is not in the appropriate format.
      Parameters:
        `path` - the file's path
      Returns:
        the dataset in a `MultiLabelInstances` form
      Throws:
        `mulan.data.InvalidDataFormatException`

    - #### getTrainSet

          public mulan.data.MultiLabelInstances getTrainSet()
                                                     throws mulan.data.InvalidDataFormatException

      Gets the training dataset in a `MultiLabelInstances` form.
      Returns:
        the training set in a `MultiLabelInstances` form
      Throws:
        `mulan.data.InvalidDataFormatException` - when the input file is not in the appropriate format (ARFF)

    - #### getTestSet

          public mulan.data.MultiLabelInstances getTestSet()
                                                    throws mulan.data.InvalidDataFormatException

      Gets the testing dataset in a `MultiLabelInstances` form.
      Returns:
        the testing dataset in a `MultiLabelInstances` form
      Throws:
        `mulan.data.InvalidDataFormatException` - when the input file is not in the appropriate format (ARFF)

    - #### getTrainPath

          public java.lang.String getTrainPath()

      Gets the training set's path.
      Returns:
        the training set's path
      Throws:
        `java.lang.NullPointerException` - when the training set's file path has not set

    - #### getTestPath

          public java.lang.String getTestPath()

      Gets the testing set's path.
      Returns:
        the testing set's path
      Throws:
        `java.lang.NullPointerException` - when the testing set's file path has not set

    - #### getLayers

          public int[] getLayers()

      Gets an array with the number of units for each layer.
      Returns:
        the array with the number of units for each layer.

    - #### getGreedyEpochs

          public int getGreedyEpochs()

      Gets number of greedy training epochs.
      Default value is 20.
      Returns:
        greedy training epochs

    - #### getBPEpochs

          public int getBPEpochs()

      Gets number of back-propagation training epochs.
      Default value is 2.
      Returns:
        back-propagation training epochs per

    - #### getMomentum

          public double getMomentum()

      Gets the momentum.
      The default value is 0.6.
      Returns:
        momentum

    - #### getLearningRate

          public double getLearningRate()

      Gets the learning rate.
      The default value is 0.05.
      Returns:
        learning rate

    - #### getWeightCost

          public double getWeightCost()

      Gets a value of the regularization cost term for weights decay.
      The default value is 0.00001
      Returns:
        regularization cost

    - #### getDebug

          public boolean getDebug()

      Informs if user has chosen the option "debug".
      The default value is `false`
      Returns:
        `true` if user has chosen the option "debug"
        `false` if user hasn't chosen the option "debug"

    - #### getThreshold

          public double getThreshold()

      Gets the threshold.
      The default value is -1.
      Returns:
        threshold

    - #### getNN

          public DeepBeliefNetwork getNN()

      Gets the `DeepBeliefNetwork`. If user has set the option "load" the NN will be loaded from the hard drive, otherwise this function will construct a new neural network.
      Returns:
        the loaded `DeepBeliefNetwork`. If user hasn't chosen to load a neural network, it will return a new one.

    - #### GetFileName

          public static java.lang.String GetFileName(java.lang.String path)

      Gets as a parameter a file path `String` and returns the name of the file without the path and the ending.
      Parameters:
        `path` - the file's path
      Returns:
        the file's name