protected void addMissing(Instances data,int level,boolean predictorMissing,boolean classMissing){
  int classIndex=data.classIndex();
  Random random=new Random(1);
  for (int i=0; i < data.numInstances(); i++) {
    Instance current=data.instance(i);
    for (int j=0; j < data.numAttributes(); j++) {
      if (((j == classIndex) && classMissing) || ((j != classIndex) && predictorMissing)) {
        if (Math.abs(random.nextInt()) % 100 < level)         current.setMissing(j);
      }
    }
  }
}

protected void addMissing ( Instances data , int level , boolean predictorMissing , boolean classMissing ) { int classIndex = data . classIndex ( ) ; Random random = new Random ( 1 ) ; for ( int i = 0 ; i < data . numInstances ( ) ; i ++ ) { Instance current = data . instance ( i ) ; for ( int j = 0 ; j < data . numAttributes ( ) ; j ++ ) { if ( ( ( j == classIndex ) && classMissing ) || ( ( j != classIndex ) && predictorMissing ) ) { if ( Math . abs ( random . nextInt ( ) ) % 100 < level ) current . setMissing ( j ) ; } } } }
add missing values to a dataset .
