private Attribute defaultNumericAttribute() { if (this.defaultNumericAttribute == null) { this.defaultNumericAttribute = new Attribute("default"); } return this.defaultNumericAttribute; }
/** * Get Samoa attribute from a weka attribute. * * @param index the index * @param attribute the attribute * @return the attribute */ protected Attribute samoaAttribute(int index, weka.core.Attribute attribute) { Attribute samoaAttribute; if (attribute.isNominal()) { Enumeration enu = attribute.enumerateValues(); List<String> attributeValues = new ArrayList<String>(); while (enu.hasMoreElements()) { attributeValues.add((String) enu.nextElement()); } samoaAttribute = new Attribute(attribute.name(), attributeValues); } else { samoaAttribute = new Attribute(attribute.name()); } return samoaAttribute; } }
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); }
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); }
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); }
@Override protected void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { ArrayList<Attribute> attributes = new ArrayList(); int numAtts = 2; if (!this.suppressIrrelevantAttributesOption.isSet()) { numAtts += NUM_IRRELEVANT_ATTRIBUTES; } for (int i = 0; i < numAtts; i++) { attributes.add(new Attribute("att" + (i + 1))); } List classLabels = new ArrayList(); classLabels.add("positive"); classLabels.add("negative"); Attribute classAtt = new Attribute("class", classLabels); attributes.add(classAtt); this.streamHeader = new InstancesHeader(new Instances( getCLICreationString(InstanceStream.class), attributes, 0)); this.streamHeader.setClassIndex(this.streamHeader.numAttributes() - 1); restart(); } }
@Override protected void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { // generate header FastVector attributes = new FastVector(); attributes.addElement(new Attribute("attrib1")); attributes.addElement(new Attribute("attrib2")); attributes.addElement(new Attribute("attrib3")); FastVector classLabels = new FastVector(); classLabels.addElement("groupA"); classLabels.addElement("groupB"); attributes.addElement(new Attribute("class", classLabels)); this.streamHeader = new InstancesHeader(new Instances( getCLICreationString(InstanceStream.class), attributes, 0)); this.streamHeader.setClassIndex(this.streamHeader.numAttributes() - 1); restart(); }
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; }
@Override protected void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { restart(); this.numInstances = 0; this.period = numInstancesConceptOption.getValue(); // generate header FastVector attributes = new FastVector(); FastVector binaryLabels = new FastVector(); binaryLabels.addElement("0"); binaryLabels.addElement("1"); if (!this.notBinaryStreamOption.isSet()) { attributes.addElement(new Attribute("input", binaryLabels)); } else { attributes.addElement(new Attribute("input")); } // Ground Truth attributes.addElement(new Attribute("change", binaryLabels)); attributes.addElement(new Attribute("ground truth input")); this.streamHeader = new InstancesHeader(new Instances( getCLICreationString(InstanceStream.class), attributes, 0)); this.streamHeader.setClassIndex(this.streamHeader.numAttributes() - 1); this.clusterEvents = new ArrayList<ClusterEvent>(); //this.clusterEvents.add(new ClusterEvent(this,100,"Change", "Drift")); //this.clusterEvents.add(new ClusterEvent(this,200,"Change2", "Drift2")); }
@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); }
@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); }
protected void generateHeader() { FastVector<Attribute> attributes = new FastVector<>(); FastVector<String> nominalAttVals = new FastVector<>(); for (int i = 0; i < this.numValsPerNominalOption.getValue(); i++) { nominalAttVals.addElement("value" + (i + 1)); } for (int i = 0; i < this.numNominalsOption.getValue(); i++) { attributes.addElement(new Attribute("nominal" + (i + 1), nominalAttVals)); } for (int i = 0; i < this.numNumericsOption.getValue(); i++) { attributes.addElement(new Attribute("numeric" + (i + 1))); } FastVector<String> 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(); FastVector nominalAttVals = new FastVector(); for (int i = 0; i < this.numValsPerNominalOption.getValue(); i++) { nominalAttVals.addElement("value" + (i + 1)); } for (int i = 0; i < this.numNominalsOption.getValue(); i++) { attributes.addElement(new Attribute("nominal" + (i + 1), nominalAttVals)); } for (int i = 0; i < this.numNumericsOption.getValue(); i++) { attributes.addElement(new Attribute("numeric" + (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(); FastVector nominalAttVals = new FastVector(); for (int i = 0; i < this.numValsPerNominalOption.getValue(); i++) { nominalAttVals.addElement("value" + (i + 1)); } for (int i = 0; i < this.numNominalsOption.getValue(); i++) { attributes.addElement(new Attribute("nominal" + (i + 1), nominalAttVals)); } for (int i = 0; i < this.numNumericsOption.getValue(); i++) { attributes.addElement(new Attribute("numeric" + (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 void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { // generate header FastVector attributes = new FastVector(); int numAtts = this.addNoiseOption.isSet() ? TOTAL_ATTRIBUTES_INCLUDING_NOISE : NUM_BASE_ATTRIBUTES; for (int i = 0; i < numAtts; i++) { attributes.addElement(new Attribute("att" + (i + 1))); } FastVector classLabels = new FastVector(); for (int i = 0; i < NUM_CLASSES; 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); restart(); }
public void weka() { try{ Class.forName("weka.gui.Logger"); } catch (Exception e){ m_logPanel.addText("Please add weka.jar to the classpath to use the Weka explorer."); return; } Clustering wekaClustering; wekaClustering = null; if(wekaClustering == null || wekaClustering.size()==0){ m_logPanel.addText("Empty Clustering"); return; } int dims = wekaClustering.get(0).getCenter().length; FastVector attributes = new FastVector(); for(int i = 0; i < dims; i++) attributes.addElement( new Attribute("att" + i) ); Instances instances = new Instances("trainset",attributes,0); for(int c = 0; c < wekaClustering.size(); c++){ Cluster cluster = wekaClustering.get(c); Instance inst = new DenseInstance(cluster.getWeight(), cluster.getCenter()); inst.setDataset(instances); instances.add(inst); } WekaExplorer explorer = new WekaExplorer(instances); }
/** * 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); }