m_Normalization = new NormalizationFilter(); m_Normalization.inputFormat(insts); insts = Filter.useFilter(insts, m_Normalization);
  public void buildClassifier(Instances insts) throws Exception {    int numChanged = 0;    boolean examineAll = true;    if (insts.checkForStringAttributes()) {      throw new Exception("Can't handle string attributes!");    }    if (insts.numClasses() > 2) {      throw new Exception("Can only handle two-class datasets!");    }    if (insts.classAttribute().isNumeric()) {      throw new Exception("SMO can't handle a numeric class!");    }    // Filter data    m_ReplaceMissingValues = new ReplaceMissingValuesFilter();    m_ReplaceMissingValues.inputFormat(insts);    insts = Filter.useFilter(insts, m_ReplaceMissingValues);    m_NominalToBinary = new NominalToBinaryFilter();    m_NominalToBinary.inputFormat(insts);    insts = Filter.useFilter(insts, m_NominalToBinary);    // Get support vectors    m_numSupportVectors = 0;    m_random = new Random(m_seed);    m_indices = new int[insts.numInstances()];    for (int i = 0; i < m_indices.length; i++) {      m_indices[i] = i;    }    m_class = new double[insts.numInstances()];    m_errors = new double[insts.numInstances()];    for (int i = 0; i < m_class.length; i++) {      if ((int) insts.instance(i).classValue() == 0) {	m_class[i] = -1;      } else {	m_class[i] = 1;      }    }    m_nextUnbound = new int[insts.numInstances() + 1];    for (int i = 0; i < insts.numInstances() + 1; i++) {      m_nextUnbound[i] = -1;    }    m_alpha = new double[insts.numInstances()];    m_b = 0;    m_data = insts;    while ((numChanged > 0) || examineAll) {      numChanged = 0;      if (examineAll) {	for (int i = 0; i < insts.numInstances(); i++) {	  if (examineExample(i)) {	    numChanged ++;	  }	}      } else {	for (int i = m_nextUnbound[0]; i != -1; i = m_nextUnbound[i + 1]) {	  if (m_alpha[i] < m_C) {	    if (examineExample(i)) {	      numChanged++;	    }	  }	}      }      if (examineAll) {	examineAll = false;      } else if (numChanged == 0) {	examineAll = true;      }    }  }