public static void main(String[] args) { // load example data set ListDataSet dataSet = DataSet.Factory.IRIS(); // create a classifier NaiveBayesClassifier classifier = new NaiveBayesClassifier(); // train the classifier using all data classifier.trainAll(dataSet); // use the classifier to make predictions classifier.predictAll(dataSet); // get the results double accurary = dataSet.getAccuracy(); System.out.println("accuracy: " + accurary); } }
public static void main(String[] args) { // load example data set ListDataSet dataSet = DataSet.Factory.IRIS(); // create a classifier LinearRegression classifier = new LinearRegression(); // train the classifier using all data classifier.trainAll(dataSet); // use the classifier to make predictions classifier.predictAll(dataSet); // get the results double accurary = dataSet.getAccuracy(); System.out.println("accuracy: " + accurary); }
@Test public void testIrisClassification() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new ConstantClassifier(); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.21, results.getMeanValue(), 0.04); }
@Test public void testMalletAdaBoost() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new MalletClassifier(MalletClassifiers.AdaBoost); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.93, results.getMeanValue(), 0.02); }
@Test public void testMalletNaiveBayes() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new MalletClassifier(MalletClassifiers.NaiveBayes); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.9273, results.getMeanValue(), 0.01); }
@Test public void testIrisClassification() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new NaiveBayesClassifier(); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.959, results.getMeanValue(), 0.04); }
@Test public void testIrisClassification() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new LibSVMClassifier(Kernel.RBF); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.95, results.getMeanValue(), 0.04); }
@Test public void testIrisClassification2() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Regressor c = new LinearRegression(3); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.80, results.getMeanValue(), 0.01); }
@Test public void testIrisClassification() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); KNNClassifier c = new KNNClassifier(5); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.96, results.getMeanValue(), 0.01); }
@Test public void testIrisClassification() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new RandomClassifier(); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.33, results.getMeanValue(), 0.04); }
@Test public void testIrisClassification() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new LibLinearClassifier(); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.95, results.getMeanValue(), 0.04); }
@Test public void testMalletDecisionTree() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new MalletClassifier(MalletClassifiers.DecisionTree); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.934, results.getMeanValue(), 0.01); }
@Test public void testIrisClassification1() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Regressor c = new LinearRegression(); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.82, results.getMeanValue(), 0.01); }
@Test public void testIrisClassification() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); Classifier c = new WekaClassifier(WekaClassifierType.AdaBoostM1, false); ListMatrix<Double> results = CrossValidation.run(c, iris, 10, 10, 0); assertEquals(0.954, results.getMeanValue(), 0.01); }
@Test public void testIrisClassification2() throws Exception { ListDataSet ds = ListDataSet.Factory.IRIS(); LinearRegression lr = new LinearRegression(); Bagging b = new Bagging(lr, 100); b.trainAll(ds); b.predictAll(ds); assertEquals(0.86, ds.getAccuracy(), 0.02); }
@Test public void testExampleSearch() throws Exception { ListDataSet ds = ListDataSet.Factory.IRIS(); LuceneIndex index = new LuceneIndex(); index.add(ds); ListDataSet result = index.search("setosa"); assertEquals(50, result.size()); index.close(); }
@Test public void testIrisClassification1() throws Exception { ListDataSet ds = ListDataSet.Factory.IRIS(); LinearRegression lr = new LinearRegression(); FeatureSelector r = new FeatureSelector(SelectionType.Random, lr, 3); Bagging b = new Bagging(r, 100); b.trainAll(ds); b.predictAll(ds); assertEquals(0.86, ds.getAccuracy(), 0.02); }
@Test public void testMLP() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); iris.getInputMatrix().standardize(Ret.ORIG, Matrix.ROW); MultiLayerNetwork mlp = new MultiLayerNetwork(10); mlp.setLearningRate(0.05); for (int i = 0; i < 300; i++) { mlp.trainOnce(iris); } mlp.predictAll(iris); assertEquals(0.90, iris.getAccuracy(), 0.2); } }
@Test public void testClusteringKMeans() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); WekaClusterer wc = new WekaClusterer(WekaClustererType.SimpleKMeans, false); wc.setNumberOfClusters(3); wc.train(iris); wc.predict(iris); Matrix result = iris.getPredictedMatrix().sum(Ret.NEW, Matrix.ROW, true); // the three classes should have approximately 50 samples each assertEquals(50, result.getAsDouble(0, 0), 15); assertEquals(50, result.getAsDouble(0, 1), 15); assertEquals(50, result.getAsDouble(0, 2), 15); }
@Test public void testClusteringEM() throws Exception { ListDataSet iris = ListDataSet.Factory.IRIS(); WekaClusterer wc = new WekaClusterer(WekaClustererType.EM, false); wc.setNumberOfClusters(3); wc.train(iris); wc.predict(iris); Matrix result = iris.getPredictedMatrix().sum(Ret.NEW, Matrix.ROW, true); // the three classes should have approximately 50 samples each assertEquals(50, result.getAsDouble(0, 0), 15); assertEquals(50, result.getAsDouble(0, 1), 15); assertEquals(50, result.getAsDouble(0, 2), 15); }