MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / evaluateModelOnTestData

Function evaluateModelOnTestData

iris-fitDataset/index.js:152–162  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

150 * one-hot encoded labels of the three iris categories.
151 */
152async 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
164const HOSTED_MODEL_JSON_URL =
165 'https://storage.googleapis.com/tfjs-models/tfjs/iris_v1/model.json';

Callers 1

irisFunction · 0.70

Calls 3

predictOnManualInputFunction · 0.70
predictMethod · 0.45

Tested by

no test coverage detected