diff options
Diffstat (limited to 'source/tb_ml/tb_mh.h')
| -rw-r--r-- | source/tb_ml/tb_mh.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source/tb_ml/tb_mh.h b/source/tb_ml/tb_mh.h new file mode 100644 index 0000000..91e1e7b --- /dev/null +++ b/source/tb_ml/tb_mh.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | #ifndef TB_ML_H | ||
| 2 | #define TB_ML_H | ||
| 3 | |||
| 4 | |||
| 5 | //- supervised learning model by abdellah el morabit | ||
| 6 | //- from <math.h> | ||
| 7 | #define M_E 2.7182818284590452354 /* e */ | ||
| 8 | |||
| 9 | typedef struct training_sample trainig_sample; | ||
| 10 | struct training_sample | ||
| 11 | { | ||
| 12 | |||
| 13 | }; | ||
| 14 | |||
| 15 | typedef struct prediction_data predicition_data; | ||
| 16 | struct prediction_data | ||
| 17 | { | ||
| 18 | f32 w; | ||
| 19 | f32 y; | ||
| 20 | }; | ||
| 21 | |||
| 22 | |||
| 23 | typedef struct prediction_category prediction_category; | ||
| 24 | struct category | ||
| 25 | { | ||
| 26 | string8 name; | ||
| 27 | predicition_data data; | ||
| 28 | }; | ||
| 29 | |||
| 30 | f(f32 d) { | ||
| 31 | return d * d; | ||
| 32 | } | ||
| 33 | |||
| 34 | internal f32 | ||
| 35 | derivative(f32 x, f32 (*f)(f32)) { | ||
| 36 | |||
| 37 | f32 h = 1e-6; // small interval to differnetiate the scope | ||
| 38 | return (f(x + h) - f(x - h)) / (2.0 * h); | ||
| 39 | } | ||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | #endif | ||
