2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
* Copyright (C) 2004 University of Waikato, Hamilton, New Zealand
22
package weka.classifiers.bayes.net.search.fixed;
24
import weka.classifiers.bayes.BayesNet;
25
import weka.classifiers.bayes.net.search.SearchAlgorithm;
26
import weka.core.Instances;
29
<!-- globalinfo-start -->
30
* The NaiveBayes class generates a fixed Bayes network structure with arrows from the class variable to each of the attribute variables.
32
<!-- globalinfo-end -->
34
<!-- options-start -->
37
* @author Remco Bouckaert
38
* @version $Revision: 1.5 $
40
public class NaiveBayes
41
extends SearchAlgorithm {
43
/** for serialization */
44
static final long serialVersionUID = -4808572519709755811L;
47
* Returns a string describing this object
48
* @return a description of the classifier suitable for
49
* displaying in the explorer/experimenter gui
51
public String globalInfo() {
53
"The NaiveBayes class generates a fixed Bayes network structure "
54
+ "with arrows from the class variable to each of the attribute "
61
* @param instances the instances to work with
62
* @throws Exception if something goes wrong
64
public void buildStructure (BayesNet bayesNet, Instances instances) throws Exception {
65
for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
66
if (iAttribute != instances.classIndex()) {
67
bayesNet.getParentSet(iAttribute).addParent(instances.classIndex(), instances);