/** * Parses a given list of options. Valid options are: * * <p>-D <br> * Turn on debugging output. * * <p>-S seed <br> * Random number seed (default 1). * * <p>-B classifierstring <br> * Classifierstring should contain the full class name of a scheme included for selection followed * by options to the classifier (required, option should be used once for each classifier). * * <p>-X num_folds <br> * Use cross validation error as the basis for classifier selection. (default 0, is to use error * on the training data instead) * * <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 { setDebug(Utils.getFlag('D', options)); String numFoldsString = Utils.getOption('X', options); if (numFoldsString.length() != 0) { setNumFolds(Integer.parseInt(numFoldsString)); } else { setNumFolds(0); } String randomString = Utils.getOption('S', options); if (randomString.length() != 0) { setSeed(Integer.parseInt(randomString)); } else { setSeed(1); } // Iterate through the schemes FastVector classifiers = new FastVector(); while (true) { String classifierString = Utils.getOption('B', options); if (classifierString.length() == 0) { break; } String[] classifierSpec = Utils.splitOptions(classifierString); if (classifierSpec.length == 0) { throw new Exception("Invalid classifier specification string"); } String classifierName = classifierSpec[0]; classifierSpec[0] = ""; classifiers.addElement(Classifier.forName(classifierName, classifierSpec)); } if (classifiers.size() <= 1) { throw new Exception("At least two classifiers must be specified" + " with the -B option."); } else { Classifier[] classifiersArray = new Classifier[classifiers.size()]; for (int i = 0; i < classifiersArray.length; i++) { classifiersArray[i] = (Classifier) classifiers.elementAt(i); } setClassifiers(classifiersArray); } }
/** * Tests if there are any more elements to enumerate. * * @return true if there are some elements left */ public final boolean hasMoreElements() { return m_Counter < m_Vector.size(); }
/** * Appends all elements of the supplied vector to this vector. * * @param toAppend the FastVector containing elements to append. */ public final void appendElements(FastVector toAppend) { setCapacity(size() + toAppend.size()); System.arraycopy(toAppend.m_Objects, 0, m_Objects, size(), toAppend.size()); m_Size = m_Objects.length; }