if (indicesSparse[j] == trainCopy.classIndex()) { weights[indicesSparse[j]] = -Double.MAX_VALUE; } else { weights[indicesSparse[j]] = weightsSparse[j] * weightsSparse[j]; }
weights[indicesSparse[j]] = weightsSparse[j] * weightsSparse[j];
  public void buildEvaluator(Instances data) throws Exception {        if (data.checkForStringAttributes()) {      throw  new Exception("Can't handle string attributes!");    }        if (!data.classAttribute().isNominal()) {      throw new Exception("Class must be nominal!");    }        if (data.classAttribute().numValues() != 2) {      throw new Exception("Can only deal with binary class problems!");    }        // Holds a mapping into the original array of attribute indices    int[] origIndices = new int[data.numAttributes()];    for (int i = 0; i < origIndices.length; i++) {      if (data.attribute(i).isNominal() && 	  (data.attribute(i).numValues() != 2)) {	throw new Exception("All nominal attributes must be binary!");      }      origIndices[i] = i;    }        // We need to repeat the following loop until we've computed    // a weight for every attribute (excluding the class).    m_attScores = new double[data.numAttributes() - 1];    Instances trainCopy = new Instances(data);    for (int i = 0; i < m_attScores.length; i++) {            // Build the linear SVM with default parameters      SMO smo = new SMO();      smo.buildClassifier(trainCopy);      // Find the attribute with maximum weight^2      FastVector weightsAndIndices = smo.weights();      double[] weightsSparse = (double[])weightsAndIndices.elementAt(0);      int[] indicesSparse = (int[])weightsAndIndices.elementAt(1);      double[] weights = new double[trainCopy.numAttributes()];      for (int j = 0; j < weightsSparse.length; j++) {	if (indicesSparse[j] == trainCopy.classIndex()) {	  weights[indicesSparse[j]] = -Double.MAX_VALUE;	} else {	  weights[indicesSparse[j]] = weightsSparse[j] * 	    weightsSparse[j];	}      }      int maxWeightIndex = Utils.maxIndex(weights);      m_attScores[origIndices[maxWeightIndex]] = weights[maxWeightIndex];            // Delete the best attribute.       AttributeFilter delTransform = new AttributeFilter();      delTransform.setInvertSelection(false);      int[] featArray = new int[1];      featArray[0] = maxWeightIndex;      delTransform.setAttributeIndicesArray(featArray);      delTransform.setInputFormat(trainCopy);      trainCopy = Filter.useFilter(trainCopy, delTransform);            // Update the array of indices      int[] temp = new int[origIndices.length - 1];      System.arraycopy(origIndices, 0, temp, 0, maxWeightIndex);      for (int j = maxWeightIndex + 1; j < origIndices.length; j++) {	temp[j - 1] = origIndices[j];      }      origIndices = temp;    }  }