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

Function evaluateModelOnTestData

iris/index.js:145–159  ·  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 xTest Test data feature, a `tf.Tensor` of shape [numTestExamples, 4]. * @param yTest Test true labels, one-hot encoded, a `tf.Tensor` of shape * [numTestExamples, 3].

(model, xTest, yTest)

Source from the content-addressed store, hash-verified

143 * [numTestExamples, 3].
144 */
145async function evaluateModelOnTestData(model, xTest, yTest) {
146 ui.clearEvaluateTable();
147
148 tf.tidy(() => {
149 const xData = xTest.dataSync();
150 const yTrue = yTest.argMax(-1).dataSync();
151 const predictOut = model.predict(xTest);
152 const yPred = predictOut.argMax(-1);
153 ui.renderEvaluateTable(
154 xData, yTrue, yPred.dataSync(), predictOut.dataSync());
155 calculateAndDrawConfusionMatrix(model, xTest, yTest);
156 });
157
158 predictOnManualInput(model);
159}
160
161const HOSTED_MODEL_JSON_URL =
162 '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