-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
103 lines (81 loc) · 3.35 KB
/
main.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
from data_description import DataDescription
from data_input import DataInput
from imputation import Imputation
from download import Download
from categorical import Categorical
from feature_scaling import FeatureScaling
class Preprocessor:
bold_start = "\033[1m"
bold_end = "\033[0;0m"
# The Task associated with this class. This is also the main class of the project.
tasks = [
'1. Data Description',
'2. Handling NULL Values',
'3. Encoding Categorical Data',
'4. Feature Scaling of the Dataset',
'5. Download the modified dataset'
]
data = 0
def __init__(self):
self.data = DataInput().inputFunction()
print("\n\n" + self.bold_start + "WELCOME TO THE MACHINE LEARNING PREPROCESSOR CLI!!!\N{grinning face}" + self.bold_end + "\n\n")
# function to remove the target column of the DataFrame.
def removeTargetColumn(self):
print("Columns\U0001F447\n")
for column in self.data.columns.values:
print(column, end = " ")
while(1):
column = input("\nWhich is the target variable:(Press -1 to exit) ").lower()
if column == "-1":
exit()
choice = input("Are you sure?(y/n) ")
if choice=="y" or choice=="Y":
try:
self.data.drop([column], axis = 1, inplace = True)
except KeyError:
print("No column present with this name. Try again......\U0001F974")
continue
print("Done.......\U0001F601")
break
else:
print("Try again with the correct column name...\U0001F974")
return
def printData(self):
print(self.data)
# main function of the Preprocessor class.
def preprocessorMain(self):
self.removeTargetColumn()
while(1):
print("\nTasks (Preprocessing)\U0001F447\n")
for task in self.tasks:
print(task)
while(1):
try:
choice = int(input("\nWhat do you want to do? (Press -1 to exit): "))
except ValueError:
print("Integer Value required. Try again.....\U0001F974")
continue
break
if choice == -1:
exit()
# moves the control into the DataDescription class.
elif choice==1:
DataDescription(self.data).describe()
# moves the control into the Imputation class.
elif choice==2:
self.data = Imputation(self.data).imputer()
# moves the control into the Categorical class.
elif choice==3:
self.data = Categorical(self.data).categoricalMain()
# moves the control into the FeatureScaling class.
elif choice==4:
self.data = FeatureScaling(self.data).scaling()
# moves the control into the Download class.
elif choice==5:
Download(self.data).download()
else:
print("\nWrong Integer value!! Try again..\U0001F974")
# obj is the object of our Preprocessor class(main class).
obj = Preprocessor()
# the object 'obj' calls the main function of our Preprocessor class.
obj.preprocessorMain()