diff options
Diffstat (limited to 'source/tb_ml/tb_ml.c')
| -rw-r--r-- | source/tb_ml/tb_ml.c | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/source/tb_ml/tb_ml.c b/source/tb_ml/tb_ml.c index cf9625a..8211a60 100644 --- a/source/tb_ml/tb_ml.c +++ b/source/tb_ml/tb_ml.c | |||
| @@ -1,20 +1,62 @@ | |||
| 1 | #define BASE_UNITY | 1 | #define BASE_IMPLEMENTATION |
| 2 | #include "../base/base_include.h" | 2 | #include "../base/base_include.h" |
| 3 | 3 | ||
| 4 | #if 0 | 4 | #ifdef BTREE_IMPLEMENTATION |
| 5 | internal void | ||
| 6 | btree_collect(btree_node *node, (void *) *keys, (void *) array *) { | ||
| 5 | 7 | ||
| 6 | #include "../third_party/btree_impl.h" | 8 | if (!n) return; |
| 9 | |||
| 10 | for (s32 index = 0; index < node->count; ++index) | ||
| 11 | { | ||
| 12 | TODO(nasr): traverse the tree to use the tree as training data | ||
| 13 | } | ||
| 14 | } | ||
| 7 | #endif | 15 | #endif |
| 8 | 16 | ||
| 9 | 17 | ||
| 18 | /** | ||
| 19 | * calculating a derviate requires a building an algebraic system | ||
| 20 | * so we do a dump approximation of what the derivative could be | ||
| 21 | * we want this to be able to normalize the data which is necessary for proper training | ||
| 22 | **/ | ||
| 23 | #if 1 | ||
| 24 | internal f32 | ||
| 25 | internal training_sample_data | ||
| 26 | normalize_training_data_btree(btree *btree) { | ||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | } | ||
| 31 | |||
| 32 | #endif | ||
| 10 | 33 | ||
| 11 | //- dataset is an implementation of the btree | ||
| 12 | 34 | ||
| 13 | int main(int c, char **v) | 35 | // using gradient descent |
| 14 | { | 36 | internal void |
| 15 | unused(c); | 37 | train(f32 *weights, b_tree, s32 learning_rate) { |
| 16 | unused(v); | 38 | |
| 39 | btree_collect(btree_node *node, (void *) *keys, (void *) array *); | ||
| 40 | |||
| 41 | for (s32 epoch = 0; epoch < learning_rate; ++epoch) | ||
| 42 | { | ||
| 43 | |||
| 44 | } | ||
| 45 | |||
| 46 | } | ||
| 47 | |||
| 48 | internal f32 | ||
| 49 | predict(f32 b1, f32 b2) { | ||
| 50 | return b1 + (b2 * log(b1)) + M_E; | ||
| 51 | } | ||
| 52 | |||
| 53 | //- dataset is an implementation of the btree | ||
| 54 | int main(void) { | ||
| 17 | 55 | ||
| 56 | for (s32 index = 0; index < 10; ++index) | ||
| 57 | { | ||
| 58 | printf("value [%4.f]\n",predict(10, 10)); | ||
| 59 | } | ||
| 18 | 60 | ||
| 19 | return 0; | 61 | return 0; |
| 20 | } | 62 | } |
