|
| 1 | +// Copyright 2020 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +'use strict'; |
| 16 | + |
| 17 | +function main( |
| 18 | + projectId = 'YOUR_PROJECT_ID', |
| 19 | + location = 'us-central1', |
| 20 | + modelId = 'YOUR_MODEL_ID' |
| 21 | +) { |
| 22 | + // [START automl_language_entity_extraction_list_model_evaluations] |
| 23 | + // [START automl_language_sentiment_analysis_list_model_evaluations] |
| 24 | + // [START automl_language_text_classification_list_model_evaluations] |
| 25 | + // [START automl_translate_list_model_evaluations] |
| 26 | + // [START automl_vision_classification_list_model_evaluations] |
| 27 | + // [START automl_vision_object_detection_list_model_evaluations] |
| 28 | + /** |
| 29 | + * TODO(developer): Uncomment these variables before running the sample. |
| 30 | + */ |
| 31 | + // const projectId = 'YOUR_PROJECT_ID'; |
| 32 | + // const location = 'us-central1'; |
| 33 | + // const modelId = 'YOUR_MODEL_ID'; |
| 34 | + |
| 35 | + // Imports the Google Cloud AutoML library |
| 36 | + const {AutoMlClient} = require(`@google-cloud/automl`).v1; |
| 37 | + |
| 38 | + // Instantiates a client |
| 39 | + const client = new AutoMlClient(); |
| 40 | + |
| 41 | + async function listModelEvaluations() { |
| 42 | + // Construct request |
| 43 | + const request = { |
| 44 | + parent: client.modelPath(projectId, location, modelId), |
| 45 | + filter: '', |
| 46 | + }; |
| 47 | + |
| 48 | + const [response] = await client.listModelEvaluations(request); |
| 49 | + |
| 50 | + console.log(`List of model evaluations:`); |
| 51 | + for (const evaluation of response) { |
| 52 | + console.log(`Model evaluation name: ${evaluation.name}`); |
| 53 | + console.log(`Model annotation spec id: ${evaluation.annotationSpecId}`); |
| 54 | + console.log(`Model display name: ${evaluation.displayName}`); |
| 55 | + console.log(`Model create time`); |
| 56 | + console.log(`\tseconds ${evaluation.createTime.seconds}`); |
| 57 | + console.log(`\tnanos ${evaluation.createTime.nanos / 1e9}`); |
| 58 | + console.log( |
| 59 | + `Evaluation example count: ${evaluation.evaluatedExampleCount}` |
| 60 | + ); |
| 61 | + // [END automl_language_sentiment_analysis_list_model_evaluations] |
| 62 | + // [END automl_language_text_classification_list_model_evaluations] |
| 63 | + // [END automl_translate_list_model_evaluations] |
| 64 | + // [END automl_vision_classification_list_model_evaluations] |
| 65 | + // [END automl_vision_object_detection_list_model_evaluations] |
| 66 | + console.log( |
| 67 | + `Entity extraction model evaluation metrics: ${evaluation.textExtractionEvaluationMetrics}` |
| 68 | + ); |
| 69 | + // [END automl_language_entity_extraction_list_model_evaluations] |
| 70 | + |
| 71 | + // [START automl_language_sentiment_analysis_list_model_evaluations] |
| 72 | + console.log( |
| 73 | + `Sentiment analysis model evaluation metrics: ${evaluation.textSentimentEvaluationMetrics}` |
| 74 | + ); |
| 75 | + // [END automl_language_sentiment_analysis_list_model_evaluations] |
| 76 | + |
| 77 | + // [START automl_language_text_classification_list_model_evaluations] |
| 78 | + // [START automl_vision_classification_list_model_evaluations] |
| 79 | + console.log( |
| 80 | + `Classification model evaluation metrics: ${evaluation.classificationEvaluationMetrics}` |
| 81 | + ); |
| 82 | + // [END automl_language_text_classification_list_model_evaluations] |
| 83 | + // [END automl_vision_classification_list_model_evaluations] |
| 84 | + |
| 85 | + // [START automl_translate_list_model_evaluations] |
| 86 | + console.log( |
| 87 | + `Translation model evaluation metrics: ${evaluation.translationEvaluationMetrics}` |
| 88 | + ); |
| 89 | + // [END automl_translate_list_model_evaluations] |
| 90 | + |
| 91 | + // [START automl_vision_object_detection_list_model_evaluations] |
| 92 | + console.log( |
| 93 | + `Object detection model evaluation metrics: ${evaluation.imageObjectDetectionEvaluationMetrics}` |
| 94 | + ); |
| 95 | + // [START automl_language_entity_extraction_list_model_evaluations] |
| 96 | + // [START automl_language_sentiment_analysis_list_model_evaluations] |
| 97 | + // [START automl_language_text_classification_list_model_evaluations] |
| 98 | + // [START automl_translate_list_model_evaluations] |
| 99 | + // [START automl_vision_classification_list_model_evaluations] |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + listModelEvaluations(); |
| 104 | + // [END automl_language_entity_extraction_list_model_evaluations] |
| 105 | + // [END automl_language_sentiment_analysis_list_model_evaluations] |
| 106 | + // [END automl_language_text_classification_list_model_evaluations] |
| 107 | + // [END automl_translate_list_model_evaluations] |
| 108 | + // [END automl_vision_classification_list_model_evaluations] |
| 109 | + // [END automl_vision_object_detection_list_model_evaluations] |
| 110 | +} |
| 111 | + |
| 112 | +main(...process.argv.slice(2)); |
0 commit comments