throw new Exception ("Only instances of one class "+ "or no instances in the data!");
if ((m_iUp == -1) && (m_iLow == -1)) { throw new Exception ("No instances without missing class values!"); } else { if (m_iUp == -1) { m_b = 1; } else { m_b = -1; } return; }
  public void buildClassifier(Instances insts) throws Exception {    int m_kernelEvals = 0;    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!");    }    m_data = insts;    m_onlyNumeric = true;    for (int i = 0; i < m_data.numAttributes(); i++) {      if (i != m_data.classIndex()) {	if (!m_data.attribute(i).isNumeric()) {	  m_onlyNumeric = false;	  break;	}      }    }    m_Missing = new ReplaceMissingValuesFilter();    m_Missing.inputFormat(m_data);    m_data = Filter.useFilter(m_data, m_Missing);     if (!m_dontNormalize) {      m_Normalization = new NormalizationFilter();      m_Normalization.inputFormat(m_data);      m_data = Filter.useFilter(m_data, m_Normalization);     }    if (!m_onlyNumeric) {      m_NominalToBinary = new NominalToBinaryFilter();      m_NominalToBinary.inputFormat(m_data);      m_data = Filter.useFilter(m_data, m_NominalToBinary);    }    // If machine is linear, reserve space for weights    if (m_exponent == 1.0) {      m_weights = new double[m_data.numAttributes()];    }    // Set class values    m_class = new double[m_data.numInstances()];    m_iUp = -1; m_iLow = -1;    for (int i = 0; i < m_class.length; i++) {      if ((int) m_data.instance(i).classValue() == 0) {	m_class[i] = -1; m_iLow = i;      } else {	m_class[i] = 1; m_iUp = i;      }    }    if ((m_iUp == -1) || (m_iLow == -1)) {      throw new Exception ("Only instances of one class "+			   "or no instances in the data!");    }    // Initialize alpha array to zero    m_alpha = new double[m_data.numInstances()];    // Initialize thresholds    m_bUp = -1; m_bLow = 1; m_b = 0;    // Initialize error cache    m_errors = new double[m_data.numInstances()];    m_errors[m_iLow] = 1; m_errors[m_iUp] = -1;    // Initialize sets    m_supportVectors = new SMOset(m_data.numInstances());    m_I0 = new SMOset(m_data.numInstances());    m_I1 = new SMOset(m_data.numInstances());    m_I2 = new SMOset(m_data.numInstances());    m_I3 = new SMOset(m_data.numInstances());    m_I4 = new SMOset(m_data.numInstances());    // The kernel calculations are cached    m_storage = new double[m_cacheSize];    m_keys = new int[m_cacheSize];    // Build up I1 and I4    for (int i = 0; i < m_class.length; i++ ) {      if (m_class[i] == 1) {	m_I1.insert(i);      } else {	m_I4.insert(i);      }    }    // Loop to find all the support vectors    int numChanged = 0;    boolean examineAll = true;    while ((numChanged > 0) || examineAll) {      numChanged = 0;      if (examineAll) {	for (int i = 0; i < m_alpha.length; i++) {	  if (examineExample(i)) {	    numChanged++;	  }	}      } else {	// This code implements Modification 1 from Keerthi et al.'s paper	for (int i = 0; i < m_alpha.length; i++) {	  if ((m_alpha[i] > 0) &&  (m_alpha[i] < m_C)) {	    if (examineExample(i)) {	      numChanged++;	    }	    	    // Is optimality on unbound vectors obtained?	    if (m_bUp > m_bLow - 2 * m_tol) {	      numChanged = 0;	      break;	    }	  }	}		//This is the code for Modification 2 from Keerthi et al.'s paper	/*boolean innerLoopSuccess = true; 	numChanged = 0;	while ((m_bUp < m_bLow - 2 * m_tol) && (innerLoopSuccess == true)) {	  innerLoopSuccess = takeStep(m_iUp, m_iLow, m_errors[m_iLow]);	  }*/      }      if (examineAll) {	examineAll = false;      } else if (numChanged == 0) {	examineAll = true;      }    }        // Set threshold    m_b = (m_bLow + m_bUp) / 2.0;    // Save memory    m_storage = null; m_keys = null; m_errors = null;    m_I0 = m_I1 = m_I2 = m_I3 = m_I4 = null;    // If machine is linear, delete training data    if (m_exponent == 1.0) {      m_data = new Instances(m_data, 0);    }  }