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

Function predict

src/ml/ml_module.cpp:83–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83int predict (double *data, int data_len, double *output, int *output_len, const char *json_params)
84{
85 std::lock_guard<std::mutex> lock (models_mutex);
86 struct BrainFlowModelParams key (
87 (int)BrainFlowMetrics::MINDFULNESS, (int)BrainFlowClassifiers::DEFAULT_CLASSIFIER);
88 BaseClassifier::ml_logger->trace ("(Predict)Incoming json: {}", json_params);
89 int res = string_to_brainflow_model_params (json_params, &key);
90 if (res != (int)BrainFlowExitCodes::STATUS_OK)
91 {
92 return res;
93 }
94 auto model = ml_models.find (key);
95 if (model == ml_models.end ())
96 {
97 BaseClassifier::ml_logger->error ("Must prepare model before using it for prediction.");
98 return (int)BrainFlowExitCodes::CLASSIFIER_IS_NOT_PREPARED_ERROR;
99 }
100 return model->second->predict (data, data_len, output, output_len);
101}
102
103int release (const char *json_params)
104{

Callers 2

predictMethod · 0.50
predictMethod · 0.50

Calls 2

predictMethod · 0.65

Tested by

no test coverage detected