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
47131af3
Commit
47131af3
authored
1 year ago
by
Michael Mutote
Browse files
Options
Downloads
Patches
Plain Diff
Merge remote-tracking branch 'origin/main'
# Conflicts: # training2.ipynb
parent
e45277d0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DisplayWindow.py
+102
-26
102 additions, 26 deletions
DisplayWindow.py
RegressionModel.py
+9
-12
9 additions, 12 deletions
RegressionModel.py
with
111 additions
and
38 deletions
DisplayWindow.py
+
102
−
26
View file @
47131af3
...
...
@@ -5,10 +5,27 @@ import pyqtgraph as pg
from
PyQt6.QtWidgets
import
(
QApplication
,
QMainWindow
,
QWidget
,
QVBoxLayout
,
QHBoxLayout
,
QGridLayout
,
QLabel
,
QPushButton
,
QSlider
,
QDateTimeEdit
,
QLineEdit
,
QComboBox
,
QDateEdit
)
QLineEdit
,
QComboBox
,
QDateEdit
,
QTabWidget
)
from
PyQt6.QtGui
import
QPalette
,
QColor
,
QIcon
class
MyTabs
(
QMainWindow
):
def
__init__
(
self
):
super
().
__init__
()
# Create your custom pages (e.g., TradeView and OrderView)
trade_view
=
MainWindow
()
order_view
=
Advanced
()
# Create a tab widget
tab_widget
=
QTabWidget
(
self
)
tab_widget
.
addTab
(
trade_view
,
"
Main
"
)
tab_widget
.
addTab
(
order_view
,
"
Advanced
"
)
# Set the central widget
self
.
setCentralWidget
(
tab_widget
)
class
MainWindow
(
QMainWindow
):
def
__init__
(
self
):
...
...
@@ -24,51 +41,110 @@ class MainWindow(QMainWindow):
grid_layout
=
QGridLayout
(
central_widget
)
# Create labels and input fields
self
.
labels_text
=
[
'
Date
'
,
'
Airline
'
,
'
Destination
'
,
'
Model Start Year
'
]
self
.
input_fields
=
[
QDateEdit
(
self
),
QComboBox
(
self
),
QComboBox
(
self
),
QComboBox
(
self
)]
self
.
input_fields
[
1
].
addItems
(
RegressionModel
.
airlines
)
self
.
input_fields
[
2
].
addItems
(
RegressionModel
.
destinations
)
self
.
input_fields
[
3
].
addItems
(
list
(
map
(
str
,
RegressionModel
.
model_years
)))
self
.
labels_text
=
[
'
Cut
'
,
'
Colour
'
,
'
Clarity
'
,
'
Carat
'
,
'
Depth
'
,
'
Table
'
,
'
X
'
,
'
Y
'
,
'
Z
'
]
self
.
input_fields
=
[
QComboBox
(
self
),
QComboBox
(
self
),
QComboBox
(
self
),
QLineEdit
(
self
),
QLineEdit
(
self
),
QLineEdit
(
self
),
QLineEdit
(
self
),
QLineEdit
(
self
),
QLineEdit
(
self
)]
self
.
input_fields
[
0
].
addItems
(
RegressionModel
.
cut
)
self
.
input_fields
[
1
].
addItems
(
RegressionModel
.
colors
)
self
.
input_fields
[
2
].
addItems
(
RegressionModel
.
clarity
)
# add a button to capture all the data
self
.
calculate_button
=
QPushButton
(
'
Calculate Price
'
,
self
)
self
.
calculate_button
.
clicked
.
connect
(
self
.
update_values
)
# Add labels and input fields to the grid layout
for
i
in
range
(
4
):
for
i
in
range
(
len
(
self
.
labels_text
)
):
label
=
QLabel
(
self
.
labels_text
[
i
],
self
)
grid_layout
.
addWidget
(
label
,
0
,
i
)
grid_layout
.
addWidget
(
self
.
input_fields
[
i
],
1
,
i
)
# Connect signals
for
i
in
range
(
len
(
self
.
input_fields
)):
if
i
==
0
:
self
.
input_fields
[
i
].
dateChanged
.
connect
(
self
.
update_values
)
else
:
self
.
input_fields
[
i
].
currentTextChanged
.
connect
(
self
.
update_values
)
# Create a plot widget
graphWidget
=
pg
.
PlotWidget
(
self
)
graphWidget
.
setBackground
(
'
w
'
)
graphWidget
.
plot
(
RegressionModel
.
selected_day
,
RegressionModel
.
delay
)
graphWidget
.
plot
(
[
1
,
2
,
3
],
[
6
,
8
,
2
]
)
# Add the plot widget to the grid layout
grid_layout
.
addWidget
(
graphWidget
,
2
,
0
,
1
,
4
)
grid_layout
.
addWidget
(
QLabel
(
"
EXPECTED DELAY:
"
,
self
),
3
,
0
,
1
,
1
)
# Remember to add the delay value here
grid_layout
.
addWidget
(
self
.
calculate_button
,
2
,
0
,
1
,
2
)
grid_layout
.
addWidget
(
graphWidget
,
3
,
0
,
1
,
9
)
grid_layout
.
addWidget
(
QLabel
(
"
Predicted Price:
"
,
self
),
4
,
0
,
1
,
1
)
grid_layout
.
addWidget
(
QLabel
(
str
(
RegressionModel
.
price
),
self
),
4
,
2
,
1
,
1
)
# Remember to add the predicted price
self
.
setWindowTitle
(
'
Assistance Systems
'
)
self
.
show
()
def
update_values
(
self
):
menu_items
=
{
0
:
"
date
"
,
1
:
"
airline
"
,
2
:
"
destination
"
,
3
:
"
years to model
"
}
sender
=
self
.
sender
()
for
i
in
range
(
4
):
if
sender
==
self
.
input_fields
[
i
]:
RegressionModel
.
GUI_selections
[
menu_items
[
i
]]
=
sender
.
currentText
()
if
i
!=
0
\
else
sender
.
dateTime
()
print
(
RegressionModel
.
GUI_selections
[
menu_items
[
i
]])
menu_items
=
{
0
:
'
cut
'
,
1
:
'
color
'
,
2
:
'
clarity
'
,
3
:
'
carat
'
,
4
:
'
depth
'
,
5
:
'
table
'
,
6
:
'
x
'
,
7
:
'
y
'
,
8
:
'
z
'
}
for
key
,
value
in
menu_items
.
items
():
print
(
key
)
if
key
<
3
:
RegressionModel
.
GUI_selections
[
value
]
=
self
.
input_fields
[
key
].
currentText
()
else
:
RegressionModel
.
GUI_selections
[
value
]
=
self
.
input_fields
[
key
].
text
()
print
(
RegressionModel
.
GUI_selections
)
class
Advanced
(
QMainWindow
):
def
__init__
(
self
):
super
().
__init__
()
self
.
setWindowIcon
(
QIcon
(
"
icon.ico
"
))
self
.
setMinimumSize
(
720
,
640
)
#
# # Create a central widget
# central_widget = QWidget(self)
# self.setCentralWidget(central_widget)
#
# # Create a grid layout and set it to the central widget
# grid_layout = QGridLayout(central_widget)
#
# # Create labels and input fields
# self.labels_text = ['Date', 'Airline', 'Destination', 'Model Start Year']
# self.input_fields = [QDateEdit(self), QComboBox(self), QComboBox(self), QComboBox(self)]
# self.input_fields[1].addItems(RegressionModel.airlines)
# self.input_fields[2].addItems(RegressionModel.destinations)
# self.input_fields[3].addItems(list(map(str, RegressionModel.model_years)))
#
# # Add labels and input fields to the grid layout
# for i in range(4):
# label = QLabel(self.labels_text[i], self)
# grid_layout.addWidget(label, 0, i)
# grid_layout.addWidget(self.input_fields[i], 1, i)
#
# # Connect signals
# for i in range(len(self.input_fields)):
# if i == 0:
# self.input_fields[i].dateChanged.connect(self.update_values)
# else:
# self.input_fields[i].currentTextChanged.connect(self.update_values)
#
# # Create a plot widget
# graphWidget = pg.PlotWidget(self)
# graphWidget.setBackground('w')
# graphWidget.plot(RegressionModel.selected_day, RegressionModel.delay)
#
# # Add the plot widget to the grid layout
# grid_layout.addWidget(graphWidget, 2, 0, 1, 4)
# grid_layout.addWidget(QLabel("EXPECTED DELAY: ", self), 3, 0, 1, 1)
# # Remember to add the delay value here
#
# self.setWindowTitle('Assistance Systems')
# self.show()
#
# def update_values(self):
# menu_items = {0: "date", 1: "airline", 2: "destination", 3: "years to model"}
# sender = self.sender()
# for i in range(4):
# if sender == self.input_fields[i]:
# RegressionModel.GUI_selections[menu_items[i]] = sender.currentText() if i != 0 \
# else sender.dateTime()
# print(RegressionModel.GUI_selections[menu_items[i]])
app
=
QApplication
(
sys
.
argv
)
window
=
M
ainWindow
()
window
=
M
yTabs
()
window
.
show
()
app
.
exec
()
This diff is collapsed.
Click to expand it.
RegressionModel.py
+
9
−
12
View file @
47131af3
...
...
@@ -3,16 +3,13 @@ import random
import
pandas
as
pd
import
json
delaytime
=
[]
with
open
(
'
destination_cities.json
'
,
'
r
'
)
as
f
:
destinations
=
json
.
load
(
f
)
with
open
(
'
airlines.json
'
,
'
r
'
)
as
f
:
airlines
=
json
.
load
(
f
)
model_yea
rs
=
list
(
i
for
i
in
range
(
2018
,
2023
))
selected_day
=
list
(
range
(
366
))
delay
=
list
(
delaytime
)
# Shared Data from GUI
# GUI_selections = {"date": "", "airline": "", "destination": "", "years to model": ""}
GUI_selections
=
{
"
date
"
:
""
,
"
destination
"
:
""
,
"
years to model
"
:
""
}
diamonds
=
pd
.
read_csv
(
'
diamonds.csv
'
)
cut
=
list
(
diamonds
[
"
cut
"
].
unique
())
colo
rs
=
list
(
diamonds
[
"
color
"
].
unique
(
))
clarity
=
list
(
diamonds
[
"
clarity
"
].
unique
(
))
GUI_selections
=
{}
price_caret
=
[]
price
=
0
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