Implementation of naive Bayes classifier

We implement a program calculating the probability of a data item belonging to a certain class using Bayes' theorem:

# source_code/2/naive_bayes.py 
# A program that reads the CSV file with the data and returns # the Bayesian probability for the unknown value denoted by ? to # belong to a certain class. # An input CSV file should be of the following format: # 1. items in a row should be separated by a comma ',' # 2. the first row should be a heading - should contain a name for each # column of the data. # 3. the remaining rows should contain the data itself - rows with # complete and rows with the incomplete data. # A row with complete data is the row that has a non-empty and # non-question mark value ...

Get Data Science Algorithms in a Week now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.