/** * 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)); } }
/** * initializes the batch buffer if necessary, i.e., for non-incremental * loaders. */ protected void initBatchBuffer() { try { if (!isIncremental()) { m_BatchBuffer = m_Loader.getDataSet(); } else { m_BatchBuffer = null; } } catch (Exception e) { e.printStackTrace(); } }
break; case 4: // Test on user split if (source.isIncremental()) { outBuff.append("user supplied test set: " + " size unknown (reading incrementally)\n");
break; case 4: // Test on user split if (source.isIncremental()) { outBuff.append("user supplied test set: " + " size unknown (reading incrementally)\n");
/** * returns whether there are more Instance objects in the data. * * @param structure the structure of the dataset * @return true if there are more Instance objects available * @see #nextElement(Instances) */ public boolean hasMoreElements(Instances structure) { boolean result; result = false; if (isIncremental()) { // user still hasn't collected the last one? if (m_IncrementalBuffer != null) { result = true; } else { try { m_IncrementalBuffer = m_Loader.getNextInstance(structure); result = (m_IncrementalBuffer != null); } catch (Exception e) { e.printStackTrace(); result = false; } } } else { result = (m_BatchCounter < m_BatchBuffer.numInstances()); } return result; }
/** * returns whether there are more Instance objects in the data. * * @param structure the structure of the dataset * @return true if there are more Instance objects available * @see #nextElement(Instances) */ public boolean hasMoreElements(Instances structure) { boolean result; result = false; if (isIncremental()) { // user still hasn't collected the last one? if (m_IncrementalBuffer != null) { result = true; } else { try { m_IncrementalBuffer = m_Loader.getNextInstance(structure); result = (m_IncrementalBuffer != null); } catch (Exception e) { e.printStackTrace(); result = false; } } } else { result = (m_BatchCounter < m_BatchBuffer.numInstances()); } return result; }
/** * resets the loader. * * @throws Exception if resetting fails */ public void reset() throws Exception { if (m_File != null) { ((AbstractFileLoader) m_Loader).setFile(m_File); } else if (m_URL != null) { ((URLSourcedLoader) m_Loader).setURL(m_URL.toString()); } else if (m_Loader != null) { m_Loader.reset(); } m_BatchCounter = 0; m_IncrementalBuffer = null; if (m_Loader != null) { if (!isIncremental()) { m_BatchBuffer = m_Loader.getDataSet(); } else { m_BatchBuffer = null; } } }
/** * resets the loader. * * @throws Exception if resetting fails */ public void reset() throws Exception { if (m_File != null) { ((AbstractFileLoader) m_Loader).setFile(m_File); } else if (m_URL != null) { ((URLSourcedLoader) m_Loader).setURL(m_URL.toString()); } else if (m_Loader != null) { m_Loader.reset(); } m_BatchCounter = 0; m_IncrementalBuffer = null; if (m_Loader != null) { if (!isIncremental()) { m_BatchBuffer = m_Loader.getDataSet(); } else { m_BatchBuffer = null; } } }
/** * initializes the batch buffer if necessary, i.e., for non-incremental * loaders. */ protected void initBatchBuffer() { try { if (!isIncremental()) { m_BatchBuffer = m_Loader.getDataSet(); } else { m_BatchBuffer = null; } } catch (Exception e) { e.printStackTrace(); } }