⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 removemisclassified.java

📁 wekaUT是 university texas austin 开发的基于weka的半指导学习(semi supervised learning)的分类器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
   * (<1 = until fully cleansed - default)<p>   *   * -V <br>   * Invert the match so that correctly classified instances are discarded.<p>   *   * @param options the list of options as an array of strings   * @exception Exception if an option is not supported   */  public void setOptions(String[] options) throws Exception {    String classifierString = Utils.getOption('W', options);    if (classifierString.length() == 0) {      throw new Exception("A classifier must be specified"			  + " with the -W option.");    }    String[] classifierSpec = Utils.splitOptions(classifierString);    if (classifierSpec.length == 0) {      throw new Exception("Invalid classifier specification string");    }    String classifierName = classifierSpec[0];    classifierSpec[0] = "";    setClassifier(Classifier.forName(classifierName, classifierSpec));    String cString = Utils.getOption('C', options);    if (cString.length() != 0) {      setClassIndex((new Double(cString)).intValue());    } else {      setClassIndex(-1);    }    String fString = Utils.getOption('F', options);    if (fString.length() != 0) {      setNumFolds((new Double(fString)).intValue());    } else {      setNumFolds(0);    }    String tString = Utils.getOption('T', options);    if (tString.length() != 0) {      setThreshold((new Double(tString)).doubleValue());    } else {      setThreshold(0.1);    }    String iString = Utils.getOption('I', options);    if (tString.length() != 0) {      setMaxIterations((new Double(tString)).intValue());    } else {      setMaxIterations(0);    }        if (Utils.getFlag('V', options)) {      setInvert(true);    } else {      setInvert(false);    }            Utils.checkForRemainingOptions(options);  }  /**   * Gets the current settings of the filter.   *   * @return an array of strings suitable for passing to setOptions   */  public String [] getOptions() {    String [] options = new String [15];    int current = 0;    options[current++] = "-W"; options[current++] = "" + getClassifierSpec();    options[current++] = "-C"; options[current++] = "" + getClassIndex();    options[current++] = "-F"; options[current++] = "" + getNumFolds();    options[current++] = "-T"; options[current++] = "" + getThreshold();    options[current++] = "-I"; options[current++] = "" + getMaxIterations();    if (getInvert()) {      options[current++] = "-V";    }        while (current < options.length) {      options[current++] = "";    }    return options;  }  /**   * Returns a string describing this filter   *   * @return a description of the filter suitable for   * displaying in the explorer/experimenter gui   */  public String globalInfo() {    return "A filter that removes instances which are incorrectly classified. Useful for removing outliers.";  }  /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String classifierTipText() {    return "The classifier upon which to base the misclassifications.";  }  /**   * Sets the classifier to classify instances with.   *   * @param classifier The classifier to be used (with its options set).   */  public void setClassifier(Classifier classifier) {    m_cleansingClassifier = classifier;  }    /**   * Gets the classifier used by the filter.   *   * @return The classifier to be used.   */  public Classifier getClassifier() {    return m_cleansingClassifier;  }  /**   * Gets the classifier specification string, which contains the class name of   * the classifier and any options to the classifier.   *   * @return the classifier string.   */  protected String getClassifierSpec() {        Classifier c = getClassifier();    if (c instanceof OptionHandler) {      return c.getClass().getName() + " "	+ Utils.joinOptions(((OptionHandler)c).getOptions());    }    return c.getClass().getName();  }  /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String classIndexTipText() {    return "Index of the class upon which to base the misclassifications. "      + "If < 0 will use any current set class or default to the last attribute.";  }  /**   * Sets the attribute on which misclassifications are based.   * If < 0 will use any current set class or default to the last attribute.   *   * @param classIndex the class index.   */  public void setClassIndex(int classIndex) {        m_classIndex = classIndex;  }  /**   * Gets the attribute on which misclassifications are based.   *   * @return the class index.   */  public int getClassIndex() {    return m_classIndex;  }  /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String numFoldsTipText() {    return "The number of cross-validation folds to use. If < 2 then no cross-validation will be performed.";  }  /**   * Sets the number of cross-validation folds to use   * - < 2 means no cross-validation.   *   * @param numOfFolds the number of folds.   */  public void setNumFolds(int numOfFolds) {        m_numOfCrossValidationFolds = numOfFolds;  }  /**   * Gets the number of cross-validation folds used by the filter.   *   * @return the number of folds.   */  public int getNumFolds() {    return m_numOfCrossValidationFolds;  }  /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String thresholdTipText() {    return "Threshold for the max allowable error when predicting a numeric class. Should be >= 0.";  }  /**   * Sets the threshold for the max error when predicting a numeric class.   * The value should be >= 0.   *   * @param threshold the numeric theshold.   */  public void setThreshold(double threshold) {        m_numericClassifyThreshold = threshold;  }  /**   * Gets the threshold for the max error when predicting a numeric class.   *   * @return the numeric threshold.   */  public double getThreshold() {    return m_numericClassifyThreshold;  }  /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String maxIterationsTipText() {    return "The maximum number of iterations to perform. < 1 means filter will go until fully cleansed.";  }  /**   * Sets the maximum number of cleansing iterations to perform   * - < 1 means go until fully cleansed   *   * @param iterations the maximum number of iterations.   */  public void setMaxIterations(int iterations) {        m_numOfCleansingIterations = iterations;  }  /**   * Gets the maximum number of cleansing iterations performed   *   * @return the maximum number of iterations.    */  public int getMaxIterations() {    return m_numOfCleansingIterations;  }  /**   * Returns the tip text for this property   *   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String invertTipText() {    return "Whether or not to invert the selection. If true, correctly classified instances will be discarded.";  }  /**   * Set whether selection is inverted.   *   * @param invert whether or not to invert selection.   */  public void setInvert(boolean invert) {        m_invertMatching = invert;  }  /**   * Get whether selection is inverted.   *   * @return whether or not selection is inverted.   */  public boolean getInvert() {        return m_invertMatching;  }  /**   * Main method for testing this class.   *   * @param argv should contain arguments to the filter: use -h for help   */  public static void main(String [] argv) {    try {      if (Utils.getFlag('b', argv)) { 	Filter.batchFilterFile(new RemoveMisclassified(), argv);       } else {	Filter.filterFile(new RemoveMisclassified(), argv);      }    } catch (Exception ex) {      System.out.println(ex.getMessage());    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -