Skip to content

Commit 897eb23

Browse files
Update README documentation with info on how to test model.
1 parent a79fdaf commit 897eb23

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,31 @@ source code.
119119
By default, the MakeCode project prints debug data via serial.
120120
To disable this feature, set the `ML_DEBUG_PRINT` flag to `0`.
121121

122+
## Testing the model with known data
123+
124+
A special mode has been included to test the filters and model output.
125+
This mode can be triggered by changing a define flag in the source code and
126+
including a couple of test files with accelerometer samples, expected filter
127+
and model results, and a model blob to test.
128+
129+
The results are printed to serial and nothing else runs on the device. So, it
130+
is designed for one-off tests for validation and debugging.
131+
132+
To run the tests:
133+
- Obtain the `autogenerate.ts` and `modeltest/testdata.h` files under test and
134+
replace the versions already present in this reporistory.
135+
- You can copy the files from within the `modeltest/testdatax/` folders
136+
- Or create new ones using the `ml4f-output` npm script within the
137+
[CreateAI](https://github.com/microbit-foundation/ml-trainer) project
138+
- If you have a `main.ts` file using the model under test, add it as well
139+
- Otherwise you might need to manually update the `main.ts` file for the
140+
actions configured in the model under test
141+
- Set the [`ML_TEST_MODEL` macro define](https://github.com/microbit-foundation/pxt-microbit-ml-runner/blob/a79fdaf51ebf221843a7be4c948f586643471991/testextension.cpp#L11)
142+
value to `1`
143+
- Build the MakeCode project locally (`npx pxt`) and flash the micro:bit
144+
- Connect a serial terminal and review the printed data
145+
146+
122147
## License
123148

124149
This software is under the MIT open source license.

mlrunner/mldataprocessor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ MldpReturn_t filterPeaks(const float *data_in, const int in_size, float *data_ou
101101
const float threshold = 3.5;
102102
const float influence = 0.5;
103103

104-
if (in_size < (5 + 2) || out_size != 1) {
104+
if (in_size < (lag + 2) || out_size != 1) {
105105
return MLDP_ERROR_CONFIG;
106106
}
107107

0 commit comments

Comments
 (0)