# Machine Learning

- FASTCV\_API [fcvStatus](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1a39574810b4ad6914ee8613424f316283.html#_CPPv49fcvStatus) fcvSVMPredict2Classf32([fcvSVMKernelType](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1aa931937c95463d67769b4939ba2687fb.html#_CPPv416fcvSVMKernelType) kernelType, uint32\_t degree, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) gamma, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) coef0, const [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict sv, uint32\_t svLen, uint32\_t svNum, uint32\_t svStride, const [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict svCoef, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) rho, const [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict vec, uint32\_t vecNum, uint32\_t vecStride, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict confidence)

    - SVM prediction for two classes.

The function returns the confidence scores for test vectors using the equation: confidence(i) = sum\_j( svCoef[j] \* Kernel(vec\_i, sv\_j) - rho; The SVM model(svCoef, sv, rho) can be obtained using the training function of libSVM or openCV.

- Parameters:

    - - **kernelType** – kernelType options: ‘FASTCV\_SVM\_LINEAR’,’FASTCV\_SVM\_POLY’,’FASTCV\_SVM\_RBF’,’FASTCV\_SVM\_SIGMOID’. FASTCV\_SVM\_LINEAR: Kernel(xi, xj) = xi’*xj FASTCV\_SVM\_POLY: Kernel(xi, xi) = (gamma \* xi’ \* xj + coef0)^degree, (gamma&gt;0 , degree is positive integer). FASTCV\_SVM\_RBF: Kernel(xi,xj) = exp(-gamma*||xi-xj||^2), (gamma&gt;0). FASTCV\_SVM\_SIGMOID: Kernel(xi, xj) = tanh(gamma \* xi’ \* xj + coef0)
- **degree** – Parameter degree of a kernel function (FASTCV\_SVM\_POLY). **NOTE:** Degree should be positive integer.
- **gamma** – Parameter of a kernel function (FASTCV\_SVM\_POLY / FASTCV\_SVM\_RBF / FASTCV\_SVM\_SIGMOID). **NOTE:** gamma &gt; 0 for FASTCV\_SVM\_Ploy and FASTCV\_SVM\_RBF
- **coef0** – Parameter coef0 of a kernel function (FASTCV\_SVM\_LINEAR / FASTCV\_SVM\_POLY / FASTCV\_SVM\_SIGMOID).
- **sv** – Support vectors.
- **svLen** – Feature length, (support vector length = feature length).
- **svNum** – Number of support vectors.
- **svStride** – support vector stride. Stride of support vector 2D matrix (i.e., how many bytes between column 0 of row 1 and column 0 of row 2). **NOTE:** if 0, svStride is set as svLen\*sizeof(float32\_t). **WARNING:** should be multiple of 8, and at least as much as svLen if not 0.
- **svCoef** – Coefficent of support vectors, length equals to the Number of SV.
- **rho** – SVM bias.
- **vec** – Test vectors, it has same width as sv.
- **vecNum** – Number of test vectors.
- **vecStride** – Stride of test vectors. Stride of test vector 2D matrix (i.e., how many bytes between column 0 of row 1 and column 0 of row 2). **NOTE:** if 0, vecStride is set as svLen\*sizeof(float32\_t). **WARNING:** should be multiple of 8, and at least as much as svLen if not 0.
- **confidence** – Output, store confidence value of each test vector. The length is vecNum.

- Returns:

    - FASTCV\_SUCCESS upon success. Other status codes upon failure.

Last Published: Aug 30, 2024

[Previous Topic
Image transformation](https://docs.qualcomm.com/bundle/publicresource/80-79511-2/topics/image_transformation.md) [Next Topic
Mathvector operations](https://docs.qualcomm.com/bundle/publicresource/80-79511-2/topics/mathvector_operations.md)