/** * for testing only - takes a data file as input. * * @param args the commandline arguments * @throws Exception if something goes wrong */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("\nUsage: " + DataSource.class.getName() + " <file>\n"); System.exit(1); } DataSource loader = new DataSource(args[0]); System.out.println("Incremental? " + loader.isIncremental()); System.out.println("Loader: " + loader.getLoader().getClass().getName()); System.out.println("Data:\n"); Instances structure = loader.getStructure(); System.out.println(structure); while (loader.hasMoreElements(structure)) { System.out.println(loader.nextElement(structure)); } Instances inst = loader.getDataSet(); loader = new DataSource(inst); System.out.println("\n\nProxy-Data:\n"); System.out.println(loader.getStructure()); while (loader.hasMoreElements(structure)) { System.out.println(loader.nextElement(inst)); } }
/** * for testing only - takes a data file as input. * * @param args the commandline arguments * @throws Exception if something goes wrong */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("\nUsage: " + DataSource.class.getName() + " <file>\n"); System.exit(1); } DataSource loader = new DataSource(args[0]); System.out.println("Incremental? " + loader.isIncremental()); System.out.println("Loader: " + loader.getLoader().getClass().getName()); System.out.println("Data:\n"); Instances structure = loader.getStructure(); System.out.println(structure); while (loader.hasMoreElements(structure)) { System.out.println(loader.nextElement(structure)); } Instances inst = loader.getDataSet(); loader = new DataSource(inst); System.out.println("\n\nProxy-Data:\n"); System.out.println(loader.getStructure()); while (loader.hasMoreElements(structure)) { System.out.println(loader.nextElement(inst)); } }
data = source.getDataSet(); } else if (classIndex == -2) { data = source.getDataSet(source.getStructure().numAttributes() - 1); } else { data = source.getDataSet(classIndex);
source = new DataSource(test); testRaw = source.getStructure(test.classIndex()); : new Instances(source.getStructure(), 0); i = 0; while (source.hasMoreElements(testRaw)) {
DataSource source1 = new DataSource(args[1]); DataSource source2 = new DataSource(args[2]); String msg = source1.getStructure().equalHeadersMsg( source2.getStructure()); if (msg != null) { throw new Exception("The two datasets have different headers:\n" + msg); Instances structure = source1.getStructure(); System.out.println(source1.getStructure()); while (source1.hasMoreElements(structure)) { System.out.println(source1.nextElement(structure)); structure = source2.getStructure(); while (source2.hasMoreElements(structure)) { System.out.println(source2.nextElement(structure)); DataSource source1 = new DataSource(args[1]); DataSource source2 = new DataSource(args[2]); String msg = source1.getStructure().equalHeadersMsg( source2.getStructure()); if (msg == null) { System.out.println("Headers match");
DataSource source1 = new DataSource(args[1]); DataSource source2 = new DataSource(args[2]); String msg = source1.getStructure().equalHeadersMsg( source2.getStructure()); if (msg != null) { throw new Exception("The two datasets have different headers:\n" + msg); Instances structure = source1.getStructure(); System.out.println(source1.getStructure()); while (source1.hasMoreElements(structure)) { System.out.println(source1.nextElement(structure)); structure = source2.getStructure(); while (source2.hasMoreElements(structure)) { System.out.println(source2.nextElement(structure)); DataSource source1 = new DataSource(args[1]); DataSource source2 = new DataSource(args[2]); String msg = source1.getStructure().equalHeadersMsg( source2.getStructure()); if (msg == null) { System.out.println("Headers match");
source = new DataSource(test); testRaw = source.getStructure(test.classIndex()); : new Instances(source.getStructure(), 0); i = 0; while (source.hasMoreElements(testRaw)) {
source = new DataSource(inst); instances = source.getStructure(inst.classIndex());
Instances structure = source.getStructure(); Instances forBatchPredictors = (clusterer instanceof BatchPredictor && ((BatchPredictor) clusterer) .implementsMoreEfficientBatchPrediction()) ? new Instances( source.getStructure(), 0) : null;
Instances structure = source.getStructure(); Instances forBatchPredictors = (clusterer instanceof BatchPredictor && ((BatchPredictor) clusterer) .implementsMoreEfficientBatchPrediction()) ? new Instances( source.getStructure(), 0) : null;
structure = source.getStructure(); Instances forBatchPredictors = (clusterer instanceof BatchPredictor && ((BatchPredictor) clusterer) .implementsMoreEfficientBatchPrediction()) ? new Instances( source.getStructure(), 0) : null; while (source.hasMoreElements(structure)) { inst = source.nextElement(structure);
data = source.getDataSet(); } else if (classIndex == -2) { data = source.getDataSet(source.getStructure().numAttributes() - 1); } else { data = source.getDataSet(classIndex);
source = new DataSource(inst); instances = source.getStructure(inst.classIndex());
structure = source.getStructure(); Instances forBatchPredictors = (clusterer instanceof BatchPredictor && ((BatchPredictor) clusterer) .implementsMoreEfficientBatchPrediction()) ? new Instances( source.getStructure(), 0) : null; while (source.hasMoreElements(structure)) { inst = source.nextElement(structure);
test = testset.getStructure(); if (!(classifier instanceof InputMappedClassifier)) { try {
test = testset.getStructure(); if (!(classifier instanceof InputMappedClassifier)) { try {
/** * Attempts to determine the number of classes/class index from the * specified file. In case of ARFF files, only the header will get loaded. * * @param file the file to inspect * @return the class index of the file, Integer.MAX_VALUE in case of error */ public static int peekClassIndex(File file) { int result; DataSource source; Instances structure; result = Integer.MAX_VALUE; try { source = new DataSource(file.getAbsolutePath()); structure = source.getStructure(); prepareData(structure); result = structure.classIndex(); } catch (Exception e) { // ignored } return result; }
/** * Attempts to determine the number of classes/class index from the * specified file. In case of ARFF files, only the header will get loaded. * * @param file the file to inspect * @return the class index of the file, Integer.MAX_VALUE in case of error */ public static int peekClassIndex(File file) { int result; DataSource source; Instances structure; result = Integer.MAX_VALUE; try { source = new DataSource(file.getAbsolutePath()); structure = source.getStructure(); prepareData(structure); result = structure.classIndex(); } catch (Exception e) { // ignored } return result; }
/** * returns the structure of the data, with the defined class index. * * @param classIndex the class index for the dataset * @return the structure of the data * @throws Exception if something goes wrong */ public Instances getStructure(int classIndex) throws Exception { Instances result; result = getStructure(); if (result != null) { result.setClassIndex(classIndex); } return result; }
/** * returns the structure of the data, with the defined class index. * * @param classIndex the class index for the dataset * @return the structure of the data * @throws Exception if something goes wrong */ public Instances getStructure(int classIndex) throws Exception { Instances result; result = getStructure(); if (result != null) { result.setClassIndex(classIndex); } return result; }