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

Function iris

iris/index.js:167–211  ·  view source on GitHub ↗

* The main function of the Iris demo.

()

Source from the content-addressed store, hash-verified

165 * The main function of the Iris demo.
166 */
167async function iris() {
168 const [xTrain, yTrain, xTest, yTest] = data.getIrisData(0.15);
169
170 const localLoadButton = document.getElementById('load-local');
171 const localSaveButton = document.getElementById('save-local');
172 const localRemoveButton = document.getElementById('remove-local');
173
174 document.getElementById('train-from-scratch')
175 .addEventListener('click', async () => {
176 model = await trainModel(xTrain, yTrain, xTest, yTest);
177 await evaluateModelOnTestData(model, xTest, yTest);
178 localSaveButton.disabled = false;
179 });
180
181 if (await loader.urlExists(HOSTED_MODEL_JSON_URL)) {
182 ui.status('Model available: ' + HOSTED_MODEL_JSON_URL);
183 const button = document.getElementById('load-pretrained-remote');
184 button.addEventListener('click', async () => {
185 ui.clearEvaluateTable();
186 model = await loader.loadHostedPretrainedModel(HOSTED_MODEL_JSON_URL);
187 await predictOnManualInput(model);
188 localSaveButton.disabled = false;
189 });
190 }
191
192 localLoadButton.addEventListener('click', async () => {
193 model = await loader.loadModelLocally();
194 await predictOnManualInput(model);
195 });
196
197 localSaveButton.addEventListener('click', async () => {
198 await loader.saveModelLocally(model);
199 await loader.updateLocalModelStatus();
200 });
201
202 localRemoveButton.addEventListener('click', async () => {
203 await loader.removeModelLocally();
204 await loader.updateLocalModelStatus();
205 });
206
207 await loader.updateLocalModelStatus();
208
209 ui.status('Standing by.');
210 ui.wireUpEvaluateTableCallbacks(() => predictOnManualInput(model));
211}
212
213iris();

Callers 1

index.jsFile · 0.70

Calls 3

trainModelFunction · 0.70
evaluateModelOnTestDataFunction · 0.70
predictOnManualInputFunction · 0.70

Tested by

no test coverage detected