|
| 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 | +# http://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 | + |
| 16 | +def get_model_evaluation(project_id, model_id, model_evaluation_id): |
| 17 | + """Get model evaluation.""" |
| 18 | + # [START automl_video_classification_get_model_evaluation_beta] |
| 19 | + from google.cloud import automl_v1beta1 as automl |
| 20 | + |
| 21 | + # TODO(developer): Uncomment and set the following variables |
| 22 | + # project_id = "YOUR_PROJECT_ID" |
| 23 | + # model_id = "YOUR_MODEL_ID" |
| 24 | + # model_evaluation_id = "YOUR_MODEL_EVALUATION_ID" |
| 25 | + |
| 26 | + client = automl.AutoMlClient() |
| 27 | + # Get the full path of the model evaluation. |
| 28 | + model_evaluation_full_id = client.model_evaluation_path( |
| 29 | + project_id, "us-central1", model_id, model_evaluation_id |
| 30 | + ) |
| 31 | + |
| 32 | + # Get complete detail of the model evaluation. |
| 33 | + response = client.get_model_evaluation(model_evaluation_full_id) |
| 34 | + |
| 35 | + print("Model evaluation name: {}".format(response.name)) |
| 36 | + print("Model annotation spec id: {}".format(response.annotation_spec_id)) |
| 37 | + print("Create Time:") |
| 38 | + print("\tseconds: {}".format(response.create_time.seconds)) |
| 39 | + print("\tnanos: {}".format(response.create_time.nanos / 1e9)) |
| 40 | + print( |
| 41 | + "Evaluation example count: {}".format(response.evaluated_example_count) |
| 42 | + ) |
| 43 | + |
| 44 | + print( |
| 45 | + "Classification model evaluation metrics: {}".format( |
| 46 | + response.classification_evaluation_metrics |
| 47 | + ) |
| 48 | + ) |
| 49 | + # [END automl_video_classification_get_model_evaluation_beta] |
0 commit comments