43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import pandas as pd
|
|
import os
|
|
|
|
# path = os.getcwd()
|
|
|
|
# data = pd.read_csv(path + str('/data/Social_Network_Ads.csv'),
|
|
# engine='python')
|
|
# df = pd.DataFrame(data)
|
|
|
|
|
|
# train_size = int(0.75 * df.shape[0])
|
|
# test_size = int(0.25 * df.shape[0])
|
|
|
|
# print('Training set size {}, Testing set size {}'.format(train_size,
|
|
# test_size))
|
|
|
|
|
|
class bayesClassifer(object):
|
|
"""initial implmentation of a bayes classifer"""
|
|
|
|
path = os.getcwd()
|
|
|
|
def __init__(self, data_file):
|
|
super(bayesClassifer, self).__init__()
|
|
self.data_file = data_file
|
|
|
|
def createDataFrame(self):
|
|
return pd.read_csv(self.path + self.data_file, engine='python')
|
|
|
|
def print_debug(self):
|
|
print('{0} rows, {1} columns'.format(self.df.shape[0],
|
|
self.df.shape[1]))
|
|
print(self.df[1:7])
|
|
|
|
def trainData(dataframe):
|
|
train_size = int(0.75 * dataframe.shape[0])
|
|
test_size = int(0.25 * dataframe.shape[0])
|
|
return(train_size, test_size)
|
|
|
|
|
|
bayesClassifer('/data/Social_Network_Ads.csv')
|
|
bayesClassifer.createDataFrame()
|