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

📄 subspaceclusterdefinition.java

📁 代码是一个分类器的实现,其中使用了部分weka的源代码。可以将项目导入eclipse运行
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    return "The attribute range(s).";  }  public boolean[] getAttributes() {    return m_attributes;  }  public double[] getMinValue() {    return m_minValue;  }  public double[] getMaxValue() {    return m_maxValue;  }  public double[] getMeanValue() {    return m_meanValue;  }  public double[] getStddevValue() {    return m_stddevValue;  }  public int getNumInstances () {     return m_numInstances;   }  /**   * returns the default cluster type   *    * @return the default cluster type   */  protected SelectedTag defaultClusterType() {    return new SelectedTag(        SubspaceCluster.UNIFORM_RANDOM, SubspaceCluster.TAGS_CLUSTERTYPE);  }    /**   * Gets the cluster type.   *   * @return the cluster type   * @see SubspaceCluster#TAGS_CLUSTERTYPE   */  public SelectedTag getClusterType() {    return new SelectedTag(m_clustertype, SubspaceCluster.TAGS_CLUSTERTYPE);  }    /**   * Sets the cluster type.   *   * @param value the new cluster type.   * @see SubspaceCluster#TAGS_CLUSTERTYPE   */  public void setClusterType(SelectedTag value) {    if (value.getTags() == SubspaceCluster.TAGS_CLUSTERTYPE)      m_clustertype = value.getSelectedTag().getID();  }    /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String clusterTypeTipText() {    return "The type of cluster to use.";  }  /**   * returns the default cluster sub type   *    * @return the default cluster sub type   */  protected SelectedTag defaultClusterSubType() {    return new SelectedTag(        SubspaceCluster.CONTINUOUS, SubspaceCluster.TAGS_CLUSTERSUBTYPE);  }    /**   * Gets the cluster sub type.   *   * @return the cluster sub type   * @see SubspaceCluster#TAGS_CLUSTERSUBTYPE   */  public SelectedTag getClusterSubType() {    return new SelectedTag(                  m_clustersubtype, SubspaceCluster.TAGS_CLUSTERSUBTYPE);  }    /**   * Sets the cluster sub type.   *   * @param value the new cluster sub type.   * @see SubspaceCluster#TAGS_CLUSTERSUBTYPE   */  public void setClusterSubType(SelectedTag value) {    if (value.getTags() == SubspaceCluster.TAGS_CLUSTERSUBTYPE)      m_clustersubtype = value.getSelectedTag().getID();  }    /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String clusterSubTypeTipText() {    return "The sub-type of cluster to use.";  }  /**    * checks, whether cluster type is random   *    * @return true if cluster type is random   */  public boolean isRandom() {    return (m_clustertype == SubspaceCluster.UNIFORM_RANDOM);  }  /**    * checks, whether cluster type is uniform   *    * @return true if cluster type is uniform   */  public boolean isUniform() {    return (m_clustertype == SubspaceCluster.TOTAL_UNIFORM);  }  /**    * checks, whether cluster type is gaussian   *    * @return true if cluster type is gaussian   */  public boolean isGaussian() {    return (m_clustertype == SubspaceCluster.GAUSSIAN);  }  /**    * checks, whether cluster sub type is continuous   *    * @return true if cluster sub type is continuous   */  public boolean isContinuous() {    return (m_clustertype == SubspaceCluster.CONTINUOUS);  }  /**    * checks, whether cluster sub type is integer   *    * @return true if cluster sub type is integer   */  public boolean isInteger() {    return (m_clustertype == SubspaceCluster.INTEGER);  }  /**   * Sets the upper and lower boundary for instances for this cluster.   *   * @param fromTo  the string containing the upper and lower boundary for   *                instances per cluster separated by ..   */  protected void setInstNums(String fromTo) {    int i = fromTo.indexOf("..");    if (i == -1)       i = fromTo.length();    String from = fromTo.substring(0, i);    m_MinInstNum = Integer.parseInt(from);    if (i < fromTo.length()) {      String to = fromTo.substring(i + 2, fromTo.length());      m_MaxInstNum = Integer.parseInt(to);    }     else {      m_MaxInstNum = m_MinInstNum;    }  }  /**   * Get a string with the  upper and lower boundary for the    * number of instances for this cluster.   *   * @return the string containing the upper and lower boundary for   * instances per cluster separated by ..   */  protected String getInstNums() {    String text = new String(""+m_MinInstNum+".."+m_MaxInstNum);    return text;  }    /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  protected String instNumsTipText() {    return "The lower and upper boundary for the number of instances in this cluster.";  }  /**   * returns the default min number of instances   *    * @return the default min number of instances   */  protected int defaultMinInstNum() {    return 1;  }  /**   * Gets the lower boundary for instances per cluster.   *   * @return the the lower boundary for instances per cluster   */  public int getMinInstNum() {     return m_MinInstNum;   }    /**   * Sets the lower boundary for instances per cluster.   *   * @param newMinInstNum new lower boundary for instances per cluster   */  public void setMinInstNum(int newMinInstNum) {    m_MinInstNum = newMinInstNum;  }    /**   * Returns the tip text for this property   *    * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String minInstNumTipText() {    return "The lower boundary for instances per cluster.";  }  /**   * returns the default max number of instances   *    * @return the default max number of instances   */  protected int defaultMaxInstNum() {    return 50;  }  /**   * Gets the upper boundary for instances per cluster.   *   * @return the upper boundary for instances per cluster   */  public int getMaxInstNum() {     return m_MaxInstNum;   }    /**   * Sets the upper boundary for instances per cluster.   *   * @param newMaxInstNum new upper boundary for instances per cluster   */  public void setMaxInstNum(int newMaxInstNum) {    m_MaxInstNum = newMaxInstNum;  }    /**   * Returns the tip text for this property   *    * @return tip text for this property suitable for   *         displaying in the explorer/experimenter gui   */  public String maxInstNumTipText() {    return "The upper boundary for instances per cluster.";  }  /**   * Sets the real number of instances for this cluster.   *   * @param r random number generator    */  public void setNumInstances(Random r) {    if (m_MaxInstNum > m_MinInstNum)      m_numInstances = (int)(r.nextDouble()                        * (m_MaxInstNum - m_MinInstNum) + m_MinInstNum);    else      m_numInstances =  m_MinInstNum;  }  /**   * returns the default values list   *    * @return the default values list   */  protected String defaultValuesList() {    return "1,10";  }  /**   * Sets the ranges for each attribute.   *   * @param fromToList the string containing the upper and lower boundary for   * instances per cluster separated by ..   * @throws Exception if values are not correct in number or value   */  public void setValuesList(String fromToList) throws Exception {    m_minValue = new double [m_numClusterAttributes];    m_maxValue = new double [m_numClusterAttributes];    setValuesList(fromToList, m_minValue, m_maxValue, "D");    SubspaceCluster parent = (SubspaceCluster) getParent();    for (int i = 0; i < m_numClusterAttributes; i++) {      if (m_minValue[i] > m_maxValue[i])        throw new Exception("Min must be smaller than max.");      if (getParent() != null) {        // boolean values are only 0.0 and 1.0        if (parent.isBoolean(m_attrIndices[i])) {          parent.getNumValues()[m_attrIndices[i]] = 2;          if (((m_minValue[i] != 0.0) && (m_minValue[i] != 1.0)) ||              ((m_maxValue[i] != 0.0) && (m_maxValue[i] != 1.0)))            throw new Exception("Ranges for boolean must be 0 or 1 only.");        }        if (parent.isNominal(m_attrIndices[i])) {          // nominal values: attributes range might have to be enlarged          double rest = m_minValue[i] - Math.rint(m_minValue[i]);          if (rest != 0.0)             throw new Exception(" Ranges for nominal must be integer");           rest = m_maxValue[i] - Math.rint(m_maxValue[i]);          if (rest != 0.0)             throw new Exception("Ranges for nominal must be integer");           if (m_minValue[i] < 0.0)             throw new Exception("Range for nominal must start with number 0.0 or higher");          if (m_maxValue[i] + 1 > parent.getNumValues()[m_attrIndices[i]]) {            // add new values to attribute            // (actual format is not yet defined)            parent.getNumValues()[m_attrIndices[i]] = (int)m_maxValue[i] + 1;          }        }      }    }  }  /**   * returns the range for each attribute as string   */  public String getValuesList() {    String        result;    int           i;    result = "";    if (m_minValue != null) {      for (i = 0; i < m_minValue.length; i++) {        if (i > 0)          result += ",";        result += "" + m_minValue[i] + "," + m_maxValue[i];      }    }    return result;  }    /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String valuesListTipText() {    return "The range for each each attribute as string.";  }  /**   * returns the default mean/stddev list   */  protected String defaultMeanStddev() {    return "0,1.0";  }  /**   * Sets mean and standarddeviation.   *   * @param meanstddev the string containing the upper and lower boundary for   * instances per cluster separated by ..   * @throws Exception if values are not correct in number or value   */  public void setMeanStddev(String meanstddev) throws Exception {    m_meanValue   = new double [m_numClusterAttributes];    m_stddevValue = new double [m_numClusterAttributes];    setValuesList(meanstddev, m_meanValue, m_stddevValue, "D");  }  /**   * returns the current mean/stddev setup   */  public String getMeanStddev() {    String        result;    int           i;    result = "";    if (m_meanValue != null) {      for (i = 0; i < m_meanValue.length; i++) {        if (i > 0)          result += ",";        result += "" + m_meanValue[i] + "," + m_stddevValue[i];      }    }    return result;  }    /**   * Returns the tip text for this property   * @return tip text for this property suitable for   * displaying in the explorer/experimenter gui   */  public String meanStddevTipText() {    return "The mean and stddev, in case of gaussian.";  }  /**   * Sets the ranges for each attribute.   *   * @param fromToList the string containing the upper and lower boundary for   * instances per cluster separated by ..   * @param first the "from's"   * @param second the "to's"   * @param optionLetter the option, from which the list came   * @throws Exception if values are not correct in number or value   */  public void setValuesList(String fromToList, double[] first, double[] second,       String optionLetter) throws Exception {    StringTokenizer     tok;    int                 index;        tok = new StringTokenizer(fromToList, ",");    if (tok.countTokens() != first.length + second.length)      throw new Exception(          "Wrong number of values for option '-" + optionLetter + "'.");    index = 0;    while (tok.hasMoreTokens()) {      first[index]  = Double.parseDouble(tok.nextToken());      second[index] = Double.parseDouble(tok.nextToken());      index++;    }  }}

⌨️ 快捷键说明

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