Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Fix issue with adding leaf to a decision tree without stats #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/forest.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ __forest_Node *Forest_NewLeaf(double predVal, char* stats) {
len++;
}
}else{
len = (int)predVal + 1;
total = 1;
len = 1;
total = 1;
n->stats = calloc(len ,sizeof(double));
n->stats[len-1] = 1;
}
Expand Down Expand Up @@ -442,7 +442,7 @@ typedef struct {
taskArgs ta;

static void classifierTask(void *id){
int tid = *(int *)id;
int tid = *(int *)id;
int resOffset = tid * FOREST_MAX_CLASSES;
int tStart = tid * ta.skip;
int tEnd = tStart + ta.skip > ta.f->len ? ta.f->len : tStart + ta.skip;
Expand All @@ -463,11 +463,11 @@ double Forest_Classify(FeatureVec fv, Forest *f, int classification) {
double results[FOREST_MAX_CLASSES][2] = {{0}};
int tids[FOREST_NUM_THREADS];
double rep = 0;

ta.res = &threadResults[0];
ta.fv = &fv;
ta.f = f;
ta.skip = (f->len + 1) / FOREST_NUM_THREADS;
ta.skip = (f->len + 1) / FOREST_NUM_THREADS;

if (classification) {
LG_DEBUG("\nclassification:");
Expand Down