Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WS-23-SAS-02
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Mutote
WS-23-SAS-02
Commits
dc54365f
Commit
dc54365f
authored
1 year ago
by
Fadi Gattoussi
Browse files
Options
Downloads
Patches
Plain Diff
Added buttons styling for training in progress and disabled fields
parent
70f980ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Main.py
+23
-14
23 additions, 14 deletions
Main.py
__pycache__/modeling.cpython-310.pyc
+0
-0
0 additions, 0 deletions
__pycache__/modeling.cpython-310.pyc
modeling.py
+1
-3
1 addition, 3 deletions
modeling.py
src/loading.gif
+0
-0
0 additions, 0 deletions
src/loading.gif
with
24 additions
and
17 deletions
Main.py
+
23
−
14
View file @
dc54365f
...
...
@@ -2,12 +2,15 @@ import sys
import
pandas
as
pd
from
PyQt6.QtCore
import
Qt
import
matplotlib
import
matplotlib.pyplot
as
plt
import
matplotlib.image
as
mpimg
from
matplotlib.backends.backend_qt5agg
import
FigureCanvasQTAgg
from
matplotlib.figure
import
Figure
import
modeling
from
PyQt6.QtGui
import
QIcon
from
PyQt6.QtGui
import
QIcon
,
QMovie
from
sklearn.model_selection
import
train_test_split
import
joblib
from
PyQt6.QtWidgets
import
(
QApplication
,
QMainWindow
,
QWidget
,
QDialog
,
QVBoxLayout
,
QGridLayout
,
QLabel
,
QPushButton
,
QLineEdit
,
QComboBox
,
QTabWidget
,
QCheckBox
)
...
...
@@ -118,11 +121,13 @@ class MainWindow(QMainWindow):
for
key
,
value
in
self
.
menu_items
.
items
():
if
value
==
field_name
:
self
.
input_fields
[
key
].
setDisabled
(
True
)
self
.
input_fields
[
key
].
setStyleSheet
(
"
background-color: grey; color: white;
"
)
def
enable_input_field
(
self
,
field_name
):
for
key
,
value
in
self
.
menu_items
.
items
():
if
value
==
field_name
:
self
.
input_fields
[
key
].
setEnabled
(
True
)
self
.
input_fields
[
key
].
setStyleSheet
(
"
background-color: white; color: black;
"
)
def
update_values
(
self
):
self
.
GUI_selections
=
{}
...
...
@@ -153,14 +158,15 @@ class MainWindow(QMainWindow):
def
create_graph
(
self
):
self
.
scatt
.
axes
.
clear
()
self
.
scatt
.
axes
.
set_title
(
"
Carats vs Price
"
)
self
.
scatt
.
axes
.
scatter
(
diamonds
[
'
carat
'
],
diamonds
[
'
price
'
],
color
=
'
red
'
,
s
=
2
,
label
=
'
carat
'
)
self
.
scatt
.
axes
.
scatter
(
self
.
GUI_selections
[
'
carat
'
],
self
.
price
,
color
=
'
blue
'
,
s
=
50
,
label
=
'
expected
'
)
# self.scatt.axes.axhline(y=self.price, color='blue', linestyle='--', label='Predicted Price')
# self.scatt.axes.axhline(x=self.GUI_selections['carat'], color='blue', linestyle='--', label='carat')
# self.scatt.legend()
print
(
"
I am error
"
)
self
.
scatt
.
axes
.
axhline
(
y
=
self
.
price
,
color
=
'
blue
'
,
linestyle
=
'
--
'
,
label
=
'
Predicted Price
'
)
try
:
self
.
scatt
.
axes
.
scatter
(
self
.
GUI_selections
[
'
carat
'
],
self
.
price
,
color
=
'
blue
'
,
s
=
50
,
label
=
'
expected
'
)
self
.
scatt
.
axes
.
axvline
(
x
=
self
.
GUI_selections
[
'
carat
'
],
color
=
'
blue
'
,
linestyle
=
'
--
'
,
label
=
'
carat
'
)
except
KeyError
:
pass
self
.
scatt
.
draw
()
def
validate_inputs
(
self
,
val
,
attribute
):
...
...
@@ -206,7 +212,6 @@ class Advanced(QMainWindow):
# ---------------
self
.
scatt
=
MplCanvas
(
self
,
width
=
6
,
height
=
4
,
dpi
=
100
)
# end graphs
self
.
graph_selector_X
=
QComboBox
(
self
)
self
.
graph_selector_Y
=
QComboBox
(
self
)
self
.
regression_model
=
QComboBox
(
self
)
...
...
@@ -223,7 +228,6 @@ class Advanced(QMainWindow):
self
.
teach
.
clicked
.
connect
(
self
.
re_train
)
self
.
plot_graph
=
QPushButton
(
'
PLOT
'
,
self
)
self
.
plot_graph
.
clicked
.
connect
(
self
.
create_graph
)
self
.
checkboxes
=
[]
# grid_layout.addWidget(QLabel("select features to include in Modelling"), 0, 0, 1, 0)
...
...
@@ -240,7 +244,6 @@ class Advanced(QMainWindow):
self
.
grid_layout
.
addWidget
(
self
.
histogram
,
0
,
0
,
1
,
4
)
self
.
grid_layout
.
addWidget
(
self
.
scatt
,
0
,
4
,
1
,
4
)
for
i
,
label
in
enumerate
(
self
.
check_labels
):
checkbox
=
QCheckBox
(
label
,
self
)
checkbox
.
setChecked
(
True
)
...
...
@@ -258,8 +261,12 @@ class Advanced(QMainWindow):
else
:
Advanced
.
Advanced_selections
[
checkbox
.
text
()]
=
True
window
.
calc
.
enable_input_field
(
checkbox
.
text
())
def
re_train
(
self
):
def
re_train
(
self
):
self
.
teach
.
setText
(
'
In progress
'
)
self
.
teach
.
setStyleSheet
(
"
background-color: red; color: white;
"
)
self
.
teach
.
repaint
()
global
diamonds
X
=
diamonds
.
copy
()
for
key
,
value
in
Advanced
.
Advanced_selections
.
items
():
...
...
@@ -268,18 +275,20 @@ class Advanced(QMainWindow):
y
=
X
[
'
price
'
]
X
=
X
.
drop
(
'
price
'
,
axis
=
1
)
X
=
MyTabs
.
numericise
(
X
)
self
.
teach
.
setEnabled
(
False
)
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
X
,
y
,
test_size
=
0.2
,
random_state
=
42
)
global
model
model
=
modeling
.
Model
(
X_train
,
X_test
,
y_train
,
y_test
,
self
.
regression_model
.
currentText
())
training
=
model
.
train
()
model
.
train
()
model
.
evaluate
()
self
.
R2
.
setText
(
f
"
R2 =
{
str
(
model
.
r2
)
}
"
)
self
.
MSE
.
setText
(
f
"
MSE =
{
str
(
model
.
mse
)
}
"
)
Advanced
.
checkboxes_changed
=
False
self
.
teach
.
setText
(
'
Re-Train
'
)
self
.
teach
.
setStyleSheet
(
"
background-color: white; color: black;
"
)
self
.
teach
.
setEnabled
(
True
)
def
create_graph
(
self
):
X
=
diamonds
[
self
.
graph_selector_X
.
currentText
()]
Y
=
diamonds
[
self
.
graph_selector_Y
.
currentText
()]
...
...
This diff is collapsed.
Click to expand it.
__pycache__/modeling.cpython-310.pyc
+
0
−
0
View file @
dc54365f
No preview for this file type
This diff is collapsed.
Click to expand it.
modeling.py
+
1
−
3
View file @
dc54365f
...
...
@@ -28,10 +28,8 @@ class Model:
self
.
model
=
RandomForestRegressor
(
random_state
=
42
,
n_estimators
=
100
)
else
:
raise
Exception
(
"
Model not implemented
"
)
self
.
model
.
fit
(
self
.
X_train
,
self
.
y_train
)
print
(
'
done
'
)
return
True
return
def
save_model
(
self
,
filename
):
dump
(
self
.
model
,
filename
)
...
...
This diff is collapsed.
Click to expand it.
src/loading.gif
0 → 100644
+
0
−
0
View file @
dc54365f
363 KiB
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment