@Override public void setModelContext(InstancesHeader context) { try { this.window = new Instances(context,0); //new StringReader(context.toString()) this.window.setClassIndex(context.classIndex()); } catch(Exception e) { System.err.println("Error: no Model Context available."); e.printStackTrace(); System.exit(1); } }
@Override public void setModelContext(InstancesHeader context) { try { this.stm = new Instances(context,0); this.stm.setClassIndex(context.classIndex()); this.ltm = new Instances(context,0); this.ltm.setClassIndex(context.classIndex()); this.init(); } catch(Exception e) { System.err.println("Error: no Model Context available."); e.printStackTrace(); System.exit(1); } }
protected void reset() { try { if (this.fileReader != null) this.fileReader.close(); fileSource.reset(); } catch (IOException ioe) { throw new RuntimeException("FileStream restart failed.", ioe); } if (!getNextFileReader()) { hitEndOfStream = true; throw new RuntimeException("FileStream is empty."); } this.instances = new Instances(this.fileReader, 1, -1); this.instances.setClassIndex(this.instances.numAttributes() - 1); }
protected void reset() { try { if (this.fileReader != null) this.fileReader.close(); fileSource.reset(); } catch (IOException ioe) { throw new RuntimeException("FileStream restart failed.", ioe); } if (!getNextFileReader()) { hitEndOfStream = true; throw new RuntimeException("FileStream is empty."); } this.instances = new Instances(this.fileReader, 1, -1); this.instances.setClassIndex(this.instances.numAttributes() - 1); }
private void reset() throws IOException { if (this.fileReader != null) { this.fileReader.close(); } InputStream fileStream = new FileInputStream(this.arffFileOption.getFile()); this.fileProgressMonitor = new InputStreamProgressMonitor( fileStream); this.fileReader = new BufferedReader(new InputStreamReader( this.fileProgressMonitor)); this.instances = new Instances(this.fileReader, 1, this.classIndexOption.getValue()); if (this.classIndexOption.getValue() < 0) { this.instances.setClassIndex(this.instances.numAttributes() - 1); } else if (this.classIndexOption.getValue() > 0) { this.instances.setClassIndex(this.classIndexOption.getValue() - 1); } this.numInstancesRead = 0; this.lastInstanceRead = null; }
private void reset() throws IOException, FileNotFoundException { if (this.fileReader != null) { this.fileReader.close(); } InputStream fileStream = new FileInputStream(this.arffFileOption.getFile()); this.fileProgressMonitor = new InputStreamProgressMonitor( fileStream); this.fileReader = new BufferedReader(new InputStreamReader( this.fileProgressMonitor)); this.instances = new Instances(this.fileReader, 1, this.classIndexOption.getValue()); if (this.classIndexOption.getValue() < 0) { this.instances.setClassIndex(this.instances.numAttributes() - 1); } else if (this.classIndexOption.getValue() > 0) { this.instances.setClassIndex(this.classIndexOption.getValue() - 1); } this.numInstancesRead = 0; this.lastInstanceRead = null; }
@Override protected boolean getNextFileReader() { boolean ret = super.getNextFileReader(); if (ret) { this.instances = new Instances(this.fileReader, 1, -1); if (this.classIndexOption.getValue() < 0) { this.instances.setClassIndex(this.instances.numAttributes() - 1); } else if (this.classIndexOption.getValue() > 0) { this.instances.setClassIndex(this.classIndexOption.getValue() - 1); } } return ret; }
@Override protected boolean getNextFileReader() { boolean ret = super.getNextFileReader(); if (ret) { this.instances = new Instances(this.fileReader, 1, -1); if (this.classIndexOption.getValue() < 0) { this.instances.setClassIndex(this.instances.numAttributes() - 1); } else if (this.classIndexOption.getValue() > 0) { this.instances.setClassIndex(this.classIndexOption.getValue() - 1); } } return ret; }
@Override public void restart() { try { if (this.fileReader != null) { this.fileReader.close(); } InputStream fileStream = new FileInputStream(this.arffFileOption.getFile()); this.fileProgressMonitor = new InputStreamProgressMonitor( fileStream); this.fileReader = new BufferedReader(new InputStreamReader( this.fileProgressMonitor)); int classIndex = this.classIndexOption.getValue(); this.instances = new Instances(this.fileReader, 1, classIndex); if (classIndex < 0) { this.instances.setClassIndex(this.instances.numAttributes() - 1); } else if (this.classIndexOption.getValue() > 0) { this.instances.setClassIndex(this.classIndexOption.getValue() - 1); } this.numInstancesRead = 0; this.lastInstanceRead = null; this.hitEndOfFile = !readNextInstanceFromFile(); } catch (IOException ioe) { throw new RuntimeException("ArffFileStream restart failed.", ioe); } this.clusterEvents = new ArrayList<ClusterEvent>(); }
/** * Samoa instances information. * * @param instances the instances * @return the instances */ public Instances samoaInstancesInformation(weka.core.Instances instances) { Instances samoaInstances; List<Attribute> attInfo = new ArrayList<Attribute>(); for (int i = 0; i < instances.numAttributes(); i++) { attInfo.add(samoaAttribute(i, instances.attribute(i))); } samoaInstances = new Instances(instances.relationName(), attInfo, 0); samoaInstances.setClassIndex(instances.classIndex()); return samoaInstances; }
this.dataset = new Instances(csvFileOption.getFile().getName(), attributes, 0); this.dataset.setClassIndex(this.numAttributes - 1); numAttsOption = new IntOption("numAtts", 'a', "", this.numAttributes);
format.setClassIndex(attributes.size() - 1); newHeader = new InstancesHeader(format);
instances = new Instances(fileReader, 1, this.classIndexOption.getValue()); if (classIndexOption.getValue() < 0) { instances.setClassIndex(instances.numAttributes() - 1); } else if (classIndexOption.getValue() > 0) { instances.setClassIndex(classIndexOption.getValue() - 1);
/** * GenerateMultilabelHeader. * * @param si single-label Instances */ protected MultilabelInstancesHeader generateMultilabelHeader(Instances si) { Instances mi = new Instances(si, 0, 0); mi.setClassIndex(-1); mi.deleteAttributeAt(mi.numAttributes() - 1); FastVector bfv = new FastVector(); bfv.addElement("0"); bfv.addElement("1"); for (int i = 0; i < this.m_L; i++) { mi.insertAttributeAt(new Attribute("class" + i, bfv), i); } this.multilabelStreamTemplate = mi; this.multilabelStreamTemplate.setRelationName("SYN_Z" + this.labelCardinalityOption.getValue() + "L" + this.m_L + "X" + m_A + "S" + metaRandomSeedOption.getValue() + ": -C " + this.m_L); this.multilabelStreamTemplate.setClassIndex(this.m_L); return new MultilabelInstancesHeader(multilabelStreamTemplate, m_L); }
public void initHeader(Instances dataset) { int numLabels = this.numOldLabelsOption.getValue(); Attribute target = dataset.classAttribute(); List<String> possibleValues = new ArrayList<String>(); int n = target.numValues(); for (int i = 0; i < n; i++) { possibleValues.add(target.value(i)); } ArrayList<Attribute> attrs = new ArrayList<Attribute>(numLabels + dataset.numAttributes()); for (int i = 0; i < numLabels; i++) { attrs.add(new Attribute(target.name() + "_" + i, possibleValues)); } for (int i = 0; i < dataset.numAttributes(); i++) { Attribute attr = dataset.attribute(i); Attribute newAttribute = null; if (attr.isNominal() == true) { newAttribute = new Attribute(attr.name(), attr.getAttributeValues()); } if (attr.isNumeric() == true) { newAttribute = new Attribute(attr.name()); } if (newAttribute != null) { attrs.add(newAttribute); } } this.header = new Instances("extended_" + dataset.getRelationName(), attrs, 0); this.header.setClassIndex(numLabels + dataset.classIndex()); }
public Instances getDataset(int numdim, int numclass) { FastVector attributes = new FastVector(); for (int i = 0; i < numdim; i++) { attributes.addElement(new Attribute("att" + (i + 1))); } if (numclass > 0) { FastVector classLabels = new FastVector(); for (int i = 0; i < numclass; i++) { classLabels.addElement("class" + (i + 1)); } attributes.addElement(new Attribute("class", classLabels)); } Instances myDataset = new Instances("horizion", attributes, 0); if (numclass > 0) { myDataset.setClassIndex(myDataset.numAttributes() - 1); } return myDataset; }