Ejemplo n.º 1
0
void tryadd(node *p, node **item, node **nufork)
{
  /* temporarily adds one fork and one tip to the tree.
     if the location where they are added yields greater
     "likelihood" than other locations tested up to that
     time, then keeps that location as there */
  long pos;
  boolean found;

  add(p, *item, *nufork, &root, treenode);
  evaluate(root);
  if (lastrearr) {
    if (like >= bstlike2) {
      savetree();
      if (like > bstlike2) {
        bestlike = bstlike2 = like;
        pos = 1;
        nextree = 1;
        dollop_addtree(&pos);
      } else {
        pos = 0;
        findtree(&found, &pos, nextree, place, bestrees);
                /* findtree calls for a bestelm* but is getting */
                /* a long**, LM                                 */
        if (!found) {
          if (nextree <= maxtrees)
            dollop_addtree(&pos);
        }
      }
    }
  }
  if (like > bestyet) {
    bestyet = like;
    there = p;
  }
  re_move(item, nufork, &root, treenode);
}  /* tryadd */
int main(){
	value val[TRAIN_N];
	FILE* ftree=fopen("tree", "rb");
	FILE* fval=fopen("val", "rb");
	dicisiontree tree;
	FILE* finfo=fopen("fsubinfo", "rb");
	float subinfo[MAX_ATTR_NUM][MAX_ATTR_VAL];
	
	readsubinfo(subinfo, finfo);
	fclose(finfo);
	
	readtree(&tree, ftree);
	readvalb(val, fval, TRAIN_N);

	makesubtree(subinfo, val, &tree);
	
	fclose(ftree);
	fclose(fval);
	ftree=fopen("tree", "wb");
	savetree(&tree, ftree);
	fclose(ftree);

	return 0;
}