public Instances createTemplate(Instances i) { this.m_InstancesTemplate = new Instances(i, 0, 0); return this.m_InstancesTemplate; }
@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); } }
private void generateHeader() { ArrayList<String> classLabels = new ArrayList(); for (int i = 0; i < 2; i++) { classLabels.add("class" + (i + 1)); } ArrayList<Attribute> attributes = new ArrayList(); for (int i = 0; i < this.numAttsOption.getValue(); i++) { attributes.add(new Attribute("att" + (i + 1), classLabels)); } attributes.add(new Attribute("class", classLabels)); this.streamHeader = new InstancesHeader(new Instances( getCLICreationString(InstanceStream.class), attributes, 0)); this.streamHeader.setClassIndex(this.streamHeader.numAttributes() - 1); }
@Override public void restart() { this.random = new Random(instanceRandomSeedOption.getValue()); this.originalStream.restart(); // initializes the buffers using the original header for(int i = 0; i < instancesBuffer.length; i++){ instancesBuffer[i] = new Instances(originalStream.getHeader()); } }
protected void generateHeader() { // 2013/06/02: Noise label ArrayList<Attribute> attributes = new ArrayList<Attribute>(); for (int i = 0; i < this.numAttsOption.getValue(); i++) { attributes.add(new Attribute("att" + (i + 1))); } ArrayList<String> classLabels = new ArrayList<String>(); for (int i = 0; i < this.numClusterOption.getValue(); i++) { classLabels.add("class" + (i + 1)); } if (noiseLevelOption.getValue() > 0) classLabels.add("noise"); // The last label = "noise" attributes.add(new Attribute("class", classLabels)); streamHeader = new InstancesHeader(new Instances(getCLICreationString(InstanceStream.class), attributes, 0)); streamHeader.setClassIndex(streamHeader.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); }
protected void generateHeader() { // 2013/06/02: Noise label ArrayList<Attribute> attributes = new ArrayList<Attribute>(); for (int i = 0; i < this.numAttsOption.getValue(); i++) { attributes.add(new Attribute("att" + (i + 1))); } ArrayList<String> classLabels = new ArrayList<String>(); for (int i = 0; i < this.numClusterOption.getValue(); i++) { classLabels.add("class" + (i + 1)); } if (noiseLevelOption.getValue() > 0) classLabels.add("noise"); // The last label = "noise" attributes.add(new Attribute("class", classLabels)); streamHeader = new InstancesHeader(new Instances(getCLICreationString(InstanceStream.class), attributes, 0)); streamHeader.setClassIndex(streamHeader.numAttributes() - 1); }
protected void generateHeader() { // 2013/06/02: Noise label ArrayList<Attribute> attributes = new ArrayList<Attribute>(); for (int i = 0; i < this.numAttsOption.getValue(); i++) { attributes.add(new Attribute("att" + (i + 1))); } ArrayList<String> classLabels = new ArrayList<String>(); for (int i = 0; i < this.numClusterOption.getValue(); i++) { classLabels.add("class" + (i + 1)); } if (noiseLevelOption.getValue() > 0) classLabels.add("noise"); // The last label = "noise" attributes.add(new Attribute("class", classLabels)); streamHeader = new InstancesHeader(new Instances(getCLICreationString(InstanceStream.class), attributes, 0)); streamHeader.setClassIndex(streamHeader.numAttributes() - 1); }
/** * 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; }
/** * Initiates the current chunk and class distribution variables. */ private void initVariables() { if (this.currentChunk == null) { this.currentChunk = new Instances(this.getModelContext()); } if (this.classDistributions == null) { this.classDistributions = new long[this.getModelContext().classAttribute().numValues()]; for (int i = 0; i < this.classDistributions.length; i++) { this.classDistributions[i] = 0; } } }
/** * Initiates the current chunk and class distribution variables. */ private void initVariables() { if (this.currentChunk == null) { this.currentChunk = new Instances(this.getModelContext()); } if (this.classDistributions == null) { this.classDistributions = new long[this.getModelContext().classAttribute().numValues()]; for (int i = 0; i < this.classDistributions.length; i++) { this.classDistributions[i] = 0; } } }
@Override public void trainOnInstanceImpl(Instance inst) { if (recentChunk == null) recentChunk = new Instances(this.getModelContext()); if (recentChunk.size() < this.tau_size) recentChunk.add(inst); else recentChunk.set(this.nbInstances % this.tau_size,inst); trainAndClassify(inst); if ((this.nbInstances % this.tau_size)==0) takeSnapshot(); }
@SuppressWarnings({ "rawtypes", "unchecked" }) protected void generateHeader() { FastVector attributes = new FastVector(); for (int i = 0; i < this.numAttsOption.getValue(); i++) { attributes.addElement(new Attribute("att" + (i + 1))); } FastVector classLabels = new FastVector(); for (int i = 0; i < this.numClassesOption.getValue(); i++) { classLabels.addElement("class" + (i + 1)); } attributes.addElement(new Attribute("class", classLabels)); this.streamHeader = new InstancesHeader(new Instances(getCLICreationString(InstanceStream.class), attributes, 0)); this.streamHeader.setClassIndex(this.streamHeader.numAttributes() - 1); }
@Override public void trainOnInstanceImpl(Instance inst) { if (inst.classValue() > C) C = (int)inst.classValue(); if (this.window == null) { this.window = new Instances(inst.dataset()); } if (this.limitOption.getValue() <= this.window.numInstances()) { this.window.delete(0); } this.window.add(inst); }
protected void generateHeader() { FastVector attributes = new FastVector(); for (int i = 0; i < this.numAttsOption.getValue(); i++) { attributes.addElement(new Attribute("att" + (i + 1))); } FastVector classLabels = new FastVector(); for (int i = 0; i < this.numClassesOption.getValue(); i++) { classLabels.addElement("class" + (i + 1)); } attributes.addElement(new Attribute("class", classLabels)); this.streamHeader = new InstancesHeader(new Instances( getCLICreationString(InstanceStream.class), attributes, 0)); this.streamHeader.setClassIndex(this.streamHeader.numAttributes() - 1); }
@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; }
@SuppressWarnings({ "rawtypes", "unchecked" }) protected void generateHeader() { FastVector attributes = new FastVector(); for (int i = 0; i < this.numAttsOption.getValue(); i++) { attributes.addElement(new Attribute("att" + (i + 1))); } FastVector classLabels = new FastVector(); for (int i = 0; i < this.numClassesOption.getValue(); i++) { classLabels.addElement("class" + (i + 1)); } attributes.addElement(new Attribute("class", classLabels)); this.streamHeader = new InstancesHeader(new Instances(getCLICreationString(InstanceStream.class), attributes, 0)); this.streamHeader.setClassIndex(this.streamHeader.numAttributes() - 1); }
protected void generateHeader() { FastVector attributes = new FastVector(); for (int i = 0; i < this.numAttsOption.getValue(); i++) { attributes.addElement(new Attribute("att" + (i + 1))); } FastVector classLabels = new FastVector(); for (int i = 0; i < this.numClassesOption.getValue(); i++) { classLabels.addElement("class" + (i + 1)); } attributes.addElement(new Attribute("class", classLabels)); this.streamHeader = new InstancesHeader(new Instances( getCLICreationString(InstanceStream.class), attributes, 0)); this.streamHeader.setClassIndex(this.streamHeader.numAttributes() - 1); }
@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; }