List of usage examples for weka.classifiers.meta AdditiveRegression AdditiveRegression
public AdditiveRegression()
From source file:jjj.asap.sas.models1.job.BuildRegressionModels.java
License:Open Source License
@Override protected void run() throws Exception { // validate args if (!Bucket.isBucket("datasets", inputBucket)) { throw new FileNotFoundException(inputBucket); }//from www. ja v a 2s.co m if (!Bucket.isBucket("models", outputBucket)) { throw new FileNotFoundException(outputBucket); } // create prototype classifiers List<Classifier> models = new ArrayList<Classifier>(); LinearRegression m5 = new LinearRegression(); m5.setAttributeSelectionMethod(M5); LinearRegression lr = new LinearRegression(); lr.setAttributeSelectionMethod(NONE); RandomSubSpace rss = new RandomSubSpace(); rss.setClassifier(lr); rss.setNumIterations(30); AdditiveRegression boostedStumps = new AdditiveRegression(); boostedStumps.setClassifier(new DecisionStump()); boostedStumps.setNumIterations(1000); AdditiveRegression boostedTrees = new AdditiveRegression(); boostedTrees.setClassifier(new REPTree()); boostedTrees.setNumIterations(100); models.add(m5); models.add(boostedStumps); models.add(boostedTrees); models.add(rss); // init multi-threading Job.startService(); final Queue<Future<Object>> queue = new LinkedList<Future<Object>>(); // get the input from the bucket List<String> names = Bucket.getBucketItems("datasets", this.inputBucket); for (String dsn : names) { for (Classifier model : models) { String tag = null; if (model instanceof SingleClassifierEnhancer) { tag = model.getClass().getSimpleName() + "-" + ((SingleClassifierEnhancer) model).getClassifier().getClass().getSimpleName(); } else { tag = model.getClass().getSimpleName(); } queue.add(Job.submit(new RegressionModelBuilder(dsn, tag, AbstractClassifier.makeCopy(model), this.outputBucket))); } } // wait on complete Progress progress = new Progress(queue.size(), this.getClass().getSimpleName()); while (!queue.isEmpty()) { try { queue.remove().get(); } catch (Exception e) { Job.log("ERROR", e.toString()); } progress.tick(); } progress.done(); Job.stopService(); }
From source file:jjj.asap.sas.models1.job.RGramModels.java
License:Open Source License
@Override protected void run() throws Exception { // validate args if (!Bucket.isBucket("datasets", inputBucket)) { throw new FileNotFoundException(inputBucket); }/*from www . ja v a 2 s . c o m*/ if (!Bucket.isBucket("models", outputBucket)) { throw new FileNotFoundException(outputBucket); } // create prototype classifiers List<Classifier> models = new ArrayList<Classifier>(); //SGD sgd = new SGD(); //sgd.setDontNormalize(true); //sgd.setLossFunction(new SelectedTag(SGD.SQUAREDLOSS,SGD.TAGS_SELECTION)); LinearRegression m5 = new LinearRegression(); m5.setAttributeSelectionMethod(M5); //models.add(sgd); models.add(m5); LinearRegression lr = new LinearRegression(); lr.setAttributeSelectionMethod(NONE); RandomSubSpace rss = new RandomSubSpace(); rss.setClassifier(lr); rss.setNumIterations(30); models.add(rss); AdditiveRegression boostedStumps = new AdditiveRegression(); boostedStumps.setClassifier(new DecisionStump()); boostedStumps.setNumIterations(1000); AdditiveRegression boostedTrees = new AdditiveRegression(); boostedTrees.setClassifier(new REPTree()); boostedTrees.setNumIterations(100); models.add(boostedStumps); models.add(boostedTrees); models.add(new PLSClassifier()); // init multi-threading Job.startService(); final Queue<Future<Object>> queue = new LinkedList<Future<Object>>(); // get the input from the bucket List<String> names = Bucket.getBucketItems("datasets", this.inputBucket); for (String dsn : names) { for (Classifier model : models) { String tag = null; if (model instanceof SingleClassifierEnhancer) { tag = model.getClass().getSimpleName() + "-" + ((SingleClassifierEnhancer) model).getClassifier().getClass().getSimpleName(); } else { tag = model.getClass().getSimpleName(); } queue.add(Job.submit(new RegressionModelBuilder(dsn, tag, AbstractClassifier.makeCopy(model), this.outputBucket))); } } // wait on complete Progress progress = new Progress(queue.size(), this.getClass().getSimpleName()); while (!queue.isEmpty()) { try { queue.remove().get(); } catch (Exception e) { Job.log("ERROR", e.toString()); } progress.tick(); } progress.done(); Job.stopService(); }
From source file:meddle.TrainModelByDomainOS.java
License:Open Source License
/** * Given the classifierName, return a classifier * * @param classifierName//from w ww . jav a2s.c om * e.g. J48, Bagging etc. */ public static Classifier getClassifier(String classifierName) { Classifier classifier = null; if (classifierName.equals("J48")) { J48 j48 = new J48(); j48.setUnpruned(true); classifier = j48; } else if (classifierName.equals("AdaBoostM1")) { AdaBoostM1 adm = new AdaBoostM1(); adm.setNumIterations(10); J48 j48 = new J48(); adm.setClassifier(j48); classifier = adm; } else if (classifierName.equals("Bagging")) { Bagging bagging = new Bagging(); bagging.setNumIterations(10); J48 j48 = new J48(); bagging.setClassifier(j48); classifier = bagging; } else if (classifierName.equals("Stacking")) { Stacking stacking = new Stacking(); stacking.setMetaClassifier(new Logistic()); Classifier cc[] = new Classifier[2]; cc[0] = new J48(); cc[1] = new IBk(); stacking.setClassifiers(cc); classifier = stacking; } else if (classifierName.equals("AdditiveRegression")) { AdditiveRegression ar = new AdditiveRegression(); ar.setClassifier(new J48()); classifier = ar; } else if (classifierName.equals("LogitBoost")) { LogitBoost lb = new LogitBoost(); lb.setClassifier(new J48()); classifier = lb; } return classifier; }