fixed user module (dt)

This commit is contained in:
2022-10-07 14:39:17 +08:00
parent 6467bc6964
commit 988bf0158e
7 changed files with 19 additions and 31 deletions
+2 -1
View File
@@ -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
+5 -2
View File
@@ -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
View File
@@ -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);
}