(testSplit)
| 151 | * {0, 1, 2}. |
| 152 | */ |
| 153 | export function getIrisData(testSplit) { |
| 154 | return tf.tidy(() => { |
| 155 | const dataByClass = []; |
| 156 | const targetsByClass = []; |
| 157 | for (let i = 0; i < IRIS_CLASSES.length; ++i) { |
| 158 | dataByClass.push([]); |
| 159 | targetsByClass.push([]); |
| 160 | } |
| 161 | for (const example of IRIS_DATA) { |
| 162 | const target = example[example.length - 1]; |
| 163 | const data = example.slice(0, example.length - 1); |
| 164 | dataByClass[target].push(data); |
| 165 | targetsByClass[target].push(target); |
| 166 | } |
| 167 | |
| 168 | const xTrains = []; |
| 169 | const yTrains = []; |
| 170 | const xTests = []; |
| 171 | const yTests = []; |
| 172 | for (let i = 0; i < IRIS_CLASSES.length; ++i) { |
| 173 | const [xTrain, yTrain, xTest, yTest] = |
| 174 | convertToTensors(dataByClass[i], targetsByClass[i], testSplit); |
| 175 | xTrains.push(xTrain); |
| 176 | yTrains.push(yTrain); |
| 177 | xTests.push(xTest); |
| 178 | yTests.push(yTest); |
| 179 | } |
| 180 | |
| 181 | const concatAxis = 0; |
| 182 | return [ |
| 183 | tf.concat(xTrains, concatAxis), tf.concat(yTrains, concatAxis), |
| 184 | tf.concat(xTests, concatAxis), tf.concat(yTests, concatAxis) |
| 185 | ]; |
| 186 | }); |
| 187 | } |
nothing calls this directly
no test coverage detected