14 for(i = 0; i < t->
n; ++i){
16 for(j = 0; j < n; ++j){
17 if (0==strcmp(t->
name[i], leaves[j])){
24 fprintf(stderr,
"Found %d leaves.\n", found);
40 for(j = 0; j < n; ++j){
41 int parent = hier->
parent[j];
43 predictions[j*stride] *= predictions[parent*stride];
47 for(j = 0; j < n; ++j){
48 if(!hier->
leaf[j]) predictions[j*stride] = 0;
64 float val = predictions[(i + hier->
group_offset[group])*stride];
72 group = hier->
child[max_i];
73 if(hier->
child[max_i] < 0)
return max_i;
74 }
else if (group == 0){
86 FILE *fp = fopen(filename,
"r");
93 while((line=
fgetl(fp)) != 0){
94 char *
id = calloc(256,
sizeof(
char));
96 sscanf(line,
"%s %d",
id, &parent);
100 t.
child = realloc(t.
child, (n+1)*
sizeof(
int));
103 t.
name = realloc(t.
name, (n+1)*
sizeof(
char *));
105 if(parent != last_parent){
112 last_parent = parent;
114 t.
group = realloc(t.
group, (n+1)*
sizeof(
int));
117 t.
child[parent] = groups;
129 t.
leaf = calloc(n,
sizeof(
int));
131 for(i = 0; i < n; ++i) t.
leaf[i] = 1;
135 tree *tree_ptr = calloc(1,
sizeof(
tree));
int hierarchy_top_prediction(float *predictions, tree *hier, float thresh, int stride)
void ** list_to_array(list *l)
void hierarchy_predictions(float *predictions, int n, tree *hier, int only_leaves, int stride)
void change_leaves(tree *t, char *leaf_list)
tree * read_tree(char *filename)
list * get_paths(char *filename)
float get_hierarchy_probability(float *x, tree *hier, int c, int stride)