DataMining_NaiveBayes
![License](https://camo.githubusercontent.com/5fab2edf3816ef9fb3ebcaf6e613fa7b40ff7652ec69e5f6e7f695aa24bf5ce6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)
A python implementation of NaiveBayes
Env : Python 2.6
Usage :
python 2.6
python naiveBayes.py
Defination :
-- Use pandas DataFrame datatype to handle the NaiveBayes Model
-- mean -> dataFrame.mean()
-- variance -> dataFrame.variance()
-- comments in code file
class NaiveBayes(object):
def __init__(self, train=None, trainLabel=None):
self.train = pd.DataFrame(train)
self.labels = list(set(trainLabel))
col = len(self.train.columns)
self.train.insert(col, col, trainLabel)
self.classificationGroup = self.train.groupby(self.train.iloc[:, -1])
self.mean = self.classificationGroup.mean()
self.variance = self.classificationGroup.var()
NB = NaiveBayes(trainData, trainDataLabel)
License
The MIT License