📄 birchcluster.java
字号:
"\tThe range of number of instances per cluster (default " + defaultMinInstNum() + ".." + defaultMaxInstNum() + ").\n" + "\tLower number must be between 0 and 2500,\n" + "\tupper number must be between 50 and 2500.", "N", 1, "-N <num>..<num>")); result.addElement(new Option( "\tThe range of radius per cluster (default " + defaultMinRadius() + ".." + defaultMaxRadius() + ").\n" + "\tLower number must be between 0 and SQRT(2), \n" + "\tupper number must be between SQRT(2) and SQRT(32).", "R", 1, "-R <num>..<num>")); result.addElement(new Option( "\tThe distance multiplier (default " + defaultDistMult() + ").", "M", 1, "-M <num>")); result.addElement(new Option( "\tThe number of cycles (default " + defaultNumCycles() + ").", "C", 1, "-C <num>")); result.addElement(new Option( "\tFlag for input order is ORDERED. If flag is not set then \n" + "\tinput order is RANDOMIZED. RANDOMIZED is currently not \n" + "\timplemented, therefore is the input order always ORDERED.", "O", 0, "-O")); result.addElement(new Option( "\tThe noise rate in percent (default " + defaultNoiseRate() + ").\n" + "\tCan be between 0% and 30%. (Remark: The original \n" + "\talgorithm only allows noise up to 10%.)", "P", 1, "-P <num>")); return result.elements(); } /** * Parses a list of options for this object. <p/> * <!-- options-start --> * Valid options are: <p/> * * <pre> -h * Prints this help.</pre> * * <pre> -o <file> * The name of the output file, otherwise the generated data is * printed to stdout.</pre> * * <pre> -r <name> * The name of the relation.</pre> * * <pre> -d * Whether to print debug informations.</pre> * * <pre> -S * The seed for random function (default 1)</pre> * * <pre> -a <num> * The number of attributes (default 10).</pre> * * <pre> -c * Class Flag, if set, the cluster is listed in extra attribute.</pre> * * <pre> -b <range> * The indices for boolean attributes.</pre> * * <pre> -m <range> * The indices for nominal attributes.</pre> * * <pre> -k <num> * The number of clusters (default 4)</pre> * * <pre> -G * Set pattern to grid (default is random). * This flag cannot be used at the same time as flag I. * The pattern is random, if neither flag G nor flag I is set.</pre> * * <pre> -I * Set pattern to sine (default is random). * This flag cannot be used at the same time as flag I. * The pattern is random, if neither flag G nor flag I is set.</pre> * * <pre> -N <num>..<num> * The range of number of instances per cluster (default 1..50). * Lower number must be between 0 and 2500, * upper number must be between 50 and 2500.</pre> * * <pre> -R <num>..<num> * The range of radius per cluster (default 0.1..1.4142135623730951). * Lower number must be between 0 and SQRT(2), * upper number must be between SQRT(2) and SQRT(32).</pre> * * <pre> -M <num> * The distance multiplier (default 4.0).</pre> * * <pre> -C <num> * The number of cycles (default 4).</pre> * * <pre> -O * Flag for input order is ORDERED. If flag is not set then * input order is RANDOMIZED. RANDOMIZED is currently not * implemented, therefore is the input order always ORDERED.</pre> * * <pre> -P <num> * The noise rate in percent (default 0.0). * Can be between 0% and 30%. (Remark: The original * algorithm only allows noise up to 10%.)</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 tmpStr; super.setOptions(options); tmpStr = Utils.getOption('k', options); if (tmpStr.length() != 0) setNumClusters(Integer.parseInt(tmpStr)); else setNumClusters(defaultNumClusters()); tmpStr = Utils.getOption('N', options); if (tmpStr.length() != 0) setInstNums(tmpStr); else setInstNums(defaultMinInstNum() + ".." + defaultMaxInstNum()); tmpStr = Utils.getOption('R', options); if (tmpStr.length() != 0) setRadiuses(tmpStr); else setRadiuses(defaultMinRadius() + ".." + defaultMaxRadius()); 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."); setPattern(new SelectedTag(RANDOM, TAGS_PATTERN)); if (grid) setPattern(new SelectedTag(GRID, TAGS_PATTERN)); if (sine) setPattern(new SelectedTag(SINE, TAGS_PATTERN)); tmpStr= Utils.getOption('M', options); if (tmpStr.length() != 0) { if (!grid) throw new Exception("Option M can only be used with GRID pattern."); setDistMult(Double.parseDouble(tmpStr)); } else { setDistMult(defaultDistMult()); } tmpStr = Utils.getOption('C', options); if (tmpStr.length() != 0) { if (!sine) throw new Exception("Option C can only be used with SINE pattern."); setNumCycles(Integer.parseInt(tmpStr)); } else { setNumCycles(defaultNumCycles()); } if (Utils.getFlag('O', options)) setInputOrder(new SelectedTag(ORDERED, TAGS_INPUTORDER)); else setInputOrder(defaultInputOrder()); tmpStr = Utils.getOption('P', options); if (tmpStr.length() != 0) setNoiseRate(Double.parseDouble(tmpStr)); else setNoiseRate(defaultNoiseRate()); } /** * Gets the current settings of the datagenerator BIRCHCluster. * * @return an array of strings suitable for passing to setOptions */ public String[] getOptions() { Vector result; String[] options; int i; result = new Vector(); options = super.getOptions(); for (i = 0; i < options.length; i++) result.add(options[i]); result.add("-k"); result.add("" + getNumClusters()); result.add("-N"); result.add("" + getInstNums()); result.add("-R"); result.add("" + getRadiuses()); if (m_Pattern == GRID) { result.add("-G"); result.add("-M"); result.add("" + getDistMult()); } if (m_Pattern == SINE) { result.add("-I"); result.add("-C"); result.add("" + getNumCycles()); } if (getOrderedFlag()) result.add("-O"); result.add("-P"); result.add("" + getNoiseRate()); return (String[]) result.toArray(new String[result.size()]); } /** * returns the default number of clusters * * @return the default number of clusters */ protected int defaultNumClusters() { return 4; } /** * Sets the number of clusters the dataset should have. * @param numClusters the new number of clusters */ public void setNumClusters(int numClusters) { m_NumClusters = numClusters; } /** * Gets the number of clusters the dataset should have. * @return the number of clusters the dataset should have */ public int getNumClusters() { return m_NumClusters; } /** * Returns the tip text for this property * * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String numClustersTipText() { return "The number of clusters to generate."; } /** * Sets the upper and lower boundary for instances per 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(".."); String from = fromTo.substring(0, i); setMinInstNum(Integer.parseInt(from)); String to = fromTo.substring(i + 2, fromTo.length()); setMaxInstNum(Integer.parseInt(to)); } /** * Gets the upper and lower boundary for instances per cluster. * * @return the string containing the upper and lower boundary for * instances per cluster separated by .. */ protected String getInstNums() { String fromTo = "" + getMinInstNum() + ".." + getMaxInstNum(); return fromTo; } /** * 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 upper and lowet boundary for instances per 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 upper and lower boundary for the radius of the clusters. * * @param fromTo the string containing the upper and lower boundary for * the radius of the clusters, separated by .. */ protected 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 .. */ protected String getRadiuses() { String fromTo = "" + Utils.doubleToString(getMinRadius(), 2) + ".." + Utils.doubleToString(getMaxRadius(), 2); return fromTo; } /** * Returns the tip text for this property * * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ protected String radiusesTipText() { return "The upper and lower boundary for the radius of the clusters."; } /** * returns the default min radius * * @return the default min radius */ protected double defaultMinRadius() { return 0.1; } /** * 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; } /** * Returns the tip text for this property * * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String minRadiusTipText() { return "The lower boundary for the radius of the clusters."; } /** * returns the default max radius * * @return the default max radius */ protected double defaultMaxRadius() { return Math.sqrt(2.0); } /** * 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; } /** * Returns the tip text for this property * * @return tip text for this property suitable for * displaying in the explorer/experimenter gui */ public String maxRadiusTipText() { return "The upper boundary for the radius of the clusters."; } /** * returns the default pattern * * @return the default pattern */ protected SelectedTag defaultPattern() { return new SelectedTag(RANDOM, TAGS_PATTERN); } /** * Gets the pattern type. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -