0

In the tensorflow get started we can see the code:

----------------------------------------------------------------------------
 # Evaluate accuracy.
  accuracy_score = classifier.evaluate(input_fn=get_test_inputs,
                                       steps=1)["accuracy"]

----------------------------------------------------------------------------

I want to know what does the ["accuracy"] mean? i can't understand the format. It belong to the knowledge of python or tensorflow?

thx

Jiahao Cai
  • 1,222
  • 1
  • 11
  • 25
spark
  • 1

2 Answers2

0

It will belong to Tensorflow or whatever other specific machine learning library you might use. Tensorflow has more about metrics and accuracy here. Evaluating accuracy can mean taking the prediction values for the test dataset (which was never in the training data, but that you do have the true labels for), and calculating the difference between the model predictions, and the actual values.

StarkJA
  • 75
  • 1
  • 5
0

Well, the return value of estimator.Estimator.evaluate is described as:

A dict containing the evaluation metrics specified in model_fn keyed by name, as well as an entry global_step which contains the value of the global step for which this evaluation was performed.

In fact, that line simply applies dict.get("accuracy") to extract the value stored in 'accuracy' field. It is a Pythonic knowledge. For further information on dictionaries and their keys, you can refer to this question.

EDIT: Also you can simply execute the line in a Python interpreter without ['accuracy'] part. If you look the ingredients of accuracy_score, you will see that it is indeed a dictionary that contains key-value pairs.