001: /*
002: * This program is free software; you can redistribute it and/or modify
003: * it under the terms of the GNU General Public License as published by
004: * the Free Software Foundation; either version 2 of the License, or
005: * (at your option) any later version.
006: *
007: * This program is distributed in the hope that it will be useful,
008: * but WITHOUT ANY WARRANTY; without even the implied warranty of
009: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: * GNU General Public License for more details.
011: *
012: * You should have received a copy of the GNU General Public License
013: * along with this program; if not, write to the Free Software
014: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
015: */
016:
017: /*
018: * NaiveBayesUpdateable.java
019: * Copyright (C) 1999 University of Waikato, Hamilton, New Zealand
020: *
021: */
022:
023: package weka.classifiers.bayes;
024:
025: import weka.classifiers.UpdateableClassifier;
026: import weka.core.TechnicalInformation;
027:
028: /**
029: <!-- globalinfo-start -->
030: * Class for a Naive Bayes classifier using estimator classes. This is the updateable version of NaiveBayes.<br/>
031: * This classifier will use a default precision of 0.1 for numeric attributes when buildClassifier is called with zero training instances.<br/>
032: * <br/>
033: * For more information on Naive Bayes classifiers, see<br/>
034: * <br/>
035: * George H. John, Pat Langley: Estimating Continuous Distributions in Bayesian Classifiers. In: Eleventh Conference on Uncertainty in Artificial Intelligence, San Mateo, 338-345, 1995.
036: * <p/>
037: <!-- globalinfo-end -->
038: *
039: <!-- technical-bibtex-start -->
040: * BibTeX:
041: * <pre>
042: * @inproceedings{John1995,
043: * address = {San Mateo},
044: * author = {George H. John and Pat Langley},
045: * booktitle = {Eleventh Conference on Uncertainty in Artificial Intelligence},
046: * pages = {338-345},
047: * publisher = {Morgan Kaufmann},
048: * title = {Estimating Continuous Distributions in Bayesian Classifiers},
049: * year = {1995}
050: * }
051: * </pre>
052: * <p/>
053: <!-- technical-bibtex-end -->
054: *
055: <!-- options-start -->
056: * Valid options are: <p/>
057: *
058: * <pre> -K
059: * Use kernel density estimator rather than normal
060: * distribution for numeric attributes</pre>
061: *
062: * <pre> -D
063: * Use supervised discretization to process numeric attributes
064: * </pre>
065: *
066: <!-- options-end -->
067: *
068: * @author Len Trigg (trigg@cs.waikato.ac.nz)
069: * @author Eibe Frank (eibe@cs.waikato.ac.nz)
070: * @version $Revision: 1.9 $
071: */
072: public class NaiveBayesUpdateable extends NaiveBayes implements
073: UpdateableClassifier {
074:
075: /** for serialization */
076: static final long serialVersionUID = -5354015843807192221L;
077:
078: /**
079: * Returns a string describing this classifier
080: * @return a description of the classifier suitable for
081: * displaying in the explorer/experimenter gui
082: */
083: public String globalInfo() {
084: return "Class for a Naive Bayes classifier using estimator classes. This is the "
085: + "updateable version of NaiveBayes.\n"
086: + "This classifier will use a default precision of 0.1 for numeric attributes "
087: + "when buildClassifier is called with zero training instances.\n\n"
088: + "For more information on Naive Bayes classifiers, see\n\n"
089: + getTechnicalInformation().toString();
090: }
091:
092: /**
093: * Returns an instance of a TechnicalInformation object, containing
094: * detailed information about the technical background of this class,
095: * e.g., paper reference or book this class is based on.
096: *
097: * @return the technical information about this class
098: */
099: public TechnicalInformation getTechnicalInformation() {
100: return super .getTechnicalInformation();
101: }
102:
103: /**
104: * Set whether supervised discretization is to be used.
105: *
106: * @param newblah true if supervised discretization is to be used.
107: */
108: public void setUseSupervisedDiscretization(boolean newblah) {
109:
110: if (newblah) {
111: throw new IllegalArgumentException(
112: "Can't use discretization "
113: + "in NaiveBayesUpdateable!");
114: }
115: m_UseDiscretization = false;
116: }
117:
118: /**
119: * Main method for testing this class.
120: *
121: * @param argv the options
122: */
123: public static void main(String[] argv) {
124: runClassifier(new NaiveBayesUpdateable(), argv);
125: }
126: }
|