bayes_functions.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /******************************************************************************
  2. * @file bayes_functions.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  6. * Target Processor: Cortex-M and Cortex-A cores
  7. ******************************************************************************/
  8. /*
  9. * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
  10. *
  11. * SPDX-License-Identifier: Apache-2.0
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the License); you may
  14. * not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. #ifndef _BAYES_FUNCTIONS_H_
  26. #define _BAYES_FUNCTIONS_H_
  27. #include "arm_math_types.h"
  28. #include "arm_math_memory.h"
  29. #include "dsp/none.h"
  30. #include "dsp/utils.h"
  31. #include "dsp/statistics_functions.h"
  32. /**
  33. * @defgroup groupBayes Bayesian estimators
  34. *
  35. * Implement the naive gaussian Bayes estimator.
  36. * The training must be done from scikit-learn.
  37. *
  38. * The parameters can be easily
  39. * generated from the scikit-learn object. Some examples are given in
  40. * DSP/Testing/PatternGeneration/Bayes.py
  41. */
  42. #ifdef __cplusplus
  43. extern "C"
  44. {
  45. #endif
  46. /**
  47. * @brief Instance structure for Naive Gaussian Bayesian estimator.
  48. */
  49. typedef struct
  50. {
  51. uint32_t vectorDimension; /**< Dimension of vector space */
  52. uint32_t numberOfClasses; /**< Number of different classes */
  53. const float32_t *theta; /**< Mean values for the Gaussians */
  54. const float32_t *sigma; /**< Variances for the Gaussians */
  55. const float32_t *classPriors; /**< Class prior probabilities */
  56. float32_t epsilon; /**< Additive value to variances */
  57. } arm_gaussian_naive_bayes_instance_f32;
  58. /**
  59. * @brief Naive Gaussian Bayesian Estimator
  60. *
  61. * @param[in] S points to a naive bayes instance structure
  62. * @param[in] in points to the elements of the input vector.
  63. * @param[out] *pOutputProbabilities points to a buffer of length numberOfClasses containing estimated probabilities
  64. * @param[out] *pBufferB points to a temporary buffer of length numberOfClasses
  65. * @return The predicted class
  66. *
  67. */
  68. uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_instance_f32 *S,
  69. const float32_t * in,
  70. float32_t *pOutputProbabilities,
  71. float32_t *pBufferB);
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif /* ifndef _BAYES_FUNCTIONS_H_ */