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

Function write_model

src/ml/train/train_classifiers.py:23–35  ·  view source on GitHub ↗
(intercept, coefs, model_type)

Source from the content-addressed store, hash-verified

21
22
23def write_model(intercept, coefs, model_type):
24 coefficients_string = '%s' % (','.join([str(x) for x in coefs[0]]))
25 file_content = '''
26#include "%s"
27// clang-format off
28const double %s_coefficients[%d] = {%s};
29double %s_intercept = %lf;
30// clang-format on
31''' % (f'{model_type}_model.h', model_type, len(coefs[0]), coefficients_string, model_type, intercept)
32 file_name = f'{model_type}_model.cpp'
33 file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'generated', file_name)
34 with open(file_path, 'w') as f:
35 f.write(file_content)
36
37def prepare_data(first_class, second_class, blacklisted_channels=None):
38 # use different windows, its kinda data augmentation

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected