(firstTime = false)
| 1065 | } |
| 1066 | |
| 1067 | function generateData(firstTime = false) { |
| 1068 | if (!firstTime) { |
| 1069 | // Change the seed. |
| 1070 | state.seed = Math.random().toFixed(5); |
| 1071 | state.serialize(); |
| 1072 | userHasInteracted(); |
| 1073 | } |
| 1074 | Math.seedrandom(state.seed); |
| 1075 | let numSamples = (state.problem === Problem.REGRESSION) ? |
| 1076 | NUM_SAMPLES_REGRESS : NUM_SAMPLES_CLASSIFY; |
| 1077 | let generator = state.problem === Problem.CLASSIFICATION ? |
| 1078 | state.dataset : state.regDataset; |
| 1079 | let data = generator(numSamples, state.noise / 100); |
| 1080 | // Shuffle the data in-place. |
| 1081 | shuffle(data); |
| 1082 | // Split into train and test data. |
| 1083 | let splitIndex = Math.floor(data.length * state.percTrainData / 100); |
| 1084 | trainData = data.slice(0, splitIndex); |
| 1085 | testData = data.slice(splitIndex); |
| 1086 | heatMap.updatePoints(trainData); |
| 1087 | heatMap.updateTestPoints(state.showTestData ? testData : []); |
| 1088 | } |
| 1089 | |
| 1090 | let firstInteraction = true; |
| 1091 | let parametersChanged = false; |
no test coverage detected
searching dependent graphs…