当前位置: 首页>>代码示例>>Java>>正文


Java BayesNet.getNrOfNodes方法代码示例

本文整理汇总了Java中weka.classifiers.bayes.BayesNet.getNrOfNodes方法的典型用法代码示例。如果您正苦于以下问题:Java BayesNet.getNrOfNodes方法的具体用法?Java BayesNet.getNrOfNodes怎么用?Java BayesNet.getNrOfNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weka.classifiers.bayes.BayesNet的用法示例。


在下文中一共展示了BayesNet.getNrOfNodes方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calcFullMargins

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
public void calcFullMargins(BayesNet bayesNet) throws Exception {
  // System.out.println(bayesNet.toString());
  int nNodes = bayesNet.getNrOfNodes();
  boolean[][] bAdjacencyMatrix = new boolean[nNodes][nNodes];
  for (int iNode = 0; iNode < nNodes; iNode++) {
    for (int iNode2 = 0; iNode2 < nNodes; iNode2++) {
      bAdjacencyMatrix[iNode][iNode2] = true;
    }
  }
  process(bAdjacencyMatrix, bayesNet);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:12,代码来源:MarginCalculator.java

示例2: moralize

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/**
 * moralize DAG and calculate adjacency matrix representation for a Bayes
 * Network, effecively converting the directed acyclic graph to an undirected
 * graph.
 * 
 * @param bayesNet Bayes Network to process
 * @return adjacencies in boolean matrix format
 */
public boolean[][] moralize(BayesNet bayesNet) {
  int nNodes = bayesNet.getNrOfNodes();
  boolean[][] bAdjacencyMatrix = new boolean[nNodes][nNodes];
  for (int iNode = 0; iNode < nNodes; iNode++) {
    ParentSet parents = bayesNet.getParentSets()[iNode];
    moralizeNode(parents, iNode, bAdjacencyMatrix);
  }
  return bAdjacencyMatrix;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:18,代码来源:MarginCalculator.java

示例3: copyParentSets

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/**
 * CopyParentSets copies parent sets of source to dest BayesNet
 * 
 * @param dest destination network
 * @param source source network
 */
void copyParentSets(BayesNet dest, BayesNet source) {
  int nNodes = source.getNrOfNodes();
  // clear parent set first
  for (int iNode = 0; iNode < nNodes; iNode++) {
    dest.getParentSet(iNode).copy(source.getParentSet(iNode));
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:14,代码来源:SimulatedAnnealing.java

示例4: copyParentSets

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/**
 * copyParentSets copies parent sets of source to dest BayesNet
 * 
 * @param dest destination network
 * @param source source network
 */
void copyParentSets(BayesNet dest, BayesNet source) {
  int nNodes = source.getNrOfNodes();
  // clear parent set first
  for (int iNode = 0; iNode < nNodes; iNode++) {
    dest.getParentSet(iNode).copy(source.getParentSet(iNode));
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:14,代码来源:TabuSearch.java

示例5: buildStructure

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/**
 * buildStructure determines the network structure/graph of the network. The
 * default behavior is creating a network where all nodes have the first node
 * as its parent (i.e., a BayesNet that behaves like a naive Bayes
 * classifier). This method can be overridden by derived classes to restrict
 * the class of network structures that are acceptable.
 * 
 * @param bayesNet the network
 * @param instances the data to use
 * @throws Exception if something goes wrong
 */
public void buildStructure(BayesNet bayesNet, Instances instances)
  throws Exception {
  if (m_sInitalBIFFile != null && !m_sInitalBIFFile.equals("")) {
    BIFReader initialNet = new BIFReader().processFile(m_sInitalBIFFile);
    for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
      int iNode = initialNet.getNode(bayesNet.getNodeName(iAttribute));
      for (int iParent = 0; iParent < initialNet.getNrOfParents(iAttribute); iParent++) {
        String sParent = initialNet.getNodeName(initialNet.getParent(iNode,
          iParent));
        int nParent = 0;
        while (nParent < bayesNet.getNrOfNodes()
          && !bayesNet.getNodeName(nParent).equals(sParent)) {
          nParent++;
        }
        if (nParent < bayesNet.getNrOfNodes()) {
          bayesNet.getParentSet(iAttribute).addParent(nParent, instances);
        } else {
          System.err
            .println("Warning: Node "
              + sParent
              + " is ignored. It is found in initial network but not in data set.");
        }
      }
    }
  } else if (m_bInitAsNaiveBayes) {
    int iClass = instances.classIndex();
    // initialize parent sets to have arrow from classifier node to
    // each of the other nodes
    for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
      if (iAttribute != iClass) {
        bayesNet.getParentSet(iAttribute).addParent(iClass, instances);
      }
    }
  }
  search(bayesNet, instances);
  if (m_bMarkovBlanketClassifier) {
    doMarkovBlanketCorrection(bayesNet, instances);
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:51,代码来源:SearchAlgorithm.java

示例6: calcFullMargins

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
public void calcFullMargins(BayesNet bayesNet) throws Exception {
	//System.out.println(bayesNet.toString());
	int nNodes = bayesNet.getNrOfNodes();
	boolean[][] bAdjacencyMatrix = new boolean[nNodes][nNodes];
	for (int iNode = 0; iNode < nNodes; iNode++) {
		for (int iNode2 = 0; iNode2 < nNodes; iNode2++) {
			bAdjacencyMatrix[iNode][iNode2] = true;
		}
	}
	process(bAdjacencyMatrix, bayesNet);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:12,代码来源:MarginCalculator.java

示例7: moralize

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/**
 * moralize DAG and calculate
 * adjacency matrix representation for a Bayes Network, effecively
 * converting the directed acyclic graph to an undirected graph.
 * 
 * @param bayesNet
 *            Bayes Network to process
 * @return adjacencies in boolean matrix format
 */
public boolean[][] moralize(BayesNet bayesNet) {
	int nNodes = bayesNet.getNrOfNodes();
	boolean[][] bAdjacencyMatrix = new boolean[nNodes][nNodes];
	for (int iNode = 0; iNode < nNodes; iNode++) {
		ParentSet parents = bayesNet.getParentSets()[iNode];
		moralizeNode(parents, iNode, bAdjacencyMatrix);
	}
	return bAdjacencyMatrix;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:19,代码来源:MarginCalculator.java

示例8: copyParentSets

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/** CopyParentSets copies parent sets of source to dest BayesNet
 * @param dest destination network
 * @param source source network
 */
void copyParentSets(BayesNet dest, BayesNet source) {
	int nNodes = source.getNrOfNodes();
	// clear parent set first
	for (int iNode = 0; iNode < nNodes; iNode++) {
		dest.getParentSet(iNode).copy(source.getParentSet(iNode));
	}		
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:12,代码来源:SimulatedAnnealing.java

示例9: copyParentSets

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/** 
 * copyParentSets copies parent sets of source to dest BayesNet
 * 
 * @param dest destination network
 * @param source source network
 */
void copyParentSets(BayesNet dest, BayesNet source) {
	int nNodes = source.getNrOfNodes();
	// clear parent set first
	for (int iNode = 0; iNode < nNodes; iNode++) {
		dest.getParentSet(iNode).copy(source.getParentSet(iNode));
	}		
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:14,代码来源:TabuSearch.java

示例10: copyParentSets

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/** copyParentSets copies parent sets of source to dest BayesNet
 * @param dest destination network
 * @param source source network
 */
void copyParentSets(BayesNet dest, BayesNet source) {
	int nNodes = source.getNrOfNodes();
	// clear parent set first
	for (int iNode = 0; iNode < nNodes; iNode++) {
		dest.getParentSet(iNode).copy(source.getParentSet(iNode));
	}		
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:12,代码来源:GeneticSearch.java

示例11: buildStructure

import weka.classifiers.bayes.BayesNet; //导入方法依赖的package包/类
/**
 * buildStructure determines the network structure/graph of the network.
 * The default behavior is creating a network where all nodes have the first
 * node as its parent (i.e., a BayesNet that behaves like a naive Bayes classifier).
 * This method can be overridden by derived classes to restrict the class
 * of network structures that are acceptable.
 * 
 * @param bayesNet the network
 * @param instances the data to use
 * @throws Exception if something goes wrong
 */
public void buildStructure(BayesNet bayesNet, Instances instances) throws Exception {
	if (m_sInitalBIFFile != null && !m_sInitalBIFFile.equals("")) {
		BIFReader initialNet = new BIFReader().processFile(m_sInitalBIFFile);
        for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
        	int iNode = initialNet.getNode(bayesNet.getNodeName(iAttribute));
        	for (int iParent = 0; iParent < initialNet.getNrOfParents(iAttribute);iParent++) {
        		String sParent = initialNet.getNodeName(initialNet.getParent(iNode, iParent));
        		int nParent = 0;
        		while (nParent < bayesNet.getNrOfNodes() && !bayesNet.getNodeName(nParent).equals(sParent)) {
        			nParent++;
        		}
        		if (nParent< bayesNet.getNrOfNodes()) {
        			bayesNet.getParentSet(iAttribute).addParent(nParent, instances);
        		} else {
        			System.err.println("Warning: Node " + sParent + " is ignored. It is found in initial network but not in data set.");
        		}
        	}
        }
	} else if (m_bInitAsNaiveBayes) {
        int iClass = instances.classIndex();
        // initialize parent sets to have arrow from classifier node to
        // each of the other nodes
        for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
            if (iAttribute != iClass) {
                bayesNet.getParentSet(iAttribute).addParent(iClass, instances);
            }
        }
    }
    search(bayesNet, instances);
    if (m_bMarkovBlanketClassifier) {
        doMarkovBlanketCorrection(bayesNet, instances);
    }
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:45,代码来源:SearchAlgorithm.java


注:本文中的weka.classifiers.bayes.BayesNet.getNrOfNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。