forked from UTSAVS26/PyVerse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
poker_hand_prediction.py
57 lines (38 loc) · 1.46 KB
/
poker_hand_prediction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'''
Contains things common to all models implemented here; such as imports, configs, etc.
'''
# -------------------- Imports -------------------- #
import numpy as np, pandas as pd, os
from prettytable import PrettyTable
# -------------------- Globals and Configs -------------------- #
feature_names = list()
for index in range(1, 6):
feature_names.extend(["Suit"+str(index), "Rank"+str(index)])
feature_names.append('class')
training_input_file = os.path.abspath('../datasets/csv/train.csv')
testing_input_file = os.path.abspath('../datasets/csv/test.csv')
np.random.seed(666) # seed for reproducible results
# To store configs
class myConfigs:
features = 0
classes = 0
config = myConfigs()
# -------------------- Data -------------------- #
train_data = pd.read_csv(training_input_file, names=feature_names)
test_data = pd.read_csv(testing_input_file, names=feature_names)
# Get features of data
config.features = len(train_data.columns) - 1
config.classes = len(set(train_data['class']))
# Shuffle training data
train_data = train_data.sample(frac=1).reset_index(drop=True)
# Seperate data and classes
train_y = np.array(train_data['class'])
train_x = np.array(train_data.drop('class', 1))
test_y = np.array(test_data['class'])
test_x = np.array(test_data.drop('class', 1))
if __name__ == '__main__':
tab = PrettyTable(['Config', 'Value'])
configs = vars(config)
for key in configs:
tab.add_row([key, configs[key]])
print(tab)