/** * prints a LF to stdout, if not silent mode */ protected void println() { print("\n"); }
/** * Checks whether the scheme can build models incrementally. * * @return index 0 is true if the estimator can train incrementally */ protected boolean[] incrementalEstimator() { boolean[] result = new boolean[2]; print("incremental estimator..."); if (m_Estimator instanceof IncrementalEstimator) { println("yes"); result[0] = true; } else { println("no"); result[0] = false; } return result; }
/** * Checks whether the scheme can handle zero training instances. * * @param attrTypes attribute types that can be estimated * @param classType the class type (NUMERIC, NOMINAL, etc.) * @return index 0 is true if the test was passed, index 1 is true if test was * acceptable */ protected boolean[] canHandleZeroTraining(AttrTypes attrTypes, int classType) { print("handle zero training instances"); printAttributeSummary(attrTypes, classType); print("..."); ArrayList<String> accepts = new ArrayList<String>(); accepts.add("train"); accepts.add("value"); int numTrain = 0, numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; int numAtts = 1; int attrIndex = 0; return runBasicTest(attrTypes, numAtts, attrIndex, classType, missingLevel, attributeMissing, classMissing, numTrain, numTest, numClasses, accepts); }
/** * Checks whether the scheme says it can handle instance weights. * * @return true if the estimator handles instance weights */ protected boolean[] weightedInstancesHandler() { boolean[] result = new boolean[2]; print("weighted instances estimator..."); if (m_Estimator instanceof WeightedInstancesHandler) { println("yes"); result[0] = true; } else { println("no"); result[0] = false; } return result; }
/** * prints the given message (+ LF) to stdout, if not silent mode * * @param msg the message to println to stdout */ protected void println(Object msg) { print(msg + "\n"); }
/** * Checks whether the scheme can build models incrementally. * * @return index 0 is true if the estimator can train incrementally */ protected boolean[] incrementalEstimator() { boolean[] result = new boolean[2]; print("incremental estimator..."); if (m_Estimator instanceof IncrementalEstimator) { println("yes"); result[0] = true; } else { println("no"); result[0] = false; } return result; }
/** * prints the given message (+ LF) to stdout, if not silent mode * * @param msg the message to println to stdout */ protected void println(Object msg) { print(msg + "\n"); }
/** * Checks whether the scheme can handle zero training instances. * * @param attrTypes attribute types that can be estimated * @param classType the class type (NUMERIC, NOMINAL, etc.) * @return index 0 is true if the test was passed, index 1 is true if test was * acceptable */ protected boolean[] canHandleZeroTraining(AttrTypes attrTypes, int classType) { print("handle zero training instances"); printAttributeSummary(attrTypes, classType); print("..."); ArrayList<String> accepts = new ArrayList<String>(); accepts.add("train"); accepts.add("value"); int numTrain = 0, numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; int numAtts = 1; int attrIndex = 0; return runBasicTest(attrTypes, numAtts, attrIndex, classType, missingLevel, attributeMissing, classMissing, numTrain, numTest, numClasses, accepts); }
/** * Checks whether the scheme says it can handle instance weights. * * @return true if the estimator handles instance weights */ protected boolean[] weightedInstancesHandler() { boolean[] result = new boolean[2]; print("weighted instances estimator..."); if (m_Estimator instanceof WeightedInstancesHandler) { println("yes"); result[0] = true; } else { println("no"); result[0] = false; } return result; }
/** * prints a LF to stdout, if not silent mode */ protected void println() { print("\n"); }
/** * Checks whether the scheme can handle class attributes as Nth attribute. * * @param attrTypes the attribute types the estimator accepts * @param numAtts of attributes * @param attrIndex the index of the attribute * @param classType the class type (NUMERIC, NOMINAL, etc.) * @param classIndex the index of the class attribute (0-based, -1 means last * attribute) * @return index 0 is true if the test was passed, index 1 is true if test was * acceptable * @see TestInstances#CLASS_IS_LAST */ protected boolean[] canHandleClassAsNthAttribute(AttrTypes attrTypes, int numAtts, int attrIndex, int classType, int classIndex) { if (classIndex == TestInstances.CLASS_IS_LAST) { print("class attribute as last attribute"); } else { print("class attribute as " + (classIndex + 1) + ". attribute"); } printAttributeSummary(attrTypes, classType); print("..."); ArrayList<String> accepts = new ArrayList<String>(); int numTrain = getNumInstances(), numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; return runBasicTest(attrTypes, numAtts, attrIndex, classType, classIndex, missingLevel, attributeMissing, classMissing, numTrain, numTest, numClasses, accepts); }
/** * Checks whether the scheme can take command line options. * * @return index 0 is true if the estimator can take options */ protected boolean[] canTakeOptions() { boolean[] result = new boolean[2]; print("options..."); if (m_Estimator instanceof OptionHandler) { println("yes"); if (m_Debug) { println("\n=== Full report ==="); Enumeration<Option> enu = ((OptionHandler) m_Estimator).listOptions(); while (enu.hasMoreElements()) { Option option = enu.nextElement(); print(option.synopsis() + "\n" + option.description() + "\n"); } println("\n"); } result[0] = true; } else { println("no"); result[0] = false; } return result; }
/** * Checks whether nominal schemes can handle more than two classes. If a * scheme is only designed for two-class problems it should throw an * appropriate exception for multi-class problems. * * @param attrTypes attribute types the estimator excepts * @param numClasses the number of classes to test * @return index 0 is true if the test was passed, index 1 is true if test was * acceptable */ protected boolean[] canHandleNClasses(AttrTypes attrTypes, int numClasses) { print("more than two class problems"); printAttributeSummary(attrTypes, Attribute.NOMINAL); print("..."); ArrayList<String> accepts = new ArrayList<String>(); accepts.add("number"); accepts.add("class"); int numTrain = getNumInstances(), numTest = getNumInstances(), missingLevel = 0; boolean attributeMissing = false, classMissing = false; int numAttr = 1, attrIndex = 0; return runBasicTest(attrTypes, numAttr, attrIndex, Attribute.NOMINAL, missingLevel, attributeMissing, classMissing, numTrain, numTest, numClasses, accepts); }
/** * Checks whether the scheme can take command line options. * * @return index 0 is true if the estimator can take options */ protected boolean[] canTakeOptions() { boolean[] result = new boolean[2]; print("options..."); if (m_Estimator instanceof OptionHandler) { println("yes"); if (m_Debug) { println("\n=== Full report ==="); Enumeration<Option> enu = ((OptionHandler) m_Estimator).listOptions(); while (enu.hasMoreElements()) { Option option = enu.nextElement(); print(option.synopsis() + "\n" + option.description() + "\n"); } println("\n"); } result[0] = true; } else { println("no"); result[0] = false; } return result; }
/** * Checks whether the scheme can handle class attributes as Nth attribute. * * @param attrTypes the attribute types the estimator accepts * @param numAtts of attributes * @param attrIndex the index of the attribute * @param classType the class type (NUMERIC, NOMINAL, etc.) * @param classIndex the index of the class attribute (0-based, -1 means last * attribute) * @return index 0 is true if the test was passed, index 1 is true if test was * acceptable * @see TestInstances#CLASS_IS_LAST */ protected boolean[] canHandleClassAsNthAttribute(AttrTypes attrTypes, int numAtts, int attrIndex, int classType, int classIndex) { if (classIndex == TestInstances.CLASS_IS_LAST) { print("class attribute as last attribute"); } else { print("class attribute as " + (classIndex + 1) + ". attribute"); } printAttributeSummary(attrTypes, classType); print("..."); ArrayList<String> accepts = new ArrayList<String>(); int numTrain = getNumInstances(), numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; return runBasicTest(attrTypes, numAtts, attrIndex, classType, classIndex, missingLevel, attributeMissing, classMissing, numTrain, numTest, numClasses, accepts); }
/** * Checks whether nominal schemes can handle more than two classes. If a * scheme is only designed for two-class problems it should throw an * appropriate exception for multi-class problems. * * @param attrTypes attribute types the estimator excepts * @param numClasses the number of classes to test * @return index 0 is true if the test was passed, index 1 is true if test was * acceptable */ protected boolean[] canHandleNClasses(AttrTypes attrTypes, int numClasses) { print("more than two class problems"); printAttributeSummary(attrTypes, Attribute.NOMINAL); print("..."); ArrayList<String> accepts = new ArrayList<String>(); accepts.add("number"); accepts.add("class"); int numTrain = getNumInstances(), numTest = getNumInstances(), missingLevel = 0; boolean attributeMissing = false, classMissing = false; int numAttr = 1, attrIndex = 0; return runBasicTest(attrTypes, numAttr, attrIndex, Attribute.NOMINAL, missingLevel, attributeMissing, classMissing, numTrain, numTest, numClasses, accepts); }
/** * Checks basic estimation of one attribute of the scheme, for simple * non-troublesome datasets. * * @param attrTypes the types the estimator can work with * @param classType the class type (NOMINAL, NUMERIC, etc.) * @return index 0 is true if the test was passed, index 1 is true if test was * acceptable */ protected boolean[] canEstimate(AttrTypes attrTypes, boolean supervised, int classType) { // supervised is ignored, no supervised estimators used yet print("basic estimation"); printAttributeSummary(attrTypes, classType); print("..."); ArrayList<String> accepts = new ArrayList<String>(); accepts.add("nominal"); accepts.add("numeric"); accepts.add("string"); accepts.add("date"); accepts.add("relational"); accepts.add("not in classpath"); int numTrain = getNumInstances(), numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; int numAtts = 1, attrIndex = 0; return runBasicTest(attrTypes, numAtts, attrIndex, classType, missingLevel, attributeMissing, classMissing, numTrain, numTest, numClasses, accepts); }
/** * Checks basic estimation of one attribute of the scheme, for simple * non-troublesome datasets. * * @param attrTypes the types the estimator can work with * @param classType the class type (NOMINAL, NUMERIC, etc.) * @return index 0 is true if the test was passed, index 1 is true if test was * acceptable */ protected boolean[] canEstimate(AttrTypes attrTypes, boolean supervised, int classType) { // supervised is ignored, no supervised estimators used yet print("basic estimation"); printAttributeSummary(attrTypes, classType); print("..."); ArrayList<String> accepts = new ArrayList<String>(); accepts.add("nominal"); accepts.add("numeric"); accepts.add("string"); accepts.add("date"); accepts.add("relational"); accepts.add("not in classpath"); int numTrain = getNumInstances(), numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; int numAtts = 1, attrIndex = 0; return runBasicTest(attrTypes, numAtts, attrIndex, classType, missingLevel, attributeMissing, classMissing, numTrain, numTest, numClasses, accepts); }