/** * Build the no-split node * * @param instances an <code>Instances</code> value * @exception Exception if an error occurs */ public final void buildClassifier(Instances instances) throws Exception { m_nb = new NaiveBayesUpdateable(); m_disc = new Discretize(); m_disc.setInputFormat(instances); Instances temp = Filter.useFilter(instances, m_disc); m_nb.buildClassifier(temp); if (temp.numInstances() >= 5) { m_errors = crossValidate(m_nb, temp, new Random(1)); } m_numSubsets = 1; }
/** * Return a textual description of the node * * @return a <code>String</code> value */ public String toString() { return m_nb.toString(); }
/** * Return the probability for a class value * * @param classIndex the index of the class value * @param instance the instance to generate a probability for * @param theSubset the subset to consider * @return a probability * @exception Exception if an error occurs */ public double classProb(int classIndex, Instance instance, int theSubset) throws Exception { m_disc.input(instance); Instance temp = m_disc.output(); return m_nb.distributionForInstance(temp)[classIndex]; }