Example #1
0
 /**
  * Parses a given list of options.
  *
  * <p>
  * <!-- options-start -->
  * <!-- options-end -->
  */
 @Override
 public void setOptions(String[] options) throws Exception {
   if (m_delegate == null) {
     init();
   }
   ((OptionHandler) m_delegate).setOptions(options);
 }
Example #2
0
 /**
  * Returns an enumeration describing the available options.
  *
  * @return an enumeration of all the available options.
  */
 @Override
 public Enumeration<Option> listOptions() {
   if (m_delegate == null) {
     init();
   }
   return ((OptionHandler) m_delegate).listOptions();
 }
Example #3
0
 /**
  * Returns default capabilities of the classifier.
  *
  * @return the capabilities of this classifier
  */
 @Override
 public Capabilities getCapabilities() {
   if (m_delegate == null) {
     init();
   }
   return ((CapabilitiesHandler) m_delegate).getCapabilities();
 }
Example #4
0
  /**
   * Batch scoring method
   *
   * @param insts the instances to push over to R and get predictions for
   * @return an array of probability distributions, one for each instance
   * @throws Exception if a problem occurs
   */
  @Override
  public double[][] distributionsForInstances(Instances insts) throws Exception {
    if (m_delegate == null) {
      init();
    }

    return ((BatchPredictor) m_delegate).distributionsForInstances(insts);
  }
Example #5
0
  /**
   * Gets the current settings of MLRClassifier.
   *
   * @return an array of strings suitable for passing to setOptions()
   */
  @Override
  public String[] getOptions() {
    if (m_delegate == null) {
      init();
    }

    return ((OptionHandler) m_delegate).getOptions();
  }
Example #6
0
  /**
   * Set the parameters for the R learner. This should be specified in the same way (i.e. comma
   * separated) as they would be if using the R console.
   *
   * @param learnerParams the parameters (comma separated) to pass to the R learner.
   */
  public void setLearnerParams(String learnerParams) {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m =
          m_delegate.getClass().getDeclaredMethod("setLearnerParams", new Class[] {String.class});

      m.invoke(m_delegate, new Object[] {learnerParams});
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #7
0
  /**
   * Set the base R learner to use
   *
   * @param learner the learner to use
   */
  public void setRLearner(SelectedTag learner) {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m =
          m_delegate.getClass().getDeclaredMethod("setRLearner", new Class[] {SelectedTag.class});

      m.invoke(m_delegate, new Object[] {learner});
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #8
0
  /**
   * Set whether to output debugging info
   *
   * @param d true if debugging info is to be output
   */
  @Override
  public void setDebug(boolean d) {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m = m_delegate.getClass().getDeclaredMethod("setDebug", new Class[] {Boolean.TYPE});

      m.invoke(m_delegate, new Object[] {new Boolean(d)});
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #9
0
  /**
   * Get the parameters for the R learner. This should be specified in the same way (i.e. comma
   * separated) as they would be if using the R console.
   *
   * @return the parameters (comma separated) to pass to the R learner.
   */
  public String getLearnerParams() {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m = m_delegate.getClass().getDeclaredMethod("getLearnerParams", new Class[] {});

      Object result = m.invoke(m_delegate, new Object[] {});
      return result.toString();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return "";
  }
Example #10
0
  /**
   * Set the batch size for prediction (i.e. how many instances to push over into an R data frame at
   * a time).
   *
   * @return the batch size for prediction
   */
  @Override
  public void setBatchSize(String size) {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m =
          m_delegate.getClass().getDeclaredMethod("setBatchSize", new Class[] {String.class});

      m.invoke(m_delegate, new Object[] {size});
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #11
0
  /**
   * Returns the tip text for this property
   *
   * @return tip text for this property suitable for displaying in the explorer/experimenter gui
   */
  public String logMessagesFromRTipText() {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m = m_delegate.getClass().getDeclaredMethod("logMessagesFromRTipText", new Class[] {});

      Object result = m.invoke(m_delegate, new Object[] {});
      return result.toString();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return "";
  }
Example #12
0
  /**
   * Get the base R learner to use
   *
   * @return the learner to use
   */
  public SelectedTag getRLearner() {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m = m_delegate.getClass().getDeclaredMethod("getRLearner", new Class[] {});

      Object result = m.invoke(m_delegate, new Object[] {});
      return (SelectedTag) result;
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return null;
  }
Example #13
0
  /**
   * Get whether to log info/warning messages from R to the console.
   *
   * @return true if info/warning messages should be logged to the console.
   */
  public boolean getLogMessagesFromR() {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m = m_delegate.getClass().getDeclaredMethod("getLogMessagesFromR", new Class[] {});

      Object result = m.invoke(m_delegate, new Object[] {});
      return ((Boolean) result).booleanValue();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return false;
  }
Example #14
0
 /**
  * Build the specified R learner on the incoming training data.
  *
  * @param data the training data to be used for generating the R model.
  * @throws Exception if the classifier could not be built successfully.
  */
 @Override
 public void buildClassifier(Instances data) throws Exception {
   if (m_delegate == null) {
     init();
   }
   try {
     // m_delegate.buildClassifier(data);
     Method m =
         m_delegate.getClass().getDeclaredMethod("buildClassifier", new Class[] {Instances.class});
     m.invoke(m_delegate, new Object[] {data});
   } catch (InvocationTargetException e) {
     Throwable cause = e.getCause();
     throw new Exception(cause);
   }
 }
Example #15
0
  /**
   * Set whether to log info/warning messages from R to the console.
   *
   * @param l true if info/warning messages should be logged to the console.
   */
  public void setLogMessagesFromR(boolean l) {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m =
          m_delegate
              .getClass()
              .getDeclaredMethod("setLogMessagesFromR", new Class[] {Boolean.TYPE});

      m.invoke(m_delegate, new Object[] {new Boolean(l)});
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #16
0
  public void setLaunchedFromCommandLine(boolean l) {
    if (m_delegate == null) {
      init();
    }

    try {
      Method m =
          m_delegate
              .getClass()
              .getDeclaredMethod("setLaunchedFromCommandLine", new Class[] {Boolean.class});

      m.invoke(m_delegate, new Object[] {new Boolean(l)});
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #17
0
  /**
   * Calculates the class membership probabilities for the given test instance.
   *
   * @param instance the instance to be classified
   * @return predicted class probability distribution
   * @throws Exception if distribution can't be computed successfully
   */
  @Override
  public double[] distributionForInstance(Instance inst) throws Exception {
    if (m_delegate == null) {
      init();
    }
    try {
      Method m =
          m_delegate
              .getClass()
              .getDeclaredMethod("distributionForInstance", new Class[] {Instance.class});

      Object result = m.invoke(m_delegate, new Object[] {inst});

      return (double[]) result;
    } catch (InvocationTargetException e) {
      Throwable cause = e.getCause();

      throw new Exception(cause);
    }
  }