-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain_Window.py
196 lines (128 loc) · 5.66 KB
/
Main_Window.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
196
from PyQt5.QtWidgets import (QMainWindow, QTextEdit,
QAction, QFileDialog, QApplication)
from PyQt5.QtGui import QIcon
import sys
from sklearn.base import TransformerMixin
import pandas as pd
from test2 import Ui_MainWindow
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.textEdit = QTextEdit()
self.setCentralWidget(self.textEdit)
self.statusBar()
openFile = QAction(QIcon('open.png'), 'Open', self)
openFile.setShortcut('Ctrl+O')
openFile.setStatusTip('Open new File')
openFile.triggered.connect(self.openWindow)
saveFile = QAction(QIcon('open.png'), 'Save', self)
saveFile.setShortcut('Ctrl+S')
saveFile.setStatusTip('Save File')
saveFile.triggered.connect(self.getCSV)
saveAsFile = QAction(QIcon('open.png'), 'Save as', self)
saveAsFile.setStatusTip('Save File')
saveAsFile.triggered.connect(self.getCSV)
Exit = QAction(QIcon('open.png'), 'Exit', self)
Exit.setStatusTip('Save File')
Exit.triggered.connect(self.getCSV)
Impute = QAction(QIcon('open.png'), 'Missing data', self)
Impute.setStatusTip('Save File')
Impute.triggered.connect(self.imputer)
Normalize = QAction(QIcon('open.png'), 'Normalize', self)
Normalize.setStatusTip('Save File')
Normalize.triggered.connect(self.getCSV)
Bar = QAction(QIcon('open.png'), 'Bar plot', self)
Bar.setStatusTip('Save File')
Bar.triggered.connect(self.getCSV)
Scatter = QAction(QIcon('open.png'), 'Scatter plot', self)
Scatter.setStatusTip('Save File')
Scatter.triggered.connect(self.getCSV)
Box = QAction(QIcon('open.png'), 'Box plot', self)
Box.setStatusTip('Gives Box plot representation of data')
Box.triggered.connect(self.getCSV)
loReg = QAction(QIcon('open.png'), 'Logistic Regression', self)
loReg.setStatusTip('Gives Box plot representation of data')
loReg.triggered.connect(self.getCSV)
SVM = QAction(QIcon('open.png'), 'SVM', self)
SVM.setStatusTip('Gives Box plot representation of data')
SVM.triggered.connect(self.getCSV)
Rf= QAction(QIcon('open.png'), 'Random Forest', self)
Rf.setStatusTip('Gives Box plot representation of data')
Rf.triggered.connect(self.getCSV)
Dt= QAction(QIcon('open.png'), 'Decision Tree', self)
Dt.setStatusTip('Gives Box plot representation of data')
Dt.triggered.connect(self.getCSV)
Knn= QAction(QIcon('open.png'), 'KNN', self)
Knn.setStatusTip('Gives Box plot representation of data')
Knn.triggered.connect(self.getCSV)
ts= QAction(QIcon('open.png'), 'Test split', self)
ts.setStatusTip('Gives Box plot representation of data')
ts.triggered.connect(self.getCSV)
oh= QAction(QIcon('open.png'), 'One hot encoding', self)
oh.setStatusTip('Encodes categorical data')
oh.triggered.connect(self.getCSV)
lh= QAction(QIcon('open.png'), 'Label Encoding', self)
lh.setStatusTip('Encodes categorical data')
lh.triggered.connect(self.labelEncoder)
menubar = self.menuBar()
menubar.setNativeMenuBar(False)
fileMenu = menubar.addMenu('&File')
preprocess = menubar.addMenu('&Preprocessing')
EDA = menubar.addMenu('&EDA')
Tsp = menubar.addMenu('&Test split')
Model = menubar.addMenu('Model')
fileMenu.addAction(openFile)
fileMenu.addAction(saveFile)
fileMenu.addAction(saveAsFile)
fileMenu.addAction(Exit)
# preprocess.addAction(Encode)
preprocess.addAction(oh)
preprocess.addAction(lh)
preprocess.addAction(Impute)
preprocess.addAction(Normalize)
EDA.addAction(Bar)
EDA.addAction(Scatter)
EDA.addAction(Box)
EDA.addAction(Bar)
Model.addAction(loReg)
Model.addAction(SVM)
Model.addAction(Rf)
Model.addAction(Dt)
Model.addAction(Knn)
Model.addAction(ts)
self.setGeometry(300, 300, 350, 300)
self.setWindowTitle('File dialog')
self.show()
def getCSV(self):
filePath, _ = QFileDialog.getOpenFileName(self, 'Open file', '/home')
if filePath != "":
print ("Dirección",filePath) #Opcional imprimir la dirección del archivo
self.df = pd.read_csv(str(filePath))
print(self.df.describe())
def labelEncoder(self):
self.obj_df = self.df.select_dtypes(include=['object']).copy()
for col in self.obj_df:
self.obj_df[str(col)] = self.obj_df[str(col)].astype('category')
self.obj_df[str(col)] = self.obj_df[str(col)].cat.codes
for element in self.df:
for c in self.obj_df:
if(element == c):
self.df[str(element)] = self.obj_df[str(c)]
print(self.df.head())
def openWindow(self):
self.w = QMainWindow()
self.w = Ui_MainWindow
self.w.setupUi(self)
self.w.show()
self.w.exec_()
def imputer():
imputer = preprocessing.Imputer(missing_values='NaN', strategy='most_frequent', axis=0)
self.df = imputer.fit_transform(df)
print(self.df.head())
joblib.dump(imputer, 'imputer.pkl')
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())