forked from yareddada/CS431-Data-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_module.py
195 lines (175 loc) · 6.83 KB
/
main_module.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
"""
Module: main_module
Purpose: Compute regressions of data values given, plot the data values,
and then display a graph of their plot values
Last Edited By: Joey S. Amalei (Sat. 12/2/2017)
CS431-01
Fall 2017
"""
"""
Import required modules
"""
import csv_parser as parser
import plotter
import regression_analyzer as reg
import sys
import os
import time
"""
QUICK RUN - SINGLE GRAPH ONLY TO DISPLAY
Handle Command Line Argument Index locations
[1] - Input data file path
[2] - What regression graph to display
[3] - Output figure image file name
"""
# Any commmand line arguments passed?
if (len(sys.argv) > 1):
# Clear console screen - 'cls' for Windows / 'clear' Linux & Mac OSX
os.system('cls')
# Welcome Title Program Screen Text
print("====================================")
print(" GROUP 2 - REGRESSION SOFTWARE")
print(" CS431-01")
print(" Fall 2017")
print("====================================")
print()
"""
LOOP 1 - Process available command line arguments
"""
inputFilePath = sys.argv[1]
"""
Plot and draw the raw input data values onto figure window
"""
rawDataValues = parser.parse(inputFilePath)
plotter.drawGraph(rawDataValues, 'scatter')
# What regression graph to display?
if (sys.argv[2] == 'linear'):
linearRegressionDataValues = reg.linearRegression(parser.parse(inputFilePath))
plotter.drawGraph(linearRegressionDataValues, 'line')
elif (sys.argv[2] == 'exponential'):
exponentialRegressionDataValues = reg.exponentialRegression(parser.parse(inputFilePath))
plotter.drawGraph(exponentialRegressionDataValues, 'line')
else:
quadraticRegressionDataValues = reg.quadraticRegression(parser.parse(inputFilePath))
plotter.drawGraph(quadraticRegressionDataValues, 'line')
# Display drawn plotted graph onto window
plotter.displayGraph(sys.argv[3])
else:
"""
LOOP 2 - Enter an infinite loop for user input interaction on console window
"""
# Clear console screen - 'cls' for Windows / 'clear' Linux & Mac OSX
os.system('cls')
# Welcome Title Program Screen Text
print("====================================")
print(" GROUP 2 - REGRESSION SOFTWARE")
print(" CS431-01")
print(" Fall 2017")
print("====================================")
print()
print()
"""
USER INPUT #1
"""
inputFilePath = input("Enter data file path (include .csv - file extension): ")
graphTitle = input("Enter the title name of the graph: ")
xLabel = input("Enter the name of the x-axis for the graph: ")
yLabel = input("Enter the name of the y-axis for the graph: ")
"""
Plot and draw the raw input data values onto figure window
"""
rawDataValues = parser.parse(inputFilePath)
plotter.drawGraph(rawDataValues, 'scatter')
# Request user what regression to plot and draw on figure
done = False
while (done != True):
# Clear console screen - 'cls' for Windows / 'clear' Linux & Mac OSX
os.system('cls')
"""
USER INPUT #2
"""
# What does the user want to do?
print("===================================================")
print(" SELECT REGRESSION GRAPH OPTIONS TO DRAW ON FIGURE")
print()
print(" 1 - Linear Regression")
print(" 2 - Exponential Regression")
print(" 3 - Quadratic Regression")
print()
print(" 4 - Exit sub-menu and display figure on screen")
print("===================================================")
print()
# Process user selection of options
menuOptionValue = input("Enter a number as your option of choice: ")
if (menuOptionValue == '1'):
linearRegressionDataValues = reg.linearRegression(parser.parse(inputFilePath))
plotter.drawGraph(linearRegressionDataValues, 'line')
print()
print("===================================================")
print(" DRAWING GRAPH ON FIGURE WINDOW NOW...")
print(" Returning back to sub-menu")
print(" for more options to select...")
print("===================================================")
time.sleep(3)
elif (menuOptionValue == '2'):
exponentialRegressionDataValues = reg.exponentialRegression(parser.parse(inputFilePath))
plotter.drawGraph(exponentialRegressionDataValues, 'line')
print("===================================================")
print(" DRAWING GRAPH ON FIGURE WINDOW NOW...")
print(" Returning back to sub-menu")
print(" for more options to select...")
print("===================================================")
time.sleep(3)
elif (menuOptionValue == '3'):
quadraticRegressionDataValues = reg.quadraticRegression(parser.parse(inputFilePath))
plotter.drawGraph(quadraticRegressionDataValues, 'line')
print("===================================================")
print(" DRAWING GRAPH ON FIGURE WINDOW NOW...")
print(" Returning back to sub-menu")
print(" for more options to select...")
print("===================================================")
time.sleep(3)
elif (menuOptionValue == '4'):
print("===================================================")
print(" EXITING SUB-MENU NOW...")
print()
print(" Will now prepare figure window to be displayed...")
print("===================================================")
time.sleep(3)
done = True
else:
print("That option is not acceptable. Please try again.")
time.sleep(5)
"""
USER INPUT #3
"""
# Clear console screen - 'cls' for Windows / 'clear' Linux & Mac OSX
os.system('cls')
# Display Heading Text
print("====================================")
print(" CREATION OF FIGURE IMAGE FILE")
print(" IN .PNG FILE EXTENSION")
print("====================================")
print()
# Request user for output file name
outputFileName = input("Enter figure image file name (include .png - file extension): ")
# Display user's plotted graph on window
plotter.setGraphLabels(graphTitle, xLabel, yLabel)
plotter.displayGraph(outputFileName)
"""
Display Exit Message
"""
# Clear console screen - 'cls' for Windows / 'clear' Linux & Mac OSX
os.system('cls')
print("===================================================")
print(" THANK YOU FOR USING THE REGRESSION SOFTWARE!")
print()
print(" CREDITS TO:")
print(" Gabrielson Aguilar")
print(" Claudette Aguon")
print(" Joey Amalei")
print(" Jason Bacani")
print(" Jose-Peter Charfauros")
print()
print(" CS431-01 | Fall 2017")
print("===================================================")