m_theInstances = data;
m_theInstances = new Instances(data); m_theInstances.deleteWithMissingClass(); if (m_theInstances.numInstances() == 0) { throw new Exception("No training instances without missing class!"); } if (m_theInstances.checkForStringAttributes()) { throw new Exception("Can't handle string attributes!"); }
  public void buildClassifier(Instances data) throws Exception  {    int i;    m_rr = new Random(1);    m_theInstances = data;        m_disTransform = new DiscretizeFilter();    if (m_theInstances.classAttribute().isNumeric())    {      m_classIsNominal = false;      // use binned discretisation if the class is numeric      m_disTransform.setUseMDL(false);      m_disTransform.setBins(10);      m_disTransform.setInvertSelection(true);             // Discretize all attributes EXCEPT the class       String rangeList = "";      rangeList+=(m_theInstances.classIndex()+1);      System.out.println("The class col: "+m_theInstances.classIndex());             m_disTransform.setAttributeIndices(rangeList);    }    else    {      m_disTransform.setUseBetterEncoding(true);      m_classIsNominal = true;    }    m_disTransform.inputFormat(m_theInstances);    m_theInstances = Filter.useFilter(m_theInstances, m_disTransform);    m_numAttributes = m_theInstances.numAttributes();    m_numInstances = m_theInstances.numInstances();    m_majority = m_theInstances.meanOrMode(m_theInstances.classAttribute());    best_first();    // reduce instances to selected features    m_delTransform = new DeleteFilter();    m_delTransform.setInvertSelection(true);    // set features to keep    m_delTransform.setAttributeIndicesArray(m_decisionFeatures);     m_delTransform.inputFormat(m_theInstances);    m_theInstances = Filter.useFilter(m_theInstances, m_delTransform);    // reset the number of attributes    m_numAttributes = m_theInstances.numAttributes();      // create hash table    m_entries = new Hashtable((int)(m_theInstances.numInstances() * 1.5));    // insert instances into the hash table    for (i=0;i<m_numInstances;i++)    {      Instance inst = m_theInstances.instance(i);      insertIntoTable(inst, null);    }    // Replace the global table majority with nearest neighbour?    if (m_useIBk)    {      m_ibk = new IBk();      m_ibk.buildClassifier(m_theInstances);    }    // Save memory    m_theInstances = new Instances(m_theInstances, 0);  }