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

📄 checkclassifier.java

📁 Java 编写的多种数据挖掘算法 包括聚类、分类、预处理等
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   * returns the current PostProcessor, can be null   *    * @return		the current PostProcessor   */  public PostProcessor getPostProcessor() {    return m_PostProcessor;  }    /**   * returns TRUE if the classifier returned a "not in classpath" Exception   *    * @return	true if CLASSPATH problems occurred   */  public boolean hasClasspathProblems() {    return m_ClasspathProblems;  }    /**   * Begin the tests, reporting results to System.out   */  public void doTests() {        if (getClassifier() == null) {      println("\n=== No classifier set ===");      return;    }    println("\n=== Check on Classifier: "        + getClassifier().getClass().getName()        + " ===\n");        // Start tests    m_ClasspathProblems = false;    println("--> Checking for interfaces");    canTakeOptions();    boolean updateableClassifier = updateableClassifier()[0];    boolean weightedInstancesHandler = weightedInstancesHandler()[0];    boolean multiInstanceHandler = multiInstanceHandler()[0];    println("--> Classifier tests");    testsPerClassType(Attribute.NOMINAL,    updateableClassifier, weightedInstancesHandler, multiInstanceHandler);    testsPerClassType(Attribute.NUMERIC,    updateableClassifier, weightedInstancesHandler, multiInstanceHandler);    testsPerClassType(Attribute.DATE,       updateableClassifier, weightedInstancesHandler, multiInstanceHandler);    testsPerClassType(Attribute.STRING,     updateableClassifier, weightedInstancesHandler, multiInstanceHandler);    testsPerClassType(Attribute.RELATIONAL, updateableClassifier, weightedInstancesHandler, multiInstanceHandler);  }    /**   * Set debugging mode   *   * @param debug true if debug output should be printed   */  public void setDebug(boolean debug) {    m_Debug = debug;    // disable silent mode, if necessary    if (getDebug())      setSilent(false);  }    /**   * Get whether debugging is turned on   *   * @return true if debugging output is on   */  public boolean getDebug() {    return m_Debug;  }    /**   * Set slient mode, i.e., no output at all to stdout   *   * @param value whether silent mode is active or not   */  public void setSilent(boolean value) {    m_Silent = value;  }    /**   * Get whether silent mode is turned on   *   * @return true if silent mode is on   */  public boolean getSilent() {    return m_Silent;  }    /**   * Sets the number of instances to use in the datasets (some classifiers   * might require more instances).   *   * @param value the number of instances to use   */  public void setNumInstances(int value) {    m_NumInstances = value;  }    /**   * Gets the current number of instances to use for the datasets.   *   * @return the number of instances   */  public int getNumInstances() {    return m_NumInstances;  }    /**   * Set the classifier for boosting.    *   * @param newClassifier the Classifier to use.   */  public void setClassifier(Classifier newClassifier) {    m_Classifier = newClassifier;  }    /**   * Get the classifier used as the classifier   *   * @return the classifier used as the classifier   */  public Classifier getClassifier() {    return m_Classifier;  }  /**   * turns the comma-separated list into an array   *    * @param value	the list to process   * @return		the list as array   */  protected static String[] listToArray(String value) {    StringTokenizer	tok;    Vector		list;        list = new Vector();    tok = new StringTokenizer(value, ",");    while (tok.hasMoreTokens())      list.add(tok.nextToken());        return (String[]) list.toArray(new String[list.size()]);  }    /**   * turns the array into a comma-separated list   *    * @param value	the array to process   * @return		the array as list   */  protected static String arrayToList(String[] value) {    String	result;    int		i;        result = "";        for (i = 0; i < value.length; i++) {      if (i > 0)	result += ",";      result += value[i];    }        return result;  }    /**   * Sets the comma-separated list of words to use for generating strings. The   * list must contain at least 2 words, otherwise an exception will be thrown.   *    * @param value			the list of words   * @throws IllegalArgumentException	if not at least 2 words are provided   */  public void setWords(String value) {    if (listToArray(value).length < 2)      throw new IllegalArgumentException("At least 2 words must be provided!");        m_Words = listToArray(value);  }    /**   * returns the words used for assembling strings in a comma-separated list.   *    * @return		the words as comma-separated list   */  public String getWords() {    return arrayToList(m_Words);  }  /**   * sets the word separators (chars) to use for assembling strings.   *    * @param value	the characters to use as separators   */  public void setWordSeparators(String value) {    m_WordSeparators = value;  }    /**   * returns the word separators (chars) to use for assembling strings.   *    * @return		the current separators   */  public String getWordSeparators() {    return m_WordSeparators;  }    /**   * prints the given message to stdout, if not silent mode   *    * @param msg         the text to print to stdout   */  protected void print(Object msg) {    if (!getSilent())      System.out.print(msg);  }    /**   * prints the given message (+ LF) to stdout, if not silent mode   *    * @param msg         the message to println to stdout   */  protected void println(Object msg) {    print(msg + "\n");  }    /**   * prints a LF to stdout, if not silent mode   */  protected void println() {    print("\n");  }    /**   * Run a battery of tests for a given class attribute type   *   * @param classType true if the class attribute should be numeric   * @param updateable true if the classifier is updateable   * @param weighted true if the classifier says it handles weights   * @param multiInstance true if the classifier is a multi-instance classifier   */  protected void testsPerClassType(int classType,                                    boolean updateable,                                   boolean weighted,                                   boolean multiInstance) {        boolean PNom = canPredict(true,  false, false, false, false, multiInstance, classType)[0];    boolean PNum = canPredict(false, true,  false, false, false, multiInstance, classType)[0];    boolean PStr = canPredict(false, false, true,  false, false, multiInstance, classType)[0];    boolean PDat = canPredict(false, false, false, true,  false, multiInstance, classType)[0];    boolean PRel;    if (!multiInstance)      PRel = canPredict(false, false, false, false,  true, multiInstance, classType)[0];    else      PRel = false;    if (PNom || PNum || PStr || PDat || PRel) {      if (weighted)        instanceWeights(PNom, PNum, PStr, PDat, PRel, multiInstance, classType);            if (classType == Attribute.NOMINAL)        canHandleNClasses(PNom, PNum, PStr, PDat, PRel, multiInstance, 4);      if (!multiInstance) {	canHandleClassAsNthAttribute(PNom, PNum, PStr, PDat, PRel, multiInstance, classType, 0);	canHandleClassAsNthAttribute(PNom, PNum, PStr, PDat, PRel, multiInstance, classType, 1);      }            canHandleZeroTraining(PNom, PNum, PStr, PDat, PRel, multiInstance, classType);      boolean handleMissingPredictors = canHandleMissing(PNom, PNum, PStr, PDat, PRel,           multiInstance, classType,           true, false, 20)[0];      if (handleMissingPredictors)        canHandleMissing(PNom, PNum, PStr, PDat, PRel, multiInstance, classType, true, false, 100);            boolean handleMissingClass = canHandleMissing(PNom, PNum, PStr, PDat, PRel,           multiInstance, classType,           false, true, 20)[0];      if (handleMissingClass)        canHandleMissing(PNom, PNum, PStr, PDat, PRel, multiInstance, classType, false, true, 100);            correctBuildInitialisation(PNom, PNum, PStr, PDat, PRel, multiInstance, classType);      datasetIntegrity(PNom, PNum, PStr, PDat, PRel, multiInstance, classType,          handleMissingPredictors, handleMissingClass);      doesntUseTestClassVal(PNom, PNum, PStr, PDat, PRel, multiInstance, classType);      if (updateable)        updatingEquality(PNom, PNum, PStr, PDat, PRel, multiInstance, classType);    }  }    /**   * Checks whether the scheme can take command line options.   *   * @return index 0 is true if the classifier can take options   */  protected boolean[] canTakeOptions() {        boolean[] result = new boolean[2];        print("options...");    if (m_Classifier instanceof OptionHandler) {      println("yes");      if (m_Debug) {        println("\n=== Full report ===");        Enumeration enu = ((OptionHandler)m_Classifier).listOptions();        while (enu.hasMoreElements()) {          Option option = (Option) enu.nextElement();          print(option.synopsis() + "\n"               + option.description() + "\n");        }        println("\n");      }      result[0] = true;    }    else {      println("no");      result[0] = false;    }        return result;  }    /**   * Checks whether the scheme can build models incrementally.   *   * @return index 0 is true if the classifier can train incrementally   */  protected boolean[] updateableClassifier() {        boolean[] result = new boolean[2];        print("updateable classifier...");    if (m_Classifier instanceof UpdateableClassifier) {      println("yes");      result[0] = true;    }    else {      println("no");      result[0] = false;    }        return result;  }    /**   * Checks whether the scheme says it can handle instance weights.   *   * @return true if the classifier handles instance weights   */  protected boolean[] weightedInstancesHandler() {        boolean[] result = new boolean[2];        print("weighted instances classifier...");    if (m_Classifier instanceof WeightedInstancesHandler) {      println("yes");      result[0] = true;    }    else {      println("no");      result[0] = false;    }        return result;  }    /**   * Checks whether the scheme handles multi-instance data.   *    * @return true if the classifier handles multi-instance data   */  protected boolean[] multiInstanceHandler() {    boolean[] result = new boolean[2];        print("multi-instance classifier...");    if (m_Classifier instanceof MultiInstanceCapabilitiesHandler) {

⌨️ 快捷键说明

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