MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / predict

Method predict

src/ml/mindfulness_classifier.cpp:15–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15int MindfulnessClassifier::predict (double *data, int data_len, double *output, int *output_len)
16{
17 if ((data_len < 5) || (data == NULL) || (output == NULL))
18 {
19 safe_logger (spdlog::level::err,
20 "Incorrect arguments. Null pointers or invalid feature vector size.");
21 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
22 }
23 double value = 0.0;
24 for (int i = 0; i < std::min (data_len, 5); i++)
25 {
26 value += mindfulness_coefficients[i] * data[i];
27 }
28 double mindfulness = 1.0 / (1.0 + exp (-1.0 * (mindfulness_intercept + value)));
29 *output = mindfulness;
30 *output_len = 1;
31 return (int)BrainFlowExitCodes::STATUS_OK;
32}
33
34int MindfulnessClassifier::release ()
35{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected