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 
26 
27 #ifndef _BAYES_FUNCTIONS_H_
28 #define _BAYES_FUNCTIONS_H_
29 
30 #include "arm_math_types.h"
31 #include "arm_math_memory.h"
32 
33 #include "dsp/none.h"
34 #include "dsp/utils.h"
35 
36 #include "dsp/statistics_functions.h"
37 
38 /**
39  * @defgroup groupBayes Bayesian estimators
40  *
41  * Implement the naive gaussian Bayes estimator.
42  * The training must be done from scikit-learn.
43  *
44  * The parameters can be easily
45  * generated from the scikit-learn object. Some examples are given in
46  * DSP/Testing/PatternGeneration/Bayes.py
47  */
48 
49 #ifdef   __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 /**
55  * @brief Instance structure for Naive Gaussian Bayesian estimator.
56  */
57 typedef struct
58 {
59   uint32_t vectorDimension;  /**< Dimension of vector space */
60   uint32_t numberOfClasses;  /**< Number of different classes  */
61   const float32_t *theta;          /**< Mean values for the Gaussians */
62   const float32_t *sigma;          /**< Variances for the Gaussians */
63   const float32_t *classPriors;    /**< Class prior probabilities */
64   float32_t epsilon;         /**< Additive value to variances */
65 } arm_gaussian_naive_bayes_instance_f32;
66 
67 /**
68  * @brief Naive Gaussian Bayesian Estimator
69  *
70  * @param[in]  S                        points to a naive bayes instance structure
71  * @param[in]  in                       points to the elements of the input vector.
72  * @param[out] *pOutputProbabilities    points to a buffer of length numberOfClasses containing estimated probabilities
73  * @param[out] *pBufferB                points to a temporary buffer of length numberOfClasses
74  * @return The predicted class
75  *
76  */
77 
78 
79 uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_instance_f32 *S,
80    const float32_t * in,
81    float32_t *pOutputProbabilities,
82    float32_t *pBufferB);
83 
84 
85 #ifdef   __cplusplus
86 }
87 #endif
88 
89 #endif /* ifndef _BAYES_FUNCTIONS_H_ */
90