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:-

Matlabsolutions.com 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

SEE COMPLETE ANSWER CLICK THE LINK

--

--

--

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.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Build Custom Ecommerce websites from Scratch using Django Framework

Things you need to start doing before graduating a coding bootcamp

鬼灭之刃剧场版:无限列车篇 完整版本 [Demon Slayer: Kimetsu no Yaiba] 完整版觀看電影在線小鴨 (2020-HD)完整的電影

Best Project Management Software For Architects

Graphics of Project Management Software For Architects

How to install Strapi v4 with MySQL 8 (part 2)

HoodMapper — My Own Hackathon

DevOps series — Part 3

Effective Use of Optionals in Java

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.

More from Medium

GPU Out of memory on device.

How to Display Stylist Bar-chart in Python(Matplotlib)

Using Sqlite with Python

Paradigms of various LSTM Networks

LSTM