bug
This commit is contained in:
committed by
root
parent
d5382c36e9
commit
259d9ef566
+1
-2
@@ -5,14 +5,13 @@
|
||||
|
||||
struct minEval{
|
||||
double value;
|
||||
double values;
|
||||
int* values;
|
||||
|
||||
double eval;
|
||||
long left; // how many on its left
|
||||
double* record;
|
||||
long max;
|
||||
long** count;
|
||||
long* sorted; // sorted d
|
||||
};
|
||||
|
||||
minEval giniSparse(double** data, long* result, long* d, long size, long col, long classes, long* totalT){
|
||||
|
||||
+16
-26
@@ -4,9 +4,6 @@
|
||||
#include "../server/table.h"
|
||||
|
||||
DecisionTree* dt = nullptr;
|
||||
long pt = 0;
|
||||
double** data = nullptr;
|
||||
long* result = nullptr;
|
||||
|
||||
__AQEXPORT__(bool) newtree(int height, long f, ColRef<int> sparse, double forget, long maxf, long noclasses, Evaluation e, long r, long rb){
|
||||
if(sparse.size!=f)return 0;
|
||||
@@ -19,36 +16,29 @@ __AQEXPORT__(bool) newtree(int height, long f, ColRef<int> sparse, double forget
|
||||
return 1;
|
||||
}
|
||||
|
||||
__AQEXPORT__(bool) additem(ColRef<double>X, long y, long size){
|
||||
long j = 0;
|
||||
if(size>0){
|
||||
free(data);
|
||||
free(result);
|
||||
pt = 0;
|
||||
data=(double**)malloc(size*sizeof(double*));
|
||||
result=(long*)malloc(size*sizeof(long));
|
||||
__AQEXPORT__(bool) fit(ColRef<ColRef<double>> X, ColRef<int> y){
|
||||
if(X.size != y.size)return 0;
|
||||
double** data = (double**)malloc(X.size*sizeof(double*));
|
||||
long* result = (long*)malloc(y.size*sizeof(long));
|
||||
for(long i=0; i<X.size; i++){
|
||||
data[i] = X.container[i].container;
|
||||
result[i] = y.container[i];
|
||||
}
|
||||
data[pt] = (double*)malloc(X.size*sizeof(double));
|
||||
for(j=0; j<X.size; j++){
|
||||
data[pt][j]=X.container[j];
|
||||
}
|
||||
result[pt] = y;
|
||||
pt ++;
|
||||
return 1;
|
||||
}
|
||||
__AQEXPORT__(bool) fit(){
|
||||
if(pt<=0)return 0;
|
||||
dt->fit(data, result, pt);
|
||||
dt->fit(data, result, X.size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
__AQEXPORT__(ColRef_storage) predict(){
|
||||
int* result = (int*)malloc(pt*sizeof(int));
|
||||
for(long i=0; i<pt; i++){
|
||||
__AQEXPORT__(ColRef_storage) predict(ColRef<ColRef<double>> X){
|
||||
double** data = (double**)malloc(X.size*sizeof(double*));
|
||||
int* result = (int*)malloc(X.size*sizeof(int));
|
||||
for(long i=0; i<X.size; i++){
|
||||
data[i] = X.container[i].container;
|
||||
}
|
||||
for(long i=0; i<X.size; i++){
|
||||
result[i]=dt->Test(data[i], dt->DTree);
|
||||
}
|
||||
|
||||
return ColRef_storage(new ColRef_storage(result, pt, 0, "prediction", 0), 1, 0, "prediction", 0);
|
||||
return ColRef_storage(new ColRef_storage(result, X.size, 0, "prediction", 0), 1, 0, "prediction", 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user