forked from DawsonVaal/NormalizationProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (33 loc) · 1.15 KB
/
Copy pathmain.py
File metadata and controls
46 lines (33 loc) · 1.15 KB
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
import csv
myDict = {}
with open('auto-mpg.csv', mode='r') as read_obj:
reader = csv.reader(read_obj)
dataAsRows = list(reader)
def mainMenu():
print(dataAsRows[askUserInput()])
print(dataAsRows[askUserInput()])
def askUserInput():
print("Please enter the index of the dataset you wish to compare (1-90): ")
Index = int(input("Enter number : "))
while True:
if Index >= 1 and Index <= 90:
return Index
else:
print("That was an invalid number, please re-enter (1-90): ")
Index = int(input("Enter number : "))
def normalize_data(data, min, max):
normal_column = []
for i in range(len(data)):
new_value = round((data[i] - min) / (max - min), 2)
normal_column.append(new_value)
return normal_column
if __name__ == '__main__':
open('auto-mpg.csv')
normalized_data = []
for j in range(0,4):
columnList = []
for i in range(1, len(dataAsRows)):
columnList.append(int(dataAsRows[i][j]))
normalized_data.append(normalize_data(columnList, min(columnList), max(columnList)))
print(normalized_data)
mainMenu()