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

📄 removemisclassified.java

📁 代码是一个分类器的实现,其中使用了部分weka的源代码。可以将项目导入eclipse运行
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	      + "\tIf < 0 will use any current set class or default to the last attribute.",	      "C", 1, "-C <class index>"));    newVector.addElement(new Option(	      "\tThe number of folds to use for cross-validation cleansing.\n"	      +"\t(<2 = no cross-validation - default).",	      "F", 1, "-F <number of folds>"));    newVector.addElement(new Option(	      "\tThreshold for the max error when predicting numeric class.\n"	      +"\t(Value should be >= 0, default = 0.1).",	      "T", 1, "-T <threshold>"));    newVector.addElement(new Option(	      "\tThe maximum number of cleansing iterations to perform.\n"	      +"\t(<1 = until fully cleansed - default)",	      "I", 1,"-I"));    newVector.addElement(new Option(	      "\tInvert the match so that correctly classified instances are discarded.\n",	      "V", 0,"-V"));        return newVector.elements();  }  /**   * Parses a given list of options. <p/>   *    <!-- options-start -->   * Valid options are: <p/>   *    * <pre> -W &lt;classifier specification&gt;   *  Full class name of classifier to use, followed   *  by scheme options. eg:   *   "weka.classifiers.bayes.NaiveBayes -D"   *  (default: weka.classifiers.rules.ZeroR)</pre>   *    * <pre> -C &lt;class index&gt;   *  Attribute on which misclassifications are based.   *  If &lt; 0 will use any current set class or default to the last attribute.</pre>   *    * <pre> -F &lt;number of folds&gt;   *  The number of folds to use for cross-validation cleansing.   *  (&lt;2 = no cross-validation - default).</pre>   *    * <pre> -T &lt;threshold&gt;   *  Threshold for the max error when predicting numeric class.   *  (Value should be &gt;= 0, default = 0.1).</pre>   *    * <pre> -I   *  The maximum number of cleansing iterations to perform.   *  (&lt;1 = until fully cleansed - default)</pre>   *    * <pre> -V   *  Invert the match so that correctly classified instances are discarded.   * </pre>   *    <!-- options-end -->   *   * @param options the list of options as an array of strings   * @throws Exception if an option is not supported   */  public void setOptions(String[] options) throws Exception {    String classifierString = Utils.getOption('W', options);    if (classifierString.length() == 0)      classifierString = weka.classifiers.rules.ZeroR.class.getName();    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 (iString.length() != 0) {      setMaxIterations((new Double(iString)).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 &lt; 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   * - &lt; 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 &gt;= 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   * - &lt; 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) {    runFilter(new RemoveMisclassified(), argv);  }}

⌨️ 快捷键说明

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