Classifier cModel = (Classifier)new NaiveBayes(); cModel.buildClassifier(isTrainingSet); weka.core.SerializationHelper.write("/some/where/nBayes.model", cModel); Classifier cls = (Classifier) weka.core.SerializationHelper.read("/some/where/nBayes.model"); // Test the model Evaluation eTest = new Evaluation(isTrainingSet); eTest.evaluateModel(cls, isTrainingSet);
/** * Main method for testing this class. * * @param argv the options */ public static void main(String[] argv) { runClassifier(new BayesNet(), argv); } // main
/** * Set whether supervised discretization is to be used. * * @param newblah true if supervised discretization is to be used. */ public void setUseSupervisedDiscretization(boolean newblah) { m_UseDiscretization = newblah; if (newblah) { setUseKernelEstimator(false); } }
/** * Main method for testing this class. * * @param argv the options */ public static void main(String[] argv) { runClassifier(new NaiveBayes(), argv); } }
/** * Main method for testing this class. * * @param argv the options */ public static void main(String [] argv) { runClassifier(new NaiveBayesUpdateable(), argv); } }
/** * Main method for testing this class. * * @param args the options */ public static void main(String[] args) { runClassifier(new NaiveBayesMultinomialText(), args); } }
/** * Main method for testing this class. * * @param argv the options */ public static void main(String [] argv) { runClassifier(new NaiveBayesMultinomialUpdateable(), argv); } }
/** * Main method for testing this class. * * @param argv the options */ public static void main(String [] argv) { runClassifier(new NaiveBayesMultinomial(), argv); } }
/** * Return a textual description of the node * * @return a <code>String</code> value */ public String toString() { return m_nb.toString(); }
/** * Returns a BayesNet graph in XMLBIF ver 0.3 format. * * @return String representing this BayesNet in XMLBIF ver 0.3 * @throws Exception in case BIF generation fails */ @Override public String graph() throws Exception { return toXMLBIF03(); }
int getCPT(int[] nodeSet, int nNodes, int[] values, int[] order, BayesNet bayesNet) { int iCPTnew = 0; for (int iNode = 0; iNode < nNodes; iNode++) { int nNode = nodeSet[iNode]; iCPTnew = iCPTnew * bayesNet.getCardinality(nNode); iCPTnew += values[order[nNode]]; } return iCPTnew; } // getCPT
/** * Returns an instance of a TechnicalInformation object, containing * detailed information about the technical background of this class, * e.g., paper reference or book this class is based on. * * @return the technical information about this class */ public TechnicalInformation getTechnicalInformation() { return super.getTechnicalInformation(); }
/** * Sets if kernel estimator is to be used. * * @param v Value to assign to m_UseKernelEstimatory. */ public void setUseKernelEstimator(boolean v) { m_UseKernelEstimator = v; if (v) { setUseSupervisedDiscretization(false); } }
/** * Updates the classifier with the given instance. * * @param instance the new training instance to include in the model * @throws Exception if the instance could not be incorporated in the model. */ @Override public void updateClassifier(Instance instance) throws Exception { updateClassifier(instance, true); }
/** * Main method for testing this class. * * @param argv the options */ public static void main(String[] argv) { runClassifier(new NaiveBayes(), argv); } }
/** * Main method for testing this class. * * @param args the options */ public static void main(String[] args) { runClassifier(new NaiveBayesMultinomialText(), args); } }
/** * Set whether supervised discretization is to be used. * * @param newblah true if supervised discretization is to be used. */ public void setUseSupervisedDiscretization(boolean newblah) { m_UseDiscretization = newblah; if (newblah) { setUseKernelEstimator(false); } }
/** * Return a textual description of the node * * @return a <code>String</code> value */ public String toString() { return m_nb.toString(); }
/** * Returns a BayesNet graph in XMLBIF ver 0.3 format. * * @return String representing this BayesNet in XMLBIF ver 0.3 * @throws Exception in case BIF generation fails */ @Override public String graph() throws Exception { return toXMLBIF03(); }
int getCPT(int[] nodeSet, int nNodes, int[] values, int[] order, BayesNet bayesNet) { int iCPTnew = 0; for (int iNode = 0; iNode < nNodes; iNode++) { int nNode = nodeSet[iNode]; iCPTnew = iCPTnew * bayesNet.getCardinality(nNode); iCPTnew += values[order[nNode]]; } return iCPTnew; } // getCPT