📄 testinstances.java
字号:
* * <pre> -words <comma-separated-list> * The words to use in string attributes.</pre> * * <pre> -word-separators <chars> * The word separators to use in string attributes.</pre> * * <pre> -date <num> * The number of date attributes (default 0).</pre> * * <pre> -relational <num> * The number of relational attributes (default 0).</pre> * * <pre> -relational-nominal <num> * The number of nominal attributes in a rel. attribute (default 1).</pre> * * <pre> -relational-nominal-values <num> * The number of values for nominal attributes in a rel. attribute (default 2).</pre> * * <pre> -relational-numeric <num> * The number of numeric attributes in a rel. attribute (default 0).</pre> * * <pre> -relational-string <num> * The number of string attributes in a rel. attribute (default 0).</pre> * * <pre> -relational-date <num> * The number of date attributes in a rel. attribute (default 0).</pre> * * <pre> -num-instances-relational <num> * The number of instances in relational/bag attributes (default 10).</pre> * * <pre> -multi-instance * Generates multi-instance data.</pre> * * <pre> -W <classname> * The Capabilities handler to base the dataset on. * The other parameters can be used to override the ones * determined from the handler. Additional parameters for * handler can be passed on after the '--'.</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; Class cls; CapabilitiesHandler handler; boolean initialized; initialized = false; tmpStr = Utils.getOption('W', options); if (tmpStr.length() > 0) { cls = Class.forName(tmpStr); if (ClassDiscovery.hasInterface(CapabilitiesHandler.class, cls)) { initialized = true; handler = (CapabilitiesHandler) cls.newInstance(); if (handler instanceof OptionHandler) ((OptionHandler) handler).setOptions(Utils.partitionOptions(options)); setHandler(handler); // initialize this.assign(forCapabilities(handler.getCapabilities())); } else { throw new IllegalArgumentException("Class '" + tmpStr + "' is not a CapabilitiesHandler!"); } } tmpStr = Utils.getOption("relation", options); if (tmpStr.length() != 0) setRelation(tmpStr); else if (!initialized) setRelation("Testdata"); tmpStr = Utils.getOption("seed", options); if (tmpStr.length() != 0) setSeed(Integer.parseInt(tmpStr)); else if (!initialized) setSeed(1); tmpStr = Utils.getOption("num-instances", options); if (tmpStr.length() != 0) setNumInstances(Integer.parseInt(tmpStr)); else if (!initialized) setNumInstances(20); setNoClass(Utils.getFlag("no-class", options)); if (!getNoClass()) { tmpStr = Utils.getOption("class-type", options); if (tmpStr.length() != 0) setClassType(Integer.parseInt(tmpStr)); else if (!initialized) setClassType(Attribute.NOMINAL); tmpStr = Utils.getOption("class-values", options); if (tmpStr.length() != 0) setNumClasses(Integer.parseInt(tmpStr)); else if (!initialized) setNumClasses(2); tmpStr = Utils.getOption("class-index", options); if (tmpStr.length() != 0) setClassIndex(Integer.parseInt(tmpStr)); else if (!initialized) setClassIndex(-1); } tmpStr = Utils.getOption("nominal", options); if (tmpStr.length() != 0) setNumNominal(Integer.parseInt(tmpStr)); else if (!initialized) setNumNominal(1); tmpStr = Utils.getOption("nominal-values", options); if (tmpStr.length() != 0) setNumNominalValues(Integer.parseInt(tmpStr)); else if (!initialized) setNumNominalValues(2); tmpStr = Utils.getOption("numeric", options); if (tmpStr.length() != 0) setNumNumeric(Integer.parseInt(tmpStr)); else if (!initialized) setNumNumeric(0); tmpStr = Utils.getOption("string", options); if (tmpStr.length() != 0) setNumString(Integer.parseInt(tmpStr)); else if (!initialized) setNumString(0); tmpStr = Utils.getOption("words", options); if (tmpStr.length() != 0) setWords(tmpStr); else if (!initialized) setWords(arrayToList(DEFAULT_WORDS)); if (Utils.getOptionPos("word-separators", options) > -1) { tmpStr = Utils.getOption("word-separators", options); setWordSeparators(tmpStr); } else if (!initialized) { setWordSeparators(DEFAULT_SEPARATORS); } tmpStr = Utils.getOption("date", options); if (tmpStr.length() != 0) setNumDate(Integer.parseInt(tmpStr)); else if (!initialized) setNumDate(0); tmpStr = Utils.getOption("relational", options); if (tmpStr.length() != 0) setNumRelational(Integer.parseInt(tmpStr)); else if (!initialized) setNumRelational(0); tmpStr = Utils.getOption("relational-nominal", options); if (tmpStr.length() != 0) setNumRelationalNominal(Integer.parseInt(tmpStr)); else if (!initialized) setNumRelationalNominal(1); tmpStr = Utils.getOption("relational-nominal-values", options); if (tmpStr.length() != 0) setNumRelationalNominalValues(Integer.parseInt(tmpStr)); else if (!initialized) setNumRelationalNominalValues(2); tmpStr = Utils.getOption("relational-numeric", options); if (tmpStr.length() != 0) setNumRelationalNumeric(Integer.parseInt(tmpStr)); else if (!initialized) setNumRelationalNumeric(0); tmpStr = Utils.getOption("relational-string", options); if (tmpStr.length() != 0) setNumRelationalString(Integer.parseInt(tmpStr)); else if (!initialized) setNumRelationalString(0); tmpStr = Utils.getOption("num-instances-relational", options); if (tmpStr.length() != 0) setNumInstancesRelational(Integer.parseInt(tmpStr)); else if (!initialized) setNumInstancesRelational(10); if (!initialized) setMultiInstance(Utils.getFlag("multi-instance", options)); } /** * Gets the current settings of this object. * * @return an array of strings suitable for passing to setOptions */ public String[] getOptions() { Vector result; String[] options; int i; result = new Vector(); result.add("-relation"); result.add(getRelation()); result.add("-seed"); result.add("" + getSeed()); result.add("-num-instances"); result.add("" + getNumInstances()); if (getNoClass()) { result.add("-no-class"); } else { result.add("-class-type"); result.add("" + getClassType()); result.add("-class-values"); result.add("" + getNumClasses()); result.add("-class-index"); result.add("" + getClassIndex()); } result.add("-nominal"); result.add("" + getNumNominal()); result.add("-nominal-values"); result.add("" + getNumNominalValues()); result.add("-numeric"); result.add("" + getNumNumeric()); result.add("-string"); result.add("" + getNumString()); result.add("-words"); result.add("" + getWords()); result.add("-word-separators"); result.add("" + getWordSeparators()); result.add("-date"); result.add("" + getNumDate()); result.add("-relational"); result.add("" + getNumRelational()); result.add("-relational-nominal"); result.add("" + getNumRelationalNominal()); result.add("-relational-nominal-values"); result.add("" + getNumRelationalNominalValues()); result.add("-relational-numeric"); result.add("" + getNumRelationalNumeric()); result.add("-relational-string"); result.add("" + getNumRelationalString()); result.add("-relational-date"); result.add("" + getNumRelationalDate()); result.add("-num-instances-relational"); result.add("" + getNumInstancesRelational()); if (getMultiInstance()) result.add("-multi-instance"); if (getHandler() != null) { result.add("-W"); result.add(getHandler().getClass().getName()); if (getHandler() instanceof OptionHandler) { result.add("--"); options = ((OptionHandler) getHandler()).getOptions(); for (i = 0; i < options.length; i++) result.add(options[i]); } } return (String[]) result.toArray(new String[result.size()]); } /** * sets the name of the relation * * @param value the name of the relation */ public void setRelation(String value) { m_Relation = value; } /** * returns the current name of the relation * * @return the name of the relation */ public String getRelation() { return m_Relation; } /** * sets the seed value for the random number generator * * @param value the seed */ public void setSeed(int value) { m_Seed = value; m_Random = new Random(m_Seed); } /** * returns the current seed value * * @return the seed value */ public int getSeed() { return m_Seed; } /** * sets the number of instances to produce * * @param value the number of instances */ public void setNumInstances(int value) { m_NumInstances = value; } /** * returns the current number of instances to produce * * @return the number of instances */ public int getNumInstances() { return m_NumInstances; } /** * sets the class attribute type * * @param value the class attribute type */ public void setClassType(int value) { m_ClassType = value; m_RelationalClassFormat = null; } /** * returns the current class type * * @return the class attribute type */ public int getClassType() { return m_ClassType; } /** * sets the number of classes * * @param value the number of classes */ public void setNumClasses(int value) { m_NumClasses = value; } /** * returns the current number of classes * * @return the number of classes */ public int getNumClasses() { return m_NumClasses; } /** * sets the class index (0-based) * * @param value the class index * @see #CLASS_IS_LAST * @see #NO_CLASS */ public void setClassIndex(int value) { m_ClassIndex = value; } /** * returns the current class index (0-based), -1 is last attribute * * @return the class index * @see #CLASS_IS_LAST * @see #NO_CLASS */ public int getClassIndex() { return m_ClassIndex; } /** * whether to have no class, e.g., for clusterers; otherwise the class * attribute index is set to last * * @param value whether to have no class * @see #CLASS_IS_LAST * @see #NO_CLASS */ public void setNoClass(boolean value) { if (value) setClassIndex(NO_CLASS); else setClassIndex(CLASS_IS_LAST); } /** * whether no class attribute is generated * * @return true if no class attribute is generated */ public boolean getNoClass() { return (getClassIndex() == NO_CLASS); } /** * sets the number of nominal attributes * * @param value the number of nominal attributes */ public void setNumNominal(int value) { m_NumNominal = value; } /** * returns the current number of nominal attributes * * @return the number of nominal attributes */ public int getNumNominal() { return m_NumNominal; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -