-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
100 lines (71 loc) · 1.99 KB
/
run.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
import os
import warnings
from mlclassification.dataset import Dataset
from mlclassification.classifier import Classifier
# Dataset
dataset = None
# Classifier
classifier = None
def board():
"""
Simple menu
"""
global classifier
# Check if dataset is loaded
if dataset is None:
load_dataset()
# Classifier
classifier = Classifier(dataset)
while True:
# Print parent menu
print '1. Compare accuracies'
print '2. Show the scatter plot'
print '3. Output'
usr_raw = raw_input('Select : ')
if usr_raw == '1':
# Print sub menu
print '1. k-nearest neighbors'
print '2. Decision tree'
print '3. Naive Bayes'
print '4. Linear Regression'
print '5. Logistic Regression'
print '6. All'
# Create array
usr_choice = raw_input('Select : ')
usr_choice = [int(x) for x in usr_choice.split(',')]
classifier.compare(usr_choice)
elif usr_raw == '2':
# Display scatter plot
classifier.scatter()
elif usr_raw == '3':
# Write data into file
# Filename
usr_choice = raw_input('Filename : ')
dataset.write(usr_choice)
else:
break
def load_dataset():
"""
Select dataset and load it
"""
global dataset
# Array of csv files
files = []
for value in os.listdir(os.path.abspath('data')):
if value.endswith('.csv'):
files.append(value)
# Show files
for index, file in enumerate(files):
print '{0}. {1}'.format(index + 1, file)
# Dataset
dataset = Dataset({'name': raw_input('Filename (with extension) : ')})
def main():
"""
Start point
"""
# Ignore some warnings
warnings.filterwarnings(action="ignore", module="scipy", message="^internal gelsd")
# Show menu
board()
main()