public static void main(String args[]) { ProblemTransformationMethod.evaluation(new BCC(), args); } }
@Override public double[] distributionForInstance(Instance x) throws Exception { int L = x.classIndex(); double y_long[] = Arrays.copyOf(super.distributionForInstance(x),L*2); Arrays.fill(y_long,L,y_long.length,1.0); return y_long; }
/** * Description to display in the GUI. * * @return the description */ @Override public String globalInfo() { return "Bayesian Classifier Chains (BCC).\n" + "Creates a maximum spanning tree based on marginal label dependence. Then employs CC.\n" + "For more information see:\n" + getTechnicalInformation().toString(); }
@Override public void buildClassifier(Instances D) throws Exception { testCapabilities(D); m_R = new Random(getSeed()); int L = D.classIndex(); int d = D.numAttributes()-L; if (getDebug()) System.out.println("Get unconditional dependencies ..."); double CD[][] = null; if (m_DependencyType.equals("L")) { if (getDebug()) System.out.println("The 'LEAD' method for finding conditional dependence."); CD = StatUtils.LEAD(D,getClassifier(),m_R); if (getDebug()) System.out.println("The Frequency method for finding marginal dependence."); CD = StatUtils.margDepMatrix(D,m_DependencyType); if (getDebug()) System.out.println(MatrixUtils.toString(CD)); if (getDebug()) System.out.println("Make a graph ..."); EdgeWeightedGraph G = new EdgeWeightedGraph((int)L); if (getDebug()) System.out.println("Get an MST ..."); KruskalMST mst = new KruskalMST(G); if (getDebug()) System.out.println(MatrixUtils.toString(paM));
@Override public void setOptions(String[] options) throws Exception { setDependencyType(OptionUtils.parse(options, 'X', "Ibf")); super.setOptions(options); }
@Override public String [] getOptions() { List<String> result = new ArrayList<>(); OptionUtils.add(result, 'X', getDependencyType()); OptionUtils.add(result, super.getOptions()); return OptionUtils.toArray(result); }
/** * Treeify - make a tree given the structure defined in paM[][], using the root-th node as root. */ private void treeify(int root, int paM[][], int paL[][], int visited[]) { int children[] = new int[]{}; for(int j = 0; j < paM[root].length; j++) { if (paM[root][j] == 1) { if (visited[j] < 0) { children = A.append(children,j); paL[j] = A.append(paL[j],root); visited[j] = visited[Utils.maxIndex(visited)] + 1; } // set as visited //paM[root][j] = 0; } } // go through again for(int child : children) { treeify(child,paM,paL,visited); } }
@Override public void buildClassifier(Instances D) throws Exception { testCapabilities(D); m_R = new Random(getSeed()); int L = D.classIndex(); int d = D.numAttributes()-L; if (getDebug()) System.out.println("Get unconditional dependencies ..."); double CD[][] = null; if (m_DependencyType.equals("L")) { if (getDebug()) System.out.println("The 'LEAD' method for finding conditional dependence."); CD = StatUtils.LEAD(D,getClassifier(),m_R); if (getDebug()) System.out.println("The Frequency method for finding marginal dependence."); CD = StatUtils.margDepMatrix(D,m_DependencyType); if (getDebug()) System.out.println(MatrixUtils.toString(CD)); if (getDebug()) System.out.println("Make a graph ..."); EdgeWeightedGraph G = new EdgeWeightedGraph((int)L); if (getDebug()) System.out.println("Get an MST ..."); KruskalMST mst = new KruskalMST(G); if (getDebug()) System.out.println(MatrixUtils.toString(paM));
@Override public void setOptions(String[] options) throws Exception { setDependencyType(OptionUtils.parse(options, 'X', "Ibf")); super.setOptions(options); }
@Override public String [] getOptions() { List<String> result = new ArrayList<>(); OptionUtils.add(result, 'X', getDependencyType()); OptionUtils.add(result, super.getOptions()); return OptionUtils.toArray(result); }
/** * Treeify - make a tree given the structure defined in paM[][], using the root-th node as root. */ private void treeify(int root, int paM[][], int paL[][], int visited[]) { int children[] = new int[]{}; for(int j = 0; j < paM[root].length; j++) { if (paM[root][j] == 1) { if (visited[j] < 0) { children = A.append(children,j); paL[j] = A.append(paL[j],root); visited[j] = visited[Utils.maxIndex(visited)] + 1; } // set as visited //paM[root][j] = 0; } } // go through again for(int child : children) { treeify(child,paM,paL,visited); } }
@Override public double[] distributionForInstance(Instance x) throws Exception { int L = x.classIndex(); double y_long[] = Arrays.copyOf(super.distributionForInstance(x),L*2); Arrays.fill(y_long,L,y_long.length,1.0); return y_long; }
public static void main(String args[]) { ProblemTransformationMethod.evaluation(new BCC(), args); } }
/** * Description to display in the GUI. * * @return the description */ @Override public String globalInfo() { return "Bayesian Classifier Chains (BCC).\n" + "Creates a maximum spanning tree based on marginal label dependence. Then employs CC.\n" + "For more information see:\n" + getTechnicalInformation().toString(); }