⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bayesiannetorder.java

📁 次代码是数据挖掘软件的一个小例子
💻 JAVA
字号:
/*
Bao Jie 2002-04-02
Iowa State University
*/

package weka.classifiers;

import java.io.*;
import java.util.*;
import weka.core.*;
import weka.classifiers.BayesianNetwork;

public class BayesianNetOrder extends BayesianNetwork // for Bayesian Network using statistics of order at most k.
{  
  public void buildClassifier(Instances instances) throws Exception
  {
    if (instances.checkForStringAttributes()) {
      throw new Exception("Can't handle string attributes!");
    }
    if (instances.classAttribute().isNumeric()) {
      throw new Exception("BayesianNetFixed: Class is numeric!");
    }
    
    m_Instances = new Instances(instances, 0);
    
    // Count and register attributes
    // the last attribute is class 
  	int numAtt = m_Instances.numAttributes()-1;
  	
  	m_Att = new Attribute[numAtt];
  	Enumeration enumAtts = m_Instances.enumerateAttributes();
  	int ii = 0 ;
  	while (enumAtts.hasMoreElements()) 
  	{
	  	m_Att[ii++] = (Attribute) enumAtts.nextElement();  	  
  	}
//  Create network;
	m_Network = new int[numAtt][numAtt];
	for (int i = 0 ; i < numAtt ; i++)
		for (int j = 0 ; j < numAtt ; j++)
		{	m_Network[i][j] = 0 ; }

	SearchNetwork(m_Network,3,instances );
	saveNetwork(m_Network,numAtt,"newNet.net");
        
    // Compute Table 
	BuildTable(m_Network, instances);
  }

  /**
   * Main method for testing this class.
   *
   * @param argv the options
   */
  public static void main(String [] argv) {

    Classifier scheme;

    try {
      scheme = new BayesianNetOrder();
      System.out.println(Evaluation.evaluateModel(scheme, argv));
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -