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

📄 birchcluster.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   *
   * @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;
  }

  /**
   * 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;
  }

  /**
   * Sets the upper and lower boundary for the radius of the clusters.
   *
   * @param newToFrom the string containing the upper and lower boundary for
   * the radius  of the clusters, separated by ..
   */
  public void setRadiuses(String fromTo) {
    int i = fromTo.indexOf("..");
    String from = fromTo.substring(0, i);
    setMinRadius(Double.valueOf(from).doubleValue());
    String to = fromTo.substring(i + 2, fromTo.length());
    setMaxRadius(Double.valueOf(to).doubleValue());
  }

  /**
   * Gets the upper and lower boundary for the radius of the clusters.
   *
   * @return the string containing the upper and lower boundary for
   * the radius  of the clusters, separated by ..
   */
  public String getRadiuses() {
    String fromTo = "" + 
      Utils.doubleToString(getMinRadius(), 2) + ".." +
      Utils.doubleToString(getMaxRadius(), 2);
    return fromTo;
  }

  /**
   * Gets the lower boundary for the radiuses of the clusters.
   *
   * @return the lower boundary for the radiuses of the clusters
   */
  public double getMinRadius() { return m_MinRadius; }
  
  /**
   * Sets the lower boundary for the radiuses of the clusters.
   *
   * @param newMinRadius new lower boundary for the radiuses of the clusters
   */
  public void setMinRadius(double newMinRadius) {
    m_MinRadius = newMinRadius;
  }

  /**
   * Gets the upper boundary for the radiuses of the clusters.
   *
   * @return the upper boundary for the radiuses of the clusters
   */
  public double getMaxRadius() { return m_MaxRadius; }
  
  /**
   * Sets the upper boundary for the radiuses of the clusters.
   *
   * @param newMaxRadius new upper boundary for the radiuses of the clusters
   */
  public void setMaxRadius(double newMaxRadius) {
    m_MaxRadius = newMaxRadius;
  }

  /**
   * Gets the grid flag (option G).
   *
   * @return true if grid flag is set
   */
  public boolean getGridFlag() { return m_Pattern == GRID; }
  
  /**
   * Gets the sine flag (option S).
   *
   * @return true if sine flag is set
   */
  public boolean getSineFlag() { return m_Pattern == SINE; }
  
  /**
   * Gets the pattern type.
   *
   * @return the current pattern type
   */
  public int getPattern() { return m_Pattern; }

  /**
   * Sets the pattern type.
   *
   * @param newPattern new pattern type 
   */
  public void setPattern(int newPattern) {
    m_Pattern = newPattern;
  }

  /**
   * Gets the distance multiplier.
   *
   * @return the distance multiplier
   */
  public double getDistMult() { return m_DistMult; }
  
  /**
   * Sets the distance multiplier.
   *
   * @param newDistMult new distance multiplier
   */
  public void setDistMult(double newDistMult) {
    m_DistMult = newDistMult;
  }

  /**
   * Gets the number of cycles.
   *
   * @return the number of cycles
   */
  public int getNumCycles() { return m_NumCycles; }
  
  /**
   * Sets the the number of cycles.
   *
   * @param newNumCycles new number of cycles 
   */
  public void setNumCycles(int newNumCycles) {
    m_NumCycles = newNumCycles;
  }

  /**
   * Gets the input order.
   *
   * @return the current input order
   */
  public int getInputOrder() { return m_InputOrder; }

  /**
   * Sets the input order.
   *
   * @param newInputOrder new input order 
   */
  public void setInputOrder(int newInputOrder) {
    m_InputOrder = newInputOrder;
  }

  /**
   * Gets the ordered flag (option O).
   *
   * @return true if ordered flag is set
   */
  public boolean getOrderedFlag() { return m_InputOrder == ORDERED; }

  /**
   * Gets the percentage of noise set.
   *
   * @return the percentage of noise set
   */
  public double getNoiseRate() { return m_NoiseRate; }
  
  /**
   * Sets the percentage of noise set.
   *
   * @param newNoiseRate new percentage of noise 
   */
  public void setNoiseRate(double newNoiseRate) {
    m_NoiseRate = newNoiseRate;
  }

  /**
   * Gets the random generator.
   *
   * @return the random generator
   */
  public Random getRandom() {
    if (m_Random == null) {
      m_Random = new Random (getSeed());
    }
    return m_Random;
  }
  
  /**
   * Sets the random generator.
   *
   * @param newRandom is the random generator.
   */
  public void setRandom(Random newRandom) {
    m_Random = newRandom;
  }

  /**
   * Gets the random number seed.
   *
   * @return the random number seed.
   */
  public int getSeed() { return m_Seed; }
  
  /**
   * Sets the random number seed.
   *
   * @param newSeed the new random number seed.
   */
  public void setSeed(int newSeed) { m_Seed = newSeed; }  

  /**
   * Gets the dataset format.
   *
   * @return the dataset format.
   */
  public Instances getDatasetFormat() { return m_DatasetFormat; }
  
  /**
   * Sets the dataset format.
   *
   * @param newDatasetFormat the new dataset format.
   */
  public void setDatasetFormat(Instances newDatasetFormat) { 
    m_DatasetFormat = newDatasetFormat;
  }  

  /**
   * Gets the single mode flag.
   *
   * @return true if methode generateExample can be used.
   */
  public boolean getSingleModeFlag() { return (false); }

  /**
   * Returns an enumeration describing the available options.
   *
   * @return an enumeration of all the available options
   */
  public Enumeration listOptions() {

    Vector newVector = new Vector(5);
    
    newVector.addElement(new Option(
              "\tSet pattern to grid (default is random).",
              "G", 1, "-G"));

    newVector.addElement(new Option(
              "\tSet pattern to sine (default is random).",
              "S", 1, "-S"));

    newVector.addElement(new Option(
              "\tThe range of number of instances per cluster (default 1..50).",
              "N", 1, "-N <num>..<num>"));

    newVector.addElement(new Option(
              "\tThe range of radius per cluster (default 0.1..sqrt(2)).",
              "R", 1, "-R <num>..<num>"));
    
    newVector.addElement(new Option(
              "\tThe distance multiplier (default 4).",
              "M", 1, "-M <num>"));

    newVector.addElement(new Option(
              "\tThe number of cycles (default 4).",
              "C", 1, "-C <num>"));

    newVector.addElement(new Option(
              "\tSet input order to ordered (default is randomized).",
              "O", 1, "-O"));

    newVector.addElement(new Option(
              "\tThe noise rate in percent (default 0).",
              "P", 1, "-P <num>"));

    newVector.addElement(new Option(
              "\tThe Seed for random function (default 1).",
              "S", 1, "-S"));
 
    return newVector.elements();
  }

  /**
   * Sets all options to their default values. <p>
   */
  public void setDefaultOptions() {

    m_MinInstNum = 1;
    m_MaxInstNum = 50;
    m_MinRadius = 0.1;
    m_MaxRadius = Math.sqrt(2.0);
    m_Pattern = RANDOM;
    m_DistMult = 4;
    m_NumCycles = 4;
    m_InputOrder = RANDOMIZED;
    m_NoiseRate = 0.0;
    m_Seed = 1;
  }
  
  /**
   * Parses a list of options for this object. <p>
   *
   * For list of valid options see class description.<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 {

    setDefaultOptions();
    String num;
    String fromTo;


    fromTo = Utils.getOption('N', options);
    if (fromTo.length() != 0) {
      setInstNums(fromTo);
    }
    
    fromTo = Utils.getOption('R', options);
    if (fromTo.length() != 0) {
      setRadiuses(fromTo);
    } 

    boolean grid = Utils.getFlag('G', options);
    boolean sine = Utils.getFlag('I', options);

    if (grid && sine)
      throw new Exception("Flags G and I can only be set mutually exclusiv.");

    if (grid)
      setPattern(GRID);
    if (sine)
      setPattern(SINE);

    num = Utils.getOption('M', options);
    if (num.length() != 0) {
      if (!grid)
	throw new Exception("Option M can only be used with GRID pattern.");
      setDistMult(Double.valueOf(num).doubleValue());
    } 

    num = Utils.getOption('C', options);
    if (num.length() != 0) {
      if (!sine)
	throw new Exception("Option C can only be used with SINE pattern.");
      setNumCycles((int)Double.valueOf(num).doubleValue());
    } 

    boolean ordered = Utils.getFlag('O', options);
    if (ordered)

⌨️ 快捷键说明

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