bravotty / DataMining_NaiveBayes

An Implementation of NaiveBayes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DataMining_NaiveBayes

auc License

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

About

An Implementation of NaiveBayes

License:MIT License


Languages

Language:Python 100.0%