How to use Gamma distribution as the kernel of Naive Bayes in MATLAB code?

Here I have a group of data which following the Gamma distribution and now I want to use Naive Bayes method to fit this data. I tried the original function named ‘fitcnb’ and knowing that it providing 4 types of distribution: ‘box’, ‘epanechnikov’, ‘normal’ and ‘triangle’. Now I want to revise this fitcnb function through adding Gamma distribution kernel into its original code. But I’m not sure how to implement that, can anyone give me some hint or example code?

Many thanks for that.

NOTE:- provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

If your features follow a Gamma distribution you should be fine just using the ‘normal’ smoothing Kernel. To provide some intuition the Kernel prior is using a Kernel smoothing function to approximate the distribution of the features from the discrete data. You can think of it as trying to drop a table-cloth over the histogram to smooth out the jumps the histogram creates.

To illustrate this, let’s sample from a Gamma distribution

dataSamp = gamrnd(9,0.5,1e5,1); % Gamma Samples.
histogram(dataSamp,'Normalization','pdf') % Visualize pdf

Fit a Kernel distribution (tablecloth) with the restriction that the support is positive (as is the case with the Gamma distribution).

dist = fitdist(dataSamp,'kernel','Kernel','normal','Support','positive');

Evaluate the pdf of the distribution and plot on the histogram

xVals = linspace(0,15,1000); % x Values to evaluate the pdf
yFit = pdf(dist,xVals); % pdf values at each xVals
hold on
plot(xVals,yFit,'LineWidth',2) % Plot the fitted pdf.
hold off

This is exactly what is happening in fitcnb when you use the same calls




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.