| 13 | } |
| 14 | |
| 15 | int 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 | |
| 34 | int MindfulnessClassifier::release () |
| 35 | { |
nothing calls this directly
no outgoing calls
no test coverage detected