Added documentation for trigger demo

This commit is contained in:
2023-03-06 10:21:39 +08:00
parent c944b5dfcf
commit 726ef535ea
14 changed files with 91 additions and 29 deletions
+4 -4
View File
@@ -13,14 +13,14 @@ enum Backend_Type {
BACKEND_MariaDB
};
struct Config{
struct Config {
int running, new_query, server_mode,
backend_type, has_dll, n_buffers;
int buffer_sizes[];
};
struct Session{
struct Statistic{
struct Session {
struct Statistic {
unsigned long long total_active;
unsigned long long cnt_object;
unsigned long long total_alloc;
@@ -102,7 +102,7 @@ namespace std {
}
#endif
struct vectortype_storage{
struct vectortype_storage {
void* container = nullptr;
unsigned int size = 0, capacity = 0;
vectortype_storage(void* container, unsigned int size, unsigned int capacity) :
+20 -3
View File
@@ -19,7 +19,7 @@ DecisionTree *dt = nullptr;
RandomForest *rf = nullptr;
__AQEXPORT__(bool)
newtree(int ntree, long f, ColRef<int> sparse, double forget, long maxf, long nclasses, Evaluation e)
newtree(int ntree, long f, ColRef<int> sparse, double forget, long nclasses, Evaluation e)
{
if (sparse.size != f)
return false;
@@ -27,8 +27,6 @@ newtree(int ntree, long f, ColRef<int> sparse, double forget, long maxf, long nc
memcpy(X_cpy, sparse.container, f);
if (maxf < 0)
maxf = f;
// dt = new DecisionTree(f, X_cpy, forget, maxf, noclasses, e);
rf = new RandomForest(ntree, f, X_cpy, forget, nclasses, e, true);
return true;
@@ -100,3 +98,22 @@ predict(vector_type<vector_type<double>> v)
auto ret = vectortype_cstorage{.container = container, .size = 1, .capacity = 0};
return ret;
}
template <typename T>
constexpr T sq(const T x) {
return x * x;
}
__AQEXPORT__(double)
test(vector_type<vector_type<double>> x, vector_type<long> y) {
int result = 0;
printf("y_hat = (");
double err = 0.;
for (uint32_t i = 0; i < x.size; i++) {
//result[i] = dt->Test(v.container[i].container, dt->DTree);
result = int(rf->Test(x[i].container));
err += sq(result - y.container[i]);
printf("%d ", result);
}
puts(")");
printf("error: %lf\n", err/=double(x.size));
return err;
}