Example usage for weka.classifiers Classifier getCapabilities

List of usage examples for weka.classifiers Classifier getCapabilities

Introduction

In this page you can find the example usage for weka.classifiers Classifier getCapabilities.

Prototype

public Capabilities getCapabilities();

Source Link

Document

Returns the Capabilities of this classifier.

Usage

From source file:WekaRegressor.java

License:Open Source License

public WekaRegressor(Classifier wekaClassifier) {
    if (!wekaClassifier.getCapabilities().handles(Capability.NUMERIC_CLASS))
        throw new IllegalArgumentException("The given Weka classifier ("
                + wekaClassifier.getClass().getSimpleName() + ") dosn't support regression tasks");
    this.wekaClassifier = wekaClassifier;
}

From source file:com.rapidminer.tools.WekaLearnerCapabilities.java

License:Open Source License

public static boolean supportsCapability(Classifier classifier, LearnerCapability lc) {
    Capabilities capabilities = classifier.getCapabilities();

    if (lc == LearnerCapability.POLYNOMINAL_ATTRIBUTES) {
        return capabilities.handles(Capabilities.Capability.NOMINAL_ATTRIBUTES);
    } else if (lc == LearnerCapability.BINOMINAL_ATTRIBUTES) {
        return capabilities.handles(Capabilities.Capability.BINARY_ATTRIBUTES);
    } else if (lc == LearnerCapability.NUMERICAL_ATTRIBUTES) {
        return capabilities.handles(Capabilities.Capability.NUMERIC_ATTRIBUTES);
    } else if (lc == LearnerCapability.POLYNOMINAL_CLASS) {
        return capabilities.handles(Capabilities.Capability.NOMINAL_CLASS);
    } else if (lc == LearnerCapability.BINOMINAL_CLASS) {
        return capabilities.handles(Capabilities.Capability.BINARY_CLASS);
    } else if (lc == LearnerCapability.NUMERICAL_CLASS) {
        return capabilities.handles(Capabilities.Capability.NUMERIC_CLASS);
    } else if (lc == LearnerCapability.UPDATABLE) {
        return (classifier instanceof UpdateableClassifier);
    } else if (lc == LearnerCapability.WEIGHTED_EXAMPLES) {
        return (classifier instanceof WeightedInstancesHandler);
    }//from   www  . j a v a  2 s .  c o m
    return false;
}

From source file:com.relationalcloud.partitioning.explanation.ExplanationHandler.java

License:Open Source License

/**
 * Train the given classifier/*from w  w  w .java2  s. c om*/
 * 
 * @param newData
 * @param classifier
 * @throws Exception
 */
public static void trainClassifier(Instances newData, Classifier classifier) throws Exception {
    // if the class attributed is not unary we proceed regularly

    // verify the Classifier can handle this dataset
    classifier.getCapabilities().testWithFail(newData);

    System.out.println("BUILDING CLASSIFIER ON INSTANCE:" + newData.toSummaryString());

    long treeTstart = System.currentTimeMillis();
    classifier.buildClassifier(newData); // build classifier
    long treeTend = System.currentTimeMillis();
    System.out.println("CLASSIFIER BUILDING TIME: " + (treeTend - treeTstart) + "ms FROM: "
            + newData.numInstances() + " instances \n" + classifier.toString());

}

From source file:org.knime.knip.suise.node.boundarymodel.contourdata.WekaMIContourDataClassifier.java

License:Open Source License

/**
 * @param classifier a multi-instance classifier
 *//* w ww . ja  v a  2 s. c  o  m*/
public WekaMIContourDataClassifier(Classifier classifier) {
    if (!classifier.getCapabilities().handles(Capability.ONLY_MULTIINSTANCE)) {
        throw new IllegalArgumentException("Classifier can not handle multi-instances");
    }
    m_classifier = classifier;

}