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); }
public ListDataSet searchSimilar(Sample sample, int start, int count) throws Exception { ListDataSet ds = ListDataSet.Factory.emptyDataSet(); try { List<Future<ListDataSet>> futures = new ArrayList<Future<ListDataSet>>(); for (Object key : getAlgorithmMap().keySet()) { Algorithm a = getAlgorithmMap().get(key); if (a instanceof SimilaritySearcher) { futures.add(executors.submit(new SearchSimilarFuture((SimilaritySearcher) a, sample, start, count))); } } for (Future<ListDataSet> f : futures) { ds.addAll(f.get()); } } catch (Exception e) { e.printStackTrace(); } return ds; }
public Map<String, Object> calculateObjects(Map<String, Object> input) { Map<String, Object> result = new HashMap<String, Object>(); int sampleCount = MathUtil.getInt(input.get(SAMPLECOUNT)); sampleCount = sampleCount == 0 ? 100 : sampleCount; int inputLength = MathUtil.getInt(input.get(INPUTLENGTH)); inputLength = inputLength == 0 ? 10 : inputLength; int targetLength = MathUtil.getInt(input.get(TARGETLENGTH)); targetLength = targetLength == 0 ? 5 : targetLength; result.put(TARGET, DataSet.Factory.HenonMap(sampleCount, inputLength, targetLength)); return result; } }
public Object call() { ListDataSet animals = ListDataSet.Factory.ANIMALS(); animals.showGUI(); return animals; }
public Map<String, Object> calculateObjects(Map<String, Object> input) { Map<String, Object> result = new HashMap<String, Object>(); int sampleCount = MathUtil.getInt(input.get(SAMPLECOUNT)); sampleCount = sampleCount == 0 ? 100 : sampleCount; int inputLength = MathUtil.getInt(input.get(INPUTLENGTH)); inputLength = inputLength == 0 ? 10 : inputLength; int targetLength = MathUtil.getInt(input.get(TARGETLENGTH)); targetLength = targetLength == 0 ? 5 : targetLength; result.put(TARGET, DataSet.Factory.LogisticMap(sampleCount, inputLength, targetLength)); return result; } }
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 ListDataSet search(String query, int start, int count) throws Exception { ListDataSet ds = ListDataSet.Factory.emptyDataSet(); try { List<Future<ListDataSet>> futures = new ArrayList<Future<ListDataSet>>(); for (Object key : getAlgorithmMap().keySet()) { Algorithm a = getAlgorithmMap().get(key); if (a instanceof Index) { futures.add(executors.submit(new SearchFuture((Index) a, query, start, count))); } } for (Future<ListDataSet> f : futures) { ds.addAll(f.get()); } } catch (Exception e) { e.printStackTrace(); } return ds; }
public Object call() { int sampleCount = -1; while (sampleCount <= 0) { String s = JOptionPane.showInputDialog(getComponent(), "How many samples should the data set contain", "Henon Map DataSet", JOptionPane.QUESTION_MESSAGE); sampleCount = Integer.parseInt(s); } int inputLength = -1; while (inputLength <= 0) { String s = JOptionPane.showInputDialog(getComponent(), "How many values are used as input", "Henon Map DataSet", JOptionPane.QUESTION_MESSAGE); inputLength = Integer.parseInt(s); } int predictionLength = -1; while (predictionLength <= 0) { String s = JOptionPane.showInputDialog(getComponent(), "How many values must be predicted", "Henon Map DataSet", JOptionPane.QUESTION_MESSAGE); predictionLength = Integer.parseInt(s); } ListDataSet henon = ListDataSet.Factory.HenonMap(sampleCount, inputLength, predictionLength); henon.showGUI(); return henon; } }
@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); }
public ListDataSet MNISTTest() throws IOException { ListDataSet ds = DataSet.Factory.emptyDataSet();
@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); }
public ListDataSet MNISTTrain() throws IOException { ListDataSet ds = DataSet.Factory.emptyDataSet();
@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); }
public synchronized ListDataSet searchSimilar(Sample sample, int start, int count) throws Exception { Term term = new Term(Sample.ID, sample.getId()); TermQuery tq = new TermQuery(term); TopDocs td = getIndexSearcher().search(tq, count); if (td == null || td.totalHits == 0) { ListDataSet ds = ListDataSet.Factory.emptyDataSet(); return ds; } MoreLikeThis mlt = new MoreLikeThis(indexSearcher.getIndexReader()); mlt.setFieldNames(new String[] { Variable.LABEL, Variable.DESCRIPTION, Variable.TAGS }); mlt.setMaxWordLen(MAXWORDLENGTH); Query query = mlt.like(td.scoreDocs[0].doc); BooleanQuery bq = new BooleanQuery(); bq.add(query, Occur.MUST); bq.add(new TermQuery(new Term("Id", sample.getId())), Occur.MUST_NOT); return search(bq, start, count); }
@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); }
public Object call() { ListDataSet ds = ListDataSet.Factory.emptyDataSet(); if (getCoreObject() instanceof HasDataSetMap) { try { ((HasDataSetMap) getCoreObject()).getDataSetMap().add(ds); } catch (Exception e) { ds.showGUI(); } } else { ds.showGUI(); } return ds; }
@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); }
public Map<String, Object> calculateObjects(Map<String, Object> input) { Map<String, Object> result = new HashMap<String, Object>(); ListDataSet iris = DataSet.Factory.emptyDataSet(); iris.setLabel("Iris flower data set"); iris.setMetaData(Sample.URL, "http://archive.ics.uci.edu/ml/datasets/Iris");
@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); }