Skip to content

Commit 506d2d5

Browse files
committed
More intuitive save model logic
1 parent 15aba07 commit 506d2d5

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

R/commonMachineLearningClassification.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@
167167
if (!ready) {
168168
table$addFootnote(gettextf("Please provide a target variable and at least %i feature variable(s).", if (type == "knn" || type == "neuralnet" || type == "rpart" || type == "svm" || type == "logistic") 1L else 2L))
169169
}
170-
if (options[["savePath"]] != "") {
170+
if (options[["saveModel"]]) {
171171
validNames <- (length(grep(" ", decodeColNames(colnames(dataset)))) == 0) && (length(grep("_", decodeColNames(colnames(dataset)))) == 0)
172-
if (options[["saveModel"]] && validNames) {
172+
if (options[["savePath"]] != "" && validNames) {
173173
table$addFootnote(gettextf("The trained model is saved as <i>%1$s</i>.", basename(options[["savePath"]])))
174-
} else if (options[["saveModel"]] && !validNames) {
174+
} else if (options[["savePath"]] != "" && !validNames) {
175175
table$addFootnote(gettext("The trained model is <b>not</b> saved because the some of the variable names in the model contain spaces (i.e., ' ') or underscores (i.e., '_'). Please remove all such characters from the variable names and try saving the model again."))
176176
} else {
177-
table$addFootnote(gettext("The trained model is not saved until 'Save trained model' is checked."))
177+
table$addFootnote(gettext("The trained model is not saved until a file name is specified under 'Save as'."))
178178
}
179179
}
180180
jaspResults[["classificationTable"]] <- table

R/commonMachineLearningRegression.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,14 @@
336336
if (!ready) {
337337
table$addFootnote(gettextf("Please provide a target variable and at least %d feature variable(s).", if (type == "knn" || type == "neuralnet" || type == "rpart" || type == "svm" || type == "lm") 1L else 2L))
338338
}
339-
if (options[["savePath"]] != "") {
339+
if (options[["saveModel"]]) {
340340
validNames <- (length(grep(" ", decodeColNames(colnames(dataset)))) == 0) && (length(grep("_", decodeColNames(colnames(dataset)))) == 0)
341-
if (options[["saveModel"]] && validNames) {
341+
if (options[["savePath"]] != "" && validNames) {
342342
table$addFootnote(gettextf("The trained model is saved as <i>%1$s</i>.", basename(options[["savePath"]])))
343-
} else if (options[["saveModel"]] && !validNames) {
343+
} else if (options[["savePath"]] != "" && !validNames) {
344344
table$addFootnote(gettext("The trained model is <b>not</b> saved because the some of the variable names in the model contain spaces (i.e., ' ') or underscores (i.e., '_'). Please remove all such characters from the variable names and try saving the model again."))
345345
} else {
346-
table$addFootnote(gettext("The trained model is not saved until 'Save trained model' is checked."))
346+
table$addFootnote(gettext("The trained model is not saved until a file name is specified under 'Save as'."))
347347
}
348348
}
349349
jaspResults[["regressionTable"]] <- table

inst/qml/common/ui/ExportResults.qml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,22 @@ Group
6161
{
6262
id: saveGroup
6363

64-
FileSelector
65-
{
66-
id: savePath
67-
name: "savePath"
68-
label: qsTr("Save as")
69-
placeholderText: qsTr("e.g., location/model.jaspML")
70-
filter: "*.jaspML"
71-
save: true
72-
fieldWidth: 180 * preferencesModel.uiScale
73-
info: qsTr("The file path for the saved model.")
74-
}
75-
7664
CheckBox
7765
{
78-
id: saveModel
7966
name: "saveModel"
8067
text: qsTr("Save trained model")
81-
enabled: showSave && savePath.value != ""
82-
Layout.leftMargin: 10 * preferencesModel.uiScale
8368
info: qsTr("When clicked, the model is exported to the specified file path.")
69+
70+
FileSelector
71+
{
72+
name: "savePath"
73+
label: qsTr("Save as")
74+
placeholderText: qsTr("e.g., location/model.jaspML")
75+
filter: "*.jaspML"
76+
save: true
77+
fieldWidth: 180 * preferencesModel.uiScale
78+
info: qsTr("The file path for the saved model.")
79+
}
8480
}
8581
}
8682
}

0 commit comments

Comments
 (0)