@Override public int classIndex() { return instanceInformation.classIndex(); }
/** * Helper method to set the model context, i.e. how many attributes they are and what is the class index * @param ih */ private void setModelContext(InstancesHeader ih){ //TODO possibly refactored if ((ih != null) && (ih.classIndex() < 0)) { throw new IllegalArgumentException( "Context for a classifier must include a class to learn"); } //TODO: check flag for checking whether training has started or not //model context is used to describe the model logger.trace("Model context: {}", ih.toString()); }
/** * Helper method to set the model context, i.e. how many attributes they are and what is the class index * @param ih */ private void setModelContext(InstancesHeader ih){ //TODO possibly refactored if ((ih != null) && (ih.classIndex() < 0)) { throw new IllegalArgumentException( "Context for a classifier must include a class to learn"); } //TODO: check flag for checking whether training has started or not //model context is used to describe the model this.modelContext = ih; logger.trace("Model context: {}", this.modelContext.toString()); }
/** * Class index. * * @return the int */ @Override public int classIndex() { int classIndex = instanceHeader.classIndex(); // return ? classIndex : 0; if(classIndex == Integer.MAX_VALUE) if(this.instanceHeader.instanceInformation.range!=null) classIndex=instanceHeader.instanceInformation.range.getStart(); else classIndex=0; return classIndex; }
@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); } }
public void setModelContext(InstancesHeader ih) { if ((ih != null) && (ih.classIndex() < 0)) { throw new IllegalArgumentException( "Context for a Clusterer must include a class to learn"); } if (trainingHasStarted() && (this.modelContext != null) && ((ih == null) || !contextIsCompatible(this.modelContext, ih))) { throw new IllegalArgumentException( "New context is not compatible with existing model"); } this.modelContext = ih; }
public void setModelContext(InstancesHeader ih) { if ((ih != null) && (ih.classIndex() < 0)) { throw new IllegalArgumentException( "Context for a Clusterer must include a class to learn"); } if (trainingHasStarted() && (this.modelContext != null) && ((ih == null) || !contextIsCompatible(this.modelContext, ih))) { throw new IllegalArgumentException( "New context is not compatible with existing model"); } this.modelContext = ih; }
public void setModelContext(InstancesHeader ih) { if ((ih != null) && (ih.classIndex() < 0)) { throw new IllegalArgumentException( "Context for a Clusterer must include a class to learn"); } if (trainingHasStarted() && (this.modelContext != null) && ((ih == null) || !contextIsCompatible(this.modelContext, ih))) { throw new IllegalArgumentException( "New context is not compatible with existing model"); } this.modelContext = ih; }
@Override public void setModelContext(InstancesHeader ih) { if ((ih != null) && (ih.classIndex() < 0)) { throw new IllegalArgumentException( "Context for a classifier must include a class to learn"); } if (trainingHasStarted() && (this.modelContext != null) && ((ih == null) || !contextIsCompatible(this.modelContext, ih))) { throw new IllegalArgumentException( "New context is not compatible with existing model"); } this.modelContext = ih; }
@Override public void setModelContext(InstancesHeader ih) { if ((ih != null) && (ih.classIndex() < 0)) { throw new IllegalArgumentException( "Context for a classifier must include a class to learn"); } if (trainingHasStarted() && (this.modelContext != null) && ((ih == null) || !contextIsCompatible(this.modelContext, ih))) { throw new IllegalArgumentException( "New context is not compatible with existing model"); } this.modelContext = ih; }
@Override public void setModelContext(InstancesHeader ih) { if ((ih != null) && (ih.classIndex() < 0)) { throw new IllegalArgumentException( "Context for a classifier must include a class to learn"); } if (trainingHasStarted() && (this.modelContext != null) && ((ih == null) || !contextIsCompatible(this.modelContext, ih))) { throw new IllegalArgumentException( "New context is not compatible with existing model"); } this.modelContext = ih; }
@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); } }
public static String getAttributeNameString(InstancesHeader context, int attIndex) { if ((context == null) || (attIndex >= context.numAttributes())) { return "[att " + (attIndex + 1) + "]"; } int instAttIndex = attIndex < context.classIndex() ? attIndex : attIndex + 1; return "[att " + (attIndex + 1) + ":" + context.attribute(instAttIndex).name() + "]"; }
public static String getAttributeNameString(InstancesHeader context, int attIndex) { if ((context == null) || (attIndex >= context.numAttributes())) { return "[att " + (attIndex + 1) + "]"; } int instAttIndex = attIndex < context.classIndex() ? attIndex : attIndex + 1; return "[att " + (attIndex + 1) + ":" + context.attribute(instAttIndex).name() + "]"; }
public static String getNumericValueString(InstancesHeader context, int attIndex, double value) { if (context != null) { int instAttIndex = attIndex < context.classIndex() ? attIndex : attIndex + 1; if (instAttIndex < context.numAttributes()) { if (context.attribute(instAttIndex).isDate()) { return context.attribute(instAttIndex).formatDate(value); } } } return Double.toString(value); }
public static String getNumericValueString(InstancesHeader context, int attIndex, double value) { if (context != null) { int instAttIndex = attIndex < context.classIndex() ? attIndex : attIndex + 1; if (instAttIndex < context.numAttributes()) { if (context.attribute(instAttIndex).isDate()) { return context.attribute(instAttIndex).formatDate(value); } } } return Double.toString(value); }
dataset.setClassIndex(h); System.out.println(""+dataset); System.out.println("classIndex : "+dataset.classIndex()); System.out.println("numClasses : "+dataset.numClasses()); System.out.println("numInstances: "+dataset.numInstances());
public static String getNominalValueString(InstancesHeader context, int attIndex, int valIndex) { if (context != null) { int instAttIndex = attIndex < context.classIndex() ? attIndex : attIndex + 1; if ((instAttIndex < context.numAttributes()) && (valIndex < context.attribute(instAttIndex).numValues())) { return "{val " + (valIndex + 1) + ":" + context.attribute(instAttIndex).value(valIndex) + "}"; } } return "{val " + (valIndex + 1) + "}"; }
if(originalHeader.classIndex() != -1){ attributes.add(originalHeader.attribute(originalHeader.classIndex()));
public static String getNominalValueString(InstancesHeader context, int attIndex, int valIndex) { if (context != null) { int instAttIndex = attIndex < context.classIndex() ? attIndex : attIndex + 1; if ((instAttIndex < context.numAttributes()) && (valIndex < context.attribute(instAttIndex).numValues())) { return "{val " + (valIndex + 1) + ":" + context.attribute(instAttIndex).value(valIndex) + "}"; } } return "{val " + (valIndex + 1) + "}"; }