Java Code Examples for weka.classifiers.functions.SMO#turnChecksOff()

The following examples show how to use weka.classifiers.functions.SMO#turnChecksOff() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultivariateShapeletTransformClassifier.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
public void configureEnsemble(){
    ensemble.setWeightingScheme(new TrainAcc(4));
    ensemble.setVotingScheme(new MajorityConfidence());
    
    Classifier[] classifiers = new Classifier[3];
    String[] classifierNames = new String[3];
    
    SMO smo = new SMO();
    smo.turnChecksOff();
    smo.setBuildLogisticModels(true);
    PolyKernel kl = new PolyKernel();
    kl.setExponent(2);
    smo.setKernel(kl);
    if (seedClassifier)
        smo.setRandomSeed((int)seed);
    classifiers[0] = smo;
    classifierNames[0] = "SVMQ";

    RandomForest r=new RandomForest();
    r.setNumTrees(500);
    if(seedClassifier)
       r.setSeed((int)seed);            
    classifiers[1] = r;
    classifierNames[1] = "RandF";
        
        
    RotationForest rf=new RotationForest();
    rf.setNumIterations(100);
    if(seedClassifier)
       rf.setSeed((int)seed);
    classifiers[2] = rf;
    classifierNames[2] = "RotF";
    
    
   ensemble.setClassifiers(classifiers, classifierNames, null);        
    
}
 
Example 2
Source File: CAWPE.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Uses the 'basic UCI' set up:
 * Comps: SVML, MLP, NN, Logistic, C4.5
 * Weight: TrainAcc(4) (train accuracies to the power 4)
 * Vote: MajorityConfidence (summing probability distributions)
 */
public final void setupDefaultSettings_NoLogistic() {
    this.ensembleName = "CAWPE-NoLogistic";
    
    this.weightingScheme = new TrainAcc(4);
    this.votingScheme = new MajorityConfidence();
    
    CrossValidationEvaluator cv = new CrossValidationEvaluator(seed, false, false, false, false); 
    cv.setNumFolds(10);
    this.trainEstimator = cv; 
    
    Classifier[] classifiers = new Classifier[4];
    String[] classifierNames = new String[4];

    SMO smo = new SMO();
    smo.turnChecksOff();
    smo.setBuildLogisticModels(true);
    PolyKernel kl = new PolyKernel();
    kl.setExponent(1);
    smo.setKernel(kl);
    smo.setRandomSeed(seed);
    classifiers[0] = smo;
    classifierNames[0] = "SVML";

    kNN k=new kNN(100);
    k.setCrossValidate(true);
    k.normalise(false);
    k.setDistanceFunction(new EuclideanDistance());
    classifiers[1] = k;
    classifierNames[1] = "NN";

    classifiers[2] = new J48();
    classifierNames[2] = "C4.5";

    classifiers[3] = new MultilayerPerceptron();
    classifierNames[3] = "MLP";

    setClassifiers(classifiers, classifierNames, null);
}
 
Example 3
Source File: CAWPE.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
public final void setupAdvancedSettings() {
    this.ensembleName = "CAWPE-A";
    
    this.weightingScheme = new TrainAcc(4);
    this.votingScheme = new MajorityConfidence();
    
    CrossValidationEvaluator cv = new CrossValidationEvaluator(seed, false, false, false, false); 
    cv.setNumFolds(10);
    this.trainEstimator = cv; 

    Classifier[] classifiers = new Classifier[3];
    String[] classifierNames = new String[3];

    SMO smo = new SMO();
    smo.turnChecksOff();
    smo.setBuildLogisticModels(true);
    PolyKernel kl = new PolyKernel();
    kl.setExponent(2);
    smo.setKernel(kl);
    smo.setRandomSeed(seed);
    classifiers[0] = smo;
    classifierNames[0] = "SVMQ";
    RandomForest rf= new RandomForest();
    rf.setNumTrees(500);
    classifiers[1] = rf;
    classifierNames[1] = "RandF";
    RotationForest rotf=new RotationForest();
    rotf.setNumIterations(200);
    classifiers[2] = rotf;
    classifierNames[2] = "RotF";

    setClassifiers(classifiers, classifierNames, null);
}
 
Example 4
Source File: EnsembleProvider.java    From AILibs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Initializes the CAWPE ensemble model consisting of five classifiers (SMO,
 * KNN, J48, Logistic and MLP) using a majority voting strategy. The ensemble
 * uses Weka classifiers. It refers to "Heterogeneous ensemble of standard
 * classification algorithms" (HESCA) as described in Lines, Jason & Taylor,
 * Sarah & Bagnall, Anthony. (2018). Time Series Classification with HIVE-COTE:
 * The Hierarchical Vote Collective of Transformation-Based Ensembles. ACM
 * Transactions on Knowledge Discovery from Data. 12. 1-35. 10.1145/3182382.
 *
 * @param seed
 *            Seed used within the classifiers and the majority confidence
 *            voting scheme
 * @param numFolds
 *            Number of folds used within the determination of the classifier
 *            weights for the {@link MajorityConfidenceVote}
 * @return Returns an initialized (but untrained) ensemble model.
 * @throws Exception
 *             Thrown when the initialization has failed
 */
