From c984bfaed6a9aa6df0875971e4e4b1e24df3c3b6 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Fri, 3 May 2024 12:17:46 +0200 Subject: [PATCH] Fixes issue with Random Split having overlapping groups --- instat/dlgRandomSplit.vb | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/instat/dlgRandomSplit.vb b/instat/dlgRandomSplit.vb index 7af7a1f3610..0310ca32fe0 100644 --- a/instat/dlgRandomSplit.vb +++ b/instat/dlgRandomSplit.vb @@ -132,8 +132,7 @@ Public Class dlgRandomSplit clsTesting.SetPackageName("rsample") clsTesting.SetRCommand("testing") ucrBase.clsRsyntax.SetBaseRFunction(clsInitialSplit) - ucrBase.clsRsyntax.AddToAfterCodes(clsTesting, 0) - ucrBase.clsRsyntax.AddToAfterCodes(clsTraining, 1) + End Sub Private Sub SetRCodeForControls(bReset As Boolean) @@ -153,7 +152,7 @@ Public Class dlgRandomSplit ucrChkStratifyingFactor.SetRCode(clsInitialSplit, bReset) If bReset Then - ucrChkTest.SetRCode(clsInitialSplit, bReset) + ucrChkTest.SetRCode(clsTesting, bReset) End If End Sub @@ -190,24 +189,35 @@ Public Class dlgRandomSplit Private Sub SetBaseFunction() ucrBase.clsRsyntax.ClearCodes() If rdoSample.Checked Then - If ucrSaveTestingData.IsComplete Then - clsTesting.AddParameter("x", clsRFunctionParameter:=clsInitialSplit) + If ucrChkTest.Checked AndAlso ucrSaveTestingData.IsComplete Then + clsTesting.AddParameter("x", "rsample") + ucrBase.clsRsyntax.AddToAfterCodes(clsTesting, 0) + Else + ucrBase.clsRsyntax.RemoveFromAfterCodes(clsTesting) End If If ucrSaveTrainingData.IsComplete Then - clsTraining.AddParameter("x", clsRFunctionParameter:=clsInitialSplit) + clsTraining.AddParameter("x", "rsample") + ucrBase.clsRsyntax.AddToAfterCodes(clsTraining, 1) + Else + ucrBase.clsRsyntax.RemoveFromAfterCodes(clsTraining) End If ucrBase.clsRsyntax.SetBaseRFunction(clsInitialSplit) Else - If ucrSaveTestingData.IsComplete Then - clsTesting.AddParameter("x", clsRFunctionParameter:=clsInitialTimeSplit) + If ucrChkTest.Checked AndAlso ucrSaveTestingData.IsComplete Then + clsTesting.AddParameter("x", "rsample") + ucrBase.clsRsyntax.AddToAfterCodes(clsTesting, 0) + Else + ucrBase.clsRsyntax.RemoveFromAfterCodes(clsTesting) End If If ucrSaveTrainingData.IsComplete Then - clsTraining.AddParameter("x", clsRFunctionParameter:=clsInitialTimeSplit) + clsTraining.AddParameter("x", "rsample") + ucrBase.clsRsyntax.AddToAfterCodes(clsTraining, 1) + Else + ucrBase.clsRsyntax.RemoveFromAfterCodes(clsTraining) End If ucrBase.clsRsyntax.SetBaseRFunction(clsInitialTimeSplit) End If - ucrBase.clsRsyntax.AddToAfterCodes(clsTesting, 0) - ucrBase.clsRsyntax.AddToAfterCodes(clsTraining, 1) + End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset @@ -233,4 +243,7 @@ Public Class dlgRandomSplit SetBaseFunction() End Sub + Private Sub ucrChkTest_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkTest.ControlValueChanged + SetBaseFunction() + End Sub End Class \ No newline at end of file