@Override public Instance generateExample() throws Exception {
  Instance result;
  double salary;
  double commission;
  double hvalue;
  double loan;
  int age;
  int elevel;
  int car;
  int zipcode;
  int hyears;
  boolean desiredClassFound;
  double[] atts;
  Random random;
  ClassFunction classFunction;
  result=null;
  random=getRandom();
  if (m_DatasetFormat == null) {
    throw new Exception("Dataset format not defined.");
  }
  salary=0;
  commission=0;
  hvalue=0;
  loan=0;
  age=0;
  elevel=0;
  car=0;
  zipcode=0;
  hyears=0;
  desiredClassFound=false;
  classFunction=builtInFunctions[m_Function - 1];
  while (!desiredClassFound) {
    salary=20000.0 + 130000.0 * random.nextDouble();
    commission=(salary >= 75000.0) ? 0 : (10000.0 + 65000.0 * random.nextDouble());
    age=20 + random.nextInt(61);
    elevel=random.nextInt(5);
    car=1 + random.nextInt(20);
    zipcode=random.nextInt(9);
    hvalue=(9.0 - zipcode) * 100000.0 * (0.5 + random.nextDouble());
    hyears=1 + random.nextInt(30);
    loan=random.nextDouble() * 500000.0;
    m_lastLabel=classFunction.determineClass(salary,commission,age,elevel,car,zipcode,hvalue,hyears,loan);
    if (!getBalanceClass()) {
      desiredClassFound=true;
    }
 else {
      if ((m_nextClassShouldBeZero && (m_lastLabel == 0)) || (!m_nextClassShouldBeZero && (m_lastLabel == 1))) {
        desiredClassFound=true;
        m_nextClassShouldBeZero=!m_nextClassShouldBeZero;
      }
    }
  }
  if (getPerturbationFraction() > 0.0) {
    salary=perturbValue(salary,20000,150000);
    if (commission > 0) {
      commission=perturbValue(commission,10000,75000);
    }
    age=(int)Math.round(perturbValue(age,20,80));
    hvalue=perturbValue(hvalue,(9.0 - zipcode) * 100000.0,0,135000);
    hyears=(int)Math.round(perturbValue(hyears,1,30));
    loan=perturbValue(loan,0,500000);
  }
  atts=new double[m_DatasetFormat.numAttributes()];
  atts[0]=salary;
  atts[1]=commission;
  atts[2]=age;
  atts[3]=elevel;
  atts[4]=car - 1;
  atts[5]=zipcode;
  atts[6]=hvalue;
  atts[7]=hyears;
  atts[8]=loan;
  atts[9]=m_lastLabel;
  result=new DenseInstance(1.0,atts);
  result.setDataset(m_DatasetFormat);
  return result;
}

@ Override public Instance generateExample ( ) throws Exception { Instance result ; double salary ; double commission ; double hvalue ; double loan ; int age ; int elevel ; int car ; int zipcode ; int hyears ; boolean desiredClassFound ; double [ ] atts ; Random random ; ClassFunction classFunction ; result = null ; random = getRandom ( ) ; if ( m_DatasetFormat == null ) { throw new Exception ( "Dataset format not defined." ) ; } salary = 0 ; commission = 0 ; hvalue = 0 ; loan = 0 ; age = 0 ; elevel = 0 ; car = 0 ; zipcode = 0 ; hyears = 0 ; desiredClassFound = false ; classFunction = builtInFunctions [ m_Function - 1 ] ; while ( ! desiredClassFound ) { salary = 20000.0 + 130000.0 * random . nextDouble ( ) ; commission = ( salary >= 75000.0 ) ? 0 : ( 10000.0 + 65000.0 * random . nextDouble ( ) ) ; age = 20 + random . nextInt ( 61 ) ; elevel = random . nextInt ( 5 ) ; car = 1 + random . nextInt ( 20 ) ; zipcode = random . nextInt ( 9 ) ; hvalue = ( 9.0 - zipcode ) * 100000.0 * ( 0.5 + random . nextDouble ( ) ) ; hyears = 1 + random . nextInt ( 30 ) ; loan = random . nextDouble ( ) * 500000.0 ; m_lastLabel = classFunction . determineClass ( salary , commission , age , elevel , car , zipcode , hvalue , hyears , loan ) ; if ( ! getBalanceClass ( ) ) { desiredClassFound = true ; } else { if ( ( m_nextClassShouldBeZero && ( m_lastLabel == 0 ) ) || ( ! m_nextClassShouldBeZero && ( m_lastLabel == 1 ) ) ) { desiredClassFound = true ; m_nextClassShouldBeZero = ! m_nextClassShouldBeZero ; } } } if ( getPerturbationFraction ( ) > 0.0 ) { salary = perturbValue ( salary , 20000 , 150000 ) ; if ( commission > 0 ) { commission = perturbValue ( commission , 10000 , 75000 ) ; } age = ( int ) Math . round ( perturbValue ( age , 20 , 80 ) ) ; hvalue = perturbValue ( hvalue , ( 9.0 - zipcode ) * 100000.0 , 0 , 135000 ) ; hyears = ( int ) Math . round ( perturbValue ( hyears , 1 , 30 ) ) ; loan = perturbValue ( loan , 0 , 500000 ) ; } atts = new double [ m_DatasetFormat . numAttributes ( ) ] ; atts [ 0 ] = salary ; atts [ 1 ] = commission ; atts [ 2 ] = age ; atts [ 3 ] = elevel ; atts [ 4 ] = car - 1 ; atts [ 5 ] = zipcode ; atts [ 6 ] = hvalue ; atts [ 7 ] = hyears ; atts [ 8 ] = loan ; atts [ 9 ] = m_lastLabel ; result = new DenseInstance ( 1.0 , atts ) ; result . setDataset ( m_DatasetFormat ) ; return result ; }
generates one example of the dataset .
