Skip to content

Commit e69959b

Browse files
Corrigi o construtor das MRFTrees
1 parent 09f3bd7 commit e69959b

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

ProjetoAMC/src/Classifier.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ public double Classify(int[] amostra) { // cada classe (por ex. benigno) e repr
4949

5050
for (int c=0; c < odds.size(); c++) {
5151
if (odds.get(c) == Collections.max(odds)) {
52-
return Dataset2.ClassValuesList.get(c); //não faz sentido
52+
//return Dataset2.ClassValuesList.get(c); n�o faz sentido
53+
5354
}
5455
}
55-
56+
return -1.0;
5657
}
5758

5859
}

ProjetoAMC/src/MRFTree.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,24 @@ public MRFTree(Tree arvore, Dataset tfiber) {
3232
d++;
3333
}
3434

35+
// TODO aumentar eficiencia
3536
// adicionamos uma matriz com os valores de phi(xi,xj) a cada aresta da nova arvore
3637
for (int i = 0; i < n; i++) { // for aresta in arvore
37-
// TODO trocar para apenas as arestas da arvore dada
3838
for (int j = 0; j < n; j++) {
39-
markovtree.Add(i, j, phi(i,j));
40-
int[] a = new int[2];
41-
a[0] = i;
42-
a[1] = j;
43-
E.add(a);
39+
if (arvore.EdgeQ(i, j)) {
40+
markovtree.Add(i, j, phi(i,j));
41+
int[] a = new int[2];
42+
a[0] = i;
43+
a[1] = j;
44+
E.add(a);
45+
}
4446
}
4547
}
4648
}
49+
50+
public int getDatabaseSize() {
51+
return m;
52+
}
4753

4854
public double[][] phi(int i, int j) { // calculo do phi
4955
double[][] phiv = new double[n][n];
@@ -70,7 +76,6 @@ public double[][] phi(int i, int j) { // calculo do phi
7076
return phiv;
7177
}
7278

73-
// TODO
7479
// Prob: dado um vetor de dados 𝑥1, ... , 𝑥( retorna a probabilidade destes dados no dataset.
7580
public double prob(int[] v) {
7681
double r;

ProjetoAMC/src/Main.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ public static void main(String[] args) {
5252
dataeg2.print();
5353

5454

55-
/*
5655

57-
ArrayList<int[]> fibra2 = dataset2.Fiber(1);
5856

57+
//ArrayList<int[]> fibra2 = dataeg2.Fiber(1);
5958

60-
WeightedGraph grafo = new WeightedGraph(10);
59+
60+
//WeightedGraph grafo = new WeightedGraph(10);
6161
// adicionar pesos ao grafico
62-
Tree maximal = grafo.MST();
62+
//Tree maximal = grafo.MST();
6363
ArrayList<MRFTree> listamrft= new ArrayList<MRFTree>(2);
6464

6565
for (int i = 0; i < 2; i++) {
66-
MRFTree markov = new MRFTree(maximal, dataset2.Fiber(i));
67-
listamrft.add(markov);
66+
//MRFTree markov = new MRFTree(maximal, dataset2.Fiber(i));
67+
//listamrft.add(markov);
6868
}
6969

7070
//Classifier classificador = new Classifier(listamrft, classfreq); */

0 commit comments

Comments
 (0)