Skip to content

Commit

Permalink
enabling bootstrap option on random forest
Browse files Browse the repository at this point in the history
  • Loading branch information
rifqiharrys committed Mar 14, 2021
1 parent 60c3835 commit 6a4aa05
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions sdb_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def __init__(self):
global rf_op_list
rf_op_list = [
300, # n_estimators
'mse' # criterion
'mse', # criterion
True # bootstrap
]

global svm_op_list
Expand Down Expand Up @@ -692,6 +693,10 @@ def rfOptionWIndow(self):
self.criterionCB = QComboBox()
self.criterionCB.addItems(['mse', 'mae'])

bootstrapLabel = QLabel('Bootstrap:')
self.bootstrapCB = QComboBox()
self.bootstrapCB.addItems(['True', 'False'])

cancelButton = QPushButton('Cancel')
cancelButton.clicked.connect(optionDialog.close)
loadButton = QPushButton('Load')
Expand All @@ -706,8 +711,11 @@ def rfOptionWIndow(self):
grid.addWidget(criterionLabel, 2, 1, 1, 2)
grid.addWidget(self.criterionCB, 2, 3, 1, 2)

grid.addWidget(loadButton, 3, 3, 1, 1)
grid.addWidget(cancelButton, 3, 4, 1, 1)
grid.addWidget(bootstrapLabel, 3, 1, 1, 2)
grid.addWidget(self.bootstrapCB, 3, 3, 1, 2)

grid.addWidget(loadButton, 4, 3, 1, 1)
grid.addWidget(cancelButton, 4, 4, 1, 1)

optionDialog.setLayout(grid)

Expand All @@ -722,7 +730,8 @@ def loadRFOptionAction(self):
global rf_op_list
rf_op_list = [
self.ntreeSB.value(),
self.criterionCB.currentText()
self.criterionCB.currentText(),
self.str2bool(self.bootstrapCB.currentText())
]


Expand Down Expand Up @@ -1443,14 +1452,16 @@ def rfPredict(self):
regressor = RandomForestRegressor(
n_estimators=rf_op_list[0],
criterion=rf_op_list[1],
bootstrap=rf_op_list[2],
random_state=proc_op_list[2])

parameters.append(regressor)

global print_parameters_info
print_parameters_info = (
'N Trees:\t\t' + str(rf_op_list[0]) + '\n' +
'Criterion:\t\t' + str(rf_op_list[1])
'Criterion:\t\t' + str(rf_op_list[1]) + '\n' +
'Bootstrap:\t\t' + str(rf_op_list[2])
)

return parameters
Expand Down

0 comments on commit 6a4aa05

Please sign in to comment.