-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_results (1).py
77 lines (64 loc) · 3.96 KB
/
print_results (1).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# */AIPND-revision/intropyproject-classify-pet-images/print_results.py
#
# PROGRAMMER: Elena M
# DATE CREATED: 05/03/2020
# REVISED DATE:
# PURPOSE: Create a function print_results that prints the results statistics
# from the results statistics dictionary (results_stats_dic). It
# should also allow the user to be able to print out cases of misclassified
# dogs and cases of misclassified breeds of dog using the Results
# dictionary (results_dic).
# This function inputs:
# -The results dictionary as results_dic within print_results
# function and results for the function call within main.
# -The results statistics dictionary as results_stats_dic within
# print_results function and results_stats for the function call within main.
# -The CNN model architecture as model wihtin print_results function
# and in_arg.arch for the function call within main.
# -Prints Incorrectly Classified Dogs as print_incorrect_dogs within
# print_results function and set as either boolean value True or
# False in the function call within main (defaults to False)
# -Prints Incorrectly Classified Breeds as print_incorrect_breed within
# print_results function and set as either boolean value True or
# False in the function call within main (defaults to False)
# This function does not output anything other than printing a summary
# of the final results.
##
# TODO 6: Define print_results function below, specifically replace the None
# below by the function definition of the print_results function.
# Notice that this function doesn't to return anything because it
# prints a summary of the results using results_dic and results_stats_dic
#
def print_results(results_dic, results_stats_dic, model,
print_incorrect_dogs = False, print_incorrect_breed = False):
print("\n\n*** Results Summary for CNN Model Architecture",model.upper(),
"***")
print("{:20}: {:3d}".format('N Images', results_stats_dic['n_images']))
print("{:20}: {:3d}".format('N Dog Images', results_stats_dic['n_dogs_img']))
print("{:20}: {:3d}".format('N Not Dog Images', results_stats_dic['n_notdogs_img']))
print("\n\n*** Results Summary for percentages for CNN Model Architecture", model.upper(),"***")
print("{:20}: {:3d}".format('Pct Match', results_stats_dic['pct_match']))
print("{:20}: {:3d}".format('Pct Correct Dogs', results_stats_dic['pct_correct_dogs']))
print("{:20}: {:3d}".format('Pct Correct Breed', results_stats_dic['pct_correct_breed']))
print("{:20}: {:3d}".format('Pct Correct Not Dogs', results_stats_dic['pct_correct_notdogs']))
for key in results_stats_dic:
if results_stats_dic[key][0] == 'p':
print("{}, {}".format(key, results_stats_dic[key]))
if (print_incorrect_dogs and
( (results_stats_dic['n_correct_dogs'] + results_stats_dic['n_correct_notdogs'])
!= results_stats_dic['n_images'] )
):
print("\nINCORRECT Dog/NOT Dog Assignments:")
for key in results_dic:
if (results_dic[key][3] ==1 and results_dic[key][4]==0) or (results_dic[key][3]==0 and results_dic[key][4]==1):
print("\nINCORRECT classification")
if (print_incorrect_breed and (results_stats_dic['n_correct_dogs'] != results_stats_dic['n_correct_breed'])):
print("\nINCORRECT Dog Breed Assignment:")
for key in results_dic:
if ( sum(results_dic[key][3:]) == 2 and
results_dic[key][2] == 0 ):
print("Real: {:>26} Classifier: {:>30}".format(results_dic[key][0],
results_dic[key][1]))
None