public static Classifier provideCAWPEEnsembleModel(final int seed, final int numFolds) throws Exception {
	Classifier[] classifiers = new Classifier[5];

	Vote voter = new MajorityConfidenceVote(numFolds, seed);

	SMO smo = new SMO();
	smo.turnChecksOff();
	smo.setBuildCalibrationModels(true);
	PolyKernel kl = new PolyKernel();
	kl.setExponent(1);
	smo.setKernel(kl);
	smo.setRandomSeed(seed);
	classifiers[0] = smo;

	IBk k = new IBk(100);
	k.setCrossValidate(true);
	EuclideanDistance ed = new EuclideanDistance();
	ed.setDontNormalize(true);
	k.getNearestNeighbourSearchAlgorithm().setDistanceFunction(ed);
	classifiers[1] = k;

	J48 c45 = new J48();
	c45.setSeed(seed);
	classifiers[2] = c45;

	classifiers[3] = new Logistic();

	classifiers[4] = new MultilayerPerceptron();

	voter.setClassifiers(classifiers);
	return voter;
}
 
Example 5
Source File: MultivariateShapeletTransformClassifier.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Classifiers used in the HIVE COTE paper
 */    
    public void configureDefaultEnsemble(){
//HIVE_SHAPELET_SVMQ    HIVE_SHAPELET_RandF    HIVE_SHAPELET_RotF    
//HIVE_SHAPELET_NN    HIVE_SHAPELET_NB    HIVE_SHAPELET_C45    HIVE_SHAPELET_SVML   
        ensemble=new CAWPE();
        ensemble.setWeightingScheme(new TrainAcc(4));
        ensemble.setVotingScheme(new MajorityConfidence());
        Classifier[] classifiers = new Classifier[7];
        String[] classifierNames = new String[7];
        
        SMO smo = new SMO();
        smo.turnChecksOff();
        smo.setBuildLogisticModels(true);
        PolyKernel kl = new PolyKernel();
        kl.setExponent(2);
        smo.setKernel(kl);
        if (seedClassifier)
            smo.setRandomSeed((int)seed);
        classifiers[0] = smo;
        classifierNames[0] = "SVMQ";

        RandomForest r=new RandomForest();
        r.setNumTrees(500);
        if(seedClassifier)
           r.setSeed((int)seed);            
        classifiers[1] = r;
        classifierNames[1] = "RandF";
            
            
        RotationForest rf=new RotationForest();
        rf.setNumIterations(100);
        if(seedClassifier)
           rf.setSeed((int)seed);
        classifiers[2] = rf;
        classifierNames[2] = "RotF";
        IBk nn=new IBk();
        classifiers[3] = nn;
        classifierNames[3] = "NN";
        NaiveBayes nb=new NaiveBayes();
        classifiers[4] = nb;
        classifierNames[4] = "NB";
        J48 c45=new J48();
        classifiers[5] = c45;
        classifierNames[5] = "C45";
        SMO svml = new SMO();
        svml.turnChecksOff();
        svml.setBuildLogisticModels(true);
        PolyKernel k2 = new PolyKernel();
        k2.setExponent(1);
        smo.setKernel(k2);
        classifiers[6] = svml;
        classifierNames[6] = "SVML";
        ensemble.setClassifiers(classifiers, classifierNames, null);
    }
 
Example 6
Source File: CAWPE.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Uses the 'basic UCI' set up:
 * Comps: SVML, MLP, NN, Logistic, C4.5
 * Weight: TrainAcc(4) (train accuracies to the power 4)
 * Vote: MajorityConfidence (summing probability distributions)
 */
@Override //Abstract Ensemble 
public final void setupDefaultEnsembleSettings() {
    this.ensembleName = "CAWPE";
    
    this.weightingScheme = new TrainAcc(4);
    this.votingScheme = new MajorityConfidence();
    this.transform = null;
    
    CrossValidationEvaluator cv = new CrossValidationEvaluator(seed, false, false, false, false); 
    cv.setNumFolds(10);
    this.trainEstimator = cv; 

    Classifier[] classifiers = new Classifier[5];
    String[] classifierNames = new String[5];

    SMO smo = new SMO();
    smo.turnChecksOff();
    smo.setBuildLogisticModels(true);
    PolyKernel kl = new PolyKernel();
    kl.setExponent(1);
    smo.setKernel(kl);
    smo.setRandomSeed(seed);
    classifiers[0] = smo;
    classifierNames[0] = "SVML";

    kNN k=new kNN(100);
    k.setCrossValidate(true);
    k.normalise(false);
    k.setDistanceFunction(new EuclideanDistance());
    classifiers[1] = k;
    classifierNames[1] = "NN";

    classifiers[2] = new J48();
    classifierNames[2] = "C4.5";

    classifiers[3] = new Logistic();
    classifierNames[3] = "Logistic";

    classifiers[4] = new MultilayerPerceptron();
    classifierNames[4] = "MLP";
    
    setClassifiers(classifiers, classifierNames, null);
}
 
Example 7
Source File: CAWPE.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/**
     * Comps: NN, SVML, SVMQ, C4.5, NB,  RotF, RandF, BN,
     * Weight: TrainAcc
     * Vote: MajorityVote
     *
     * As used originally in ST_HESCA, COTE.
     * NOTE the original also contained Bayes Net (BN). We have removed it because the classifier crashes
     * unpredictably when discretising features (due to lack of variance in the feature, but not easily detected and
     * dealt with
     *
     */
    public final void setupOriginalHESCASettings() {
        this.ensembleName = "HESCA";
        
        this.weightingScheme = new TrainAcc();
        this.votingScheme = new MajorityVote();
        
        CrossValidationEvaluator cv = new CrossValidationEvaluator(seed, false, false, false, false); 
        cv.setNumFolds(10);
        this.trainEstimator = cv; 
        int numClassifiers=7;
        Classifier[] classifiers = new Classifier[numClassifiers];
        String[] classifierNames = new String[numClassifiers];

        kNN k=new kNN(100);
        k.setCrossValidate(true);
        k.normalise(false);
        k.setDistanceFunction(new EuclideanDistance());
        classifiers[0] = k;
        classifierNames[0] = "NN";

        classifiers[1] = new NaiveBayes();
        classifierNames[1] = "NB";

        classifiers[2] = new J48();
        classifierNames[2] = "C45";

        SMO svml = new SMO();
        svml.turnChecksOff();
        PolyKernel kl = new PolyKernel();
        kl.setExponent(1);
        svml.setKernel(kl);
        svml.setRandomSeed(seed);
        classifiers[3] = svml;
        classifierNames[3] = "SVML";

        SMO svmq =new SMO();
//Assumes no missing, all real valued and a discrete class variable
        svmq.turnChecksOff();
        PolyKernel kq = new PolyKernel();
        kq.setExponent(2);
        svmq.setKernel(kq);
        svmq.setRandomSeed(seed);
        classifiers[4] =svmq;
        classifierNames[4] = "SVMQ";

        RandomForest r=new RandomForest();
        r.setNumTrees(500);
        r.setSeed(seed);
        classifiers[5] = r;
        classifierNames[5] = "RandF";

        RotationForest rf=new RotationForest();
        rf.setNumIterations(50);
        rf.setSeed(seed);
        classifiers[6] = rf;
        classifierNames[6] = "RotF";

//        classifiers[7] = new BayesNet();
//        classifierNames[7] = "bayesNet";

        setClassifiers(classifiers, classifierNames, null);
    }
 
Example 8
Source File: EnsembleProvider.java    From AILibs with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Initializes the HIVE COTE ensemble consisting of 7 classifiers using a
 * majority voting strategy as described in J. Lines, S. Taylor and A. Bagnall,
 * "HIVE-COTE: The Hierarchical Vote Collective of Transformation-Based
 * Ensembles for Time Series Classification," 2016 IEEE 16th International
 * Conference on Data Mining (ICDM), Barcelona, 2016, pp. 1041-1046. doi:
 * 10.1109/ICDM.2016.0133.
 *
 * @param seed
 *            Seed used within the classifiers and the majority confidence
 *            voting scheme
 * @param numFolds
 *            Number of folds used within the determination of the classifier
 *            weights for the {@link MajorityConfidenceVote}
 * @return Returns the initialized (but untrained) HIVE COTE ensemble model.
 */
public static Classifier provideHIVECOTEEnsembleModel(final long seed) {
	Classifier[] classifier = new Classifier[7];

	Vote voter = new MajorityConfidenceVote(5, seed);

	// SMO poly2
	SMO smop = new SMO();
	smop.turnChecksOff();
	smop.setBuildCalibrationModels(true);
	PolyKernel kernel = new PolyKernel();
	kernel.setExponent(2);
	smop.setKernel(kernel);
	smop.setRandomSeed((int)seed);
	classifier[0] = smop;

	// Random Forest
	RandomForest rf = new RandomForest();
	rf.setSeed((int)seed);
	rf.setNumIterations(500);
	classifier[1] = rf;

	// Rotation forest
	RotationForest rotF = new RotationForest();
	rotF.setSeed((int)seed);
	rotF.setNumIterations(100);
	classifier[2] = rotF;

	// NN
	IBk nn = new IBk();
	classifier[3] = nn;

	// Naive Bayes
	NaiveBayes nb = new NaiveBayes();
	classifier[4] = nb;

	// C45
	J48 c45 = new J48();
	c45.setSeed((int)seed);
	classifier[5] = c45;

	// SMO linear
	SMO smol = new SMO();
	smol.turnChecksOff();
	smol.setBuildCalibrationModels(true);
	PolyKernel linearKernel = new PolyKernel();
	linearKernel.setExponent(1);
	smol.setKernel(linearKernel);
	classifier[6] = smol;

	voter.setClassifiers(classifier);
	return voter;
}