diff --git a/prompt.py b/prompt.py index 8a00dcc..6883198 100644 --- a/prompt.py +++ b/prompt.py @@ -542,8 +542,8 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None): state.stats.need_print = True state.stats.print(clear = False) continue - trimed = ws.sub(' ', q.lower()).split(' ') - if trimed[0].startswith('f'): + trimed = ws.sub(' ', og_q).split(' ') + if trimed[0].lower().startswith('f'): fn = 'stock.a' if len(trimed) <= 1 or len(trimed[1]) == 0 \ else trimed[1] try: diff --git a/sdk/Makefile b/sdk/Makefile index 166386b..7bd5c8c 100644 --- a/sdk/Makefile +++ b/sdk/Makefile @@ -1,4 +1,5 @@ example: $(CXX) -shared -fPIC example.cpp aquery_mem.cpp -fno-semantic-interposition -Ofast -march=native -flto --std=c++1z -o ../test.so - +irf: + $(CXX) -shared -fPIC RF.cpp irf.cpp incrementalDecisionTree.cpp aquery_mem.cpp Evaluation.cpp -fno-semantic-interposition -Ofast -march=native -flto --std=c++1z -o ../libirf.so all: example diff --git a/sdk/incrementalDecisionTree.cpp b/sdk/incrementalDecisionTree.cpp index 47560be..29431cb 100644 --- a/sdk/incrementalDecisionTree.cpp +++ b/sdk/incrementalDecisionTree.cpp @@ -7,7 +7,10 @@ #include #include #include +#include +std::random_device rd; +std::mt19937 g(rd()); struct minEval{ double value; int* values; @@ -54,7 +57,7 @@ long* Rands(long feature, long maxFeature){ if(maxFeature==feature){ return ret; } - std::random_shuffle(ret, &ret[feature]); + std::shuffle(ret, &ret[feature], g); long* ret2 = (long*) malloc(maxFeature*sizeof(long)); for(i=0; isize; i++){ index[i] = i; } - std::random_shuffle(index, index+current->size); + std::shuffle(index, index+current->size, g); long x = 0; for(i=0;isize;i++){ if(i>=current->size-forgetSize){ diff --git a/sdk/irf.cpp b/sdk/irf.cpp index 8089c9f..8433c95 100644 --- a/sdk/irf.cpp +++ b/sdk/irf.cpp @@ -33,6 +33,7 @@ __AQEXPORT__(bool) additem(ColRefX, long y, long size){ data[pt][j]=X.container[j]; } result[pt] = y; + pt ++; return 1; } __AQEXPORT__(bool) fit(){ @@ -46,8 +47,8 @@ __AQEXPORT__(ColRef_storage) predict(){ for(long i=0; iTest(data[i], dt->DTree); } - ColRef_storage ret(result, pt, pt, "prediction", 0); - return ret; + + return ColRef_storage(new ColRef_storage(result, pt, 0, "prediction", 0), 1, 0, "prediction", 0); } diff --git a/tests/.modules.a.swp b/tests/.modules.a.swp deleted file mode 100644 index 0618208..0000000 Binary files a/tests/.modules.a.swp and /dev/null differ diff --git a/tests/dt.a b/tests/dt.a index af851e6..55dc8fb 100644 --- a/tests/dt.a +++ b/tests/dt.a @@ -1,14 +1,11 @@ LOAD MODULE FROM "./libirf.so" FUNCTIONS ( - mydiv(a:int, b:int) -> double, - mulvec(a:int, b:vecfloat) -> vecfloat, - newtree(height:int, f:int64, sparse:vecint, forget:double, maxF:int64, noClasses:int64, e:int, r:int64, rb:int64) -> bool, + newtree(height:int, f:int64, sparse:vecint, forget:double, maxf:int64, noclasses:int64, e:int, r:int64, rb:int64) -> bool, additem(X:vecdouble, y:int64, size:int64) -> bool, fit() -> bool, predict() -> vecint ); -select mydiv(2,3); create table tb(x int); create table tb2(x double, y double, z double); insert into tb values (0); @@ -22,4 +19,4 @@ select additem(tb2.x, 1, 3) from tb2; select additem(tb2.y, 0, -1) from tb2; select additem(tb2.z, 1, -1) from tb2; select fit(); -select predict(); \ No newline at end of file +select predict(); diff --git a/tests/modules.a b/tests/modules.a index 8fd61a0..89b8ee8 100644 --- a/tests/modules.a +++ b/tests/modules.a @@ -1,22 +1,8 @@ -LOAD MODULE FROM "./libirf.so" +LOAD MODULE FROM "./test.so" FUNCTIONS ( - newtree(height:int, f:int64, sparse:vecint, forget:double, maxf:int64, noclasses:int64, e:int, r:int64, rb:int64) -> bool, - additem(X:vecdouble, y:int64, size:int64) -> bool, - fit() -> bool, - predict() -> vecint + mydiv(a:int, b:int) -> double, + mulvec(a:int, b:vecfloat) -> vecfloat ); -create table tb(x int); -create table tb2(x double, y double, z double); -insert into tb values (0); -insert into tb values (0); -insert into tb values (0); -select newtree(5, 3, tb.x, 0, 3, 2, 0, 100, 1) from tb; -insert into tb2 values (1, 0, 1); -insert into tb2 values (0, 1, 1); -insert into tb2 values (1, 1, 1); -select additem(tb2.x, 1, 3) from tb2; -select additem(tb2.y, 0, -1) from tb2; -select additem(tb2.z, 1, -1) from tb2; -select fit(); -select predict(); +select mydiv(2,3); +