protected static int modelAttIndexToInstanceAttIndex(int index, Instances insts) { return insts.classIndex() > index ? index : index + 1; }
protected static int modelAttIndexToInstanceAttIndex(int index, Instances insts) { return insts.classIndex() > index ? index : index + 1; }
protected static int modelAttIndexToInstanceAttIndex(int index, Instances insts) { return insts.classIndex() > index ? index : index + 1; }
/** * Gets the index of the attribute in a set of instances, * given the index of the attribute in the learner. * * @param index the index of the attribute in the learner * @param insts the instances * @return the index of the attribute in the instances */ protected static int modelAttIndexToInstanceAttIndex(int index, Instances insts) { return insts.classIndex() > index ? index : index + 1; } }
final int classIdx = m_Instances.classIndex(); double widest = 0.0; int w = -1;
final int classIdx = m_Instances.classIndex(); double widest = 0.0; int w = -1;
/** * Sets the indices of relevant features. * This method also sets the irrelevant ones since * it is the set complement. * * @param indicesRelevants */ public void setIndicesRelevants(int[] indicesRelevants) { this.indicesRelevants = indicesRelevants; // -1 to skip the class attribute int numIrrelevantFeatures = this.numAttributes() - this.indicesRelevants.length - 1; this.indicesIrrelevants = new int[numIrrelevantFeatures]; // Infers and sets the set of irrelevant features int index = 0; int indexRel = 0; for(int i = 0; i < numAttributes(); i++){ if(i != classIndex()) { while (indexRel < indicesRelevants.length - 1 && i > indicesRelevants[indexRel]) indexRel++; if (indicesRelevants[indexRel] != i){ indicesIrrelevants[index] = i; index++; } } } } }
if (w == m_headerInfo.classIndex()) { continue;
int splitDim = -1, classIdx = m_Instances.classIndex();
int classIndex = this.ltm.classIndex(); for (int c = 0; c <= this.maxClassValue; c++){ List<double[]> classSamples = new ArrayList<>();
/** * Weka instances information. * * @param instances the instances * @return the weka.core. instances */ public weka.core.Instances wekaInstancesInformation(Instances instances) { weka.core.Instances wekaInstances; ArrayList<weka.core.Attribute> attInfo = new ArrayList<weka.core.Attribute>(); for (int i = 0; i < instances.numAttributes(); i++) { attInfo.add(wekaAttribute(i, instances.attribute(i))); } wekaInstances = new weka.core.Instances(instances.getRelationName(), attInfo, 0); if (instances.instanceInformation.numOutputAttributes() == 1){ wekaInstances.setClassIndex(instances.classIndex()); } else { //Assign a classIndex to a MultiLabel instance for compatibility reasons wekaInstances.setClassIndex(instances.instanceInformation.numOutputAttributes()-1); //instances.numAttributes()-1); //Last } //System.out.println(attInfo.get(3).name()); //System.out.println(attInfo.get(3).isNominal()); //System.out.println(wekaInstances.attribute(3).name()); //System.out.println(wekaInstances.attribute(3).isNominal()); return wekaInstances; }
if(!instances.attribute(i).isNumeric() && i != instances.classIndex()){ attributes.add(i);
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()); }
|| dim == m_Instances.classIndex()) continue; if (j == m_Instances.classIndex()) continue; val = m_Instances.instance(m_InstList[i]).value(j); leftSqSum = rightSqSum = 0.0; for (int j = 0; j < m_Instances.numAttributes(); j++) { if (j == m_Instances.classIndex()) continue; val = inst.value(j);
@Override public Example<Instance> nextInstance() { Example<Instance> original = originalStream.nextInstance(); // copies the original values double values[] = new double[this.newHeader.numAttributes()]; int ix = 0; for(int i = 0; i < original.getData().dataset().numAttributes(); i++){ if(original.getData().dataset().classIndex() != i) { values[ix] = original.getData().value(i); ix++; } } // appends the new values while(ix < values.length - 1){ Attribute att = this.newHeader.attribute(ix); if(att.isNumeric()) values[ix] = this.random.nextDouble(); else values[ix] = this.random.nextInt(numValuesCategoricalFeatureOption.getValue()); ix++; } //copies the class value if(original.getData().classIndex() != -1) { values[values.length - 1] = original.getData().classValue(); } // instantiates and returns the actual instance Instance instnc = new DenseInstance(1.0, values); instnc.setDataset(this.newHeader); return new InstanceExample(instnc); }
int secondNumValues = second.numValues(); int numAttributes = m_Data.numAttributes(); int classIndex = m_Data.classIndex();