* Run inference on some test Iris flower data. * * @param model The instance of `tf.Model` to run the inference with. * @param testDataset A tf.Dataset object yielding features and targets. The * features must be of shape [numTrainExamples, 4], while the targets must be * [numTrainExamples,
(model, testDataset)
| 150 | * one-hot encoded labels of the three iris categories. |
| 151 | */ |
| 152 | async function evaluateModelOnTestData(model, testDataset) { |
| 153 | ui.clearEvaluateTable(); |
| 154 | const [{xs: xTest, ys: yTest}] = await testDataset.toArray(); |
| 155 | const xData = xTest.dataSync(); |
| 156 | const yTrue = yTest.argMax(-1).dataSync(); |
| 157 | const predictOut = model.predict(xTest); |
| 158 | const yPred = predictOut.argMax(-1); |
| 159 | ui.renderEvaluateTable(xData, yTrue, yPred.dataSync(), predictOut.dataSync()); |
| 160 | calculateAndDrawConfusionMatrix(model, xTest, yTest); |
| 161 | predictOnManualInput(model); |
| 162 | } |
| 163 | |
| 164 | const HOSTED_MODEL_JSON_URL = |
| 165 | 'https://storage.googleapis.com/tfjs-models/tfjs/iris_v1/model.json'; |
no test coverage detected