本文整理汇总了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);
}
示例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;
}
示例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));
}
}
示例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));
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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));
}
}
示例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));
}
}
示例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));
}
}
示例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);
}
}