fixed user module (dt)
This commit is contained in:
@@ -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:
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
#include <fstream>
|
||||
#include <float.h>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
|
||||
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; i<maxFeature; i++)ret2[i] = ret[i];
|
||||
free(ret);
|
||||
@@ -473,7 +476,7 @@ void DecisionTree::IncrementalUpdate(double** data, long* result, long size, DT*
|
||||
for(i=0; i<current->size; i++){
|
||||
index[i] = i;
|
||||
}
|
||||
std::random_shuffle(index, index+current->size);
|
||||
std::shuffle(index, index+current->size, g);
|
||||
long x = 0;
|
||||
for(i=0;i<current->size;i++){
|
||||
if(i>=current->size-forgetSize){
|
||||
|
||||
+3
-2
@@ -33,6 +33,7 @@ __AQEXPORT__(bool) additem(ColRef<double>X, 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; i<pt; i++){
|
||||
result[i]=dt->Test(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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
+2
-5
@@ -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();
|
||||
select predict();
|
||||
|
||||
+5
-19
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user