List of usage examples for weka.classifiers.functions VotedPerceptron VotedPerceptron
VotedPerceptron
From source file:machinelearningcw.MachineLearningCw.java
public static void main(String[] args) throws Exception { Instances data[] = getAllFiles();/*from ww w. j a va 2 s . co m*/ //writes the data to excel writer = new FileWriter( "\\\\ueahome4\\stusci5\\ypf12pxu\\data\\Documents\\Machine Learning\\adamt94-machinelearning-da75565f2abe\\adamt94-machinelearning-da75565f2abe\\data.csv"); writer.append("DataName"); writer.append(",");//next column writer.append("Offline"); writer.append(","); writer.append("Online"); writer.append(","); writer.append("Offlinestd"); writer.append(","); writer.append("Onlinestd"); writer.append(","); writer.append("CrossValidation"); writer.append(","); writer.append("Ensemble"); writer.append(","); writer.append("WEKA1"); writer.append(","); writer.append("WEKA2"); writer.append("\n");//new row for (int i = 0; i < data.length; i++) { System.out.println("===============" + fileNames.get(i) + "============="); writer.append(fileNames.get(i)); writer.append(","); data[i].setClassIndex(data[i].numAttributes() - 1); //1. Is one learning algorithm better than the other? // compareAlgorithms(data[i]); /*2. Does standardising the data produce a more accurate classifier? You can test this on both learningalgorithms.*/ // standardiseData(data[i]); /*3. Does choosing the learning algorithm through cross validation produce a more accurate classifier?*/ // crossValidation(data[i]); // 4. Does using an ensemble produce a more accurate classifier? // ensemble(data[i]); /*5. Weka contains several related classifiers in the package weka.classifiers.functions. Comparetwo of your classifiers (including the ensemble) to at least two of the following*/ /*======================================= Weka Classifiers =========================================*/ // VotedPerceptron mp = new VotedPerceptron(); // Logistic l = new Logistic(); // SimpleLogistic sl = new SimpleLogistic(); // MultilayerPerceptron mp = new MultilayerPerceptron(); // VotedPerceptron vp = new VotedPerceptron(); // // int numFolds = 10; // EvaluationUtils eval = new EvaluationUtils(); // ArrayList<Prediction> preds // = eval.getCVPredictions(mp, data[i], numFolds); // int correct = 0; // int total = 0; // for (Prediction pred : preds) { // if (pred.predicted() == pred.actual()) { // correct++; // } // total++; // } // double acc = ((double) correct / total); // // System.out.println("Logistic Accuracy: " + acc); // writer.append(acc + ","); int j = data[i].numClasses(); writer.append(j + ","); writer.append("\n"); } /*======================================================= TIMING EXPIREMENT ========================================================= */ //create all the classifiers perceptronClassifier online = new perceptronClassifier(); EnhancedLinearPerceptron offline = new EnhancedLinearPerceptron(); EnhancedLinearPerceptron onlinestd = new EnhancedLinearPerceptron(); onlinestd.setStandardiseAttributes = true; EnhancedLinearPerceptron offlinestd = new EnhancedLinearPerceptron(); offlinestd.setStandardiseAttributes = true; EnhancedLinearPerceptron crossvalidate = new EnhancedLinearPerceptron(); crossvalidate.setStandardiseAttributes = true; RandomLinearPerceptron random = new RandomLinearPerceptron(); Logistic l = new Logistic(); SimpleLogistic sl = new SimpleLogistic(); MultilayerPerceptron mp = new MultilayerPerceptron(); VotedPerceptron vp = new VotedPerceptron(); // timingExperiment(online, data); // timingExperiment(offline, data); //timingExperiment(onlinestd, data); //timingExperiment(offlinestd, data); //timingExperiment(crossvalidate, data); timingExperiment(random, data); //timingExperiment(l, data); //timingExperiment(sl, data); // timingExperiment(mp, data); // timingExperiment(vp, data); writer.flush(); writer.close(); }
From source file:machinelearningcw.MachineLearningCw.java
public static void wekaClassifiers() { Logistic l = new Logistic(); SimpleLogistic sl = new SimpleLogistic(); MultilayerPerceptron mp = new MultilayerPerceptron(); VotedPerceptron vp = new VotedPerceptron(); }