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

The following examples show how to use weka.classifiers.functions.SMO#setBuildLogisticModels() . 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: 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 5
Source File: TunedSVM.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public void buildClassifier(Instances train) throws Exception {
        res =new ClassifierResults();
        long t=System.currentTimeMillis();
//        if(kernelOptimise)
//            selectKernel(train);
        if(buildFromPartial){
            if(paraSpace1==null)
                setStandardParaSearchSpace();  
            if(kernel==KernelType.RBF)
                setRBFParasFromPartiallyCompleteSearch();            
//            else if(kernel==KernelType.LINEAR || kernel==KernelType.QUADRATIC)
//                setFixedPolynomialParasFromPartiallyCompleteSearch();            
                else if(kernel==KernelType.POLYNOMIAL)
                    setPolynomialParasFromPartiallyCompleteSearch();            
        }
        else if(tuneParameters){
            if(paraSpace1==null)
                setStandardParaSearchSpace();
            if(buildFromFile){
                throw new Exception("Build from file in TunedSVM Not implemented yet");
            }else{
                if(kernel==KernelType.RBF)
                    tuneRBF(train); //Tunes two parameters
                else if(kernel==KernelType.LINEAR || kernel==KernelType.QUADRATIC)
                    tuneCForFixedPolynomial(train);//Tunes one parameter
                else if(kernel==KernelType.POLYNOMIAL)
                    tunePolynomial(train);
            }
        }
/*If there is no parameter search, then there is no train CV available.        
this gives the option of finding one using 10xCV  
*/        
        else if(findTrainAcc){
            int folds=10;
            if(folds>train.numInstances())
                folds=train.numInstances();
            SMO model = new SMO();
            model.setKernel(this.m_kernel);
            model.setC(this.getC());
            model.setBuildLogisticModels(true);
            model.setRandomSeed(seed);
            CrossValidationEvaluator cv = new CrossValidationEvaluator();
            cv.setSeed(seed); //trying to mimick old seeding behaviour below
            cv.setNumFolds(folds);
            cv.buildFolds(train);
            res = cv.crossValidateWithStats(model, train);
      }        
        
        
        
//If both kernelOptimise and tuneParameters are false, it just builds and SVM        
//With whatever the parameters are set to        
        super.buildClassifier(train);
        
        if(saveEachParaAcc)
            res.setBuildTime(combinedBuildTime);
        else
            res.setBuildTime(System.currentTimeMillis()-t);
        if(trainPath!=null && trainPath!=""){  //Save basic train results
            res.setClassifierName("TunedSVM"+kernel);
            res.setDatasetName(train.relationName());
            res.setFoldID(seed);
            res.setSplit("train");
            
            res.setParas(getParameters());
            res.writeFullResultsToFile(trainPath);
            File x=new File(trainPath);
            x.setWritable(true, false);
            
        }        
    }
 
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);
}