@@ 756-785 (lines=30) @@ | ||
753 | f.write('\\bottomrule\n') |
|
754 | ||
755 | ||
756 | def generate_timeliness_avg_table(methods, classes, result_array, |
|
757 | background_class, filename=None): |
|
758 | bg_class_id = _get_bg_class_id(classes, background_class) |
|
759 | timeliness_values = [] |
|
760 | for i, method in enumerate(methods): |
|
761 | start_mismatch, stop_mismatch = _get_timeliness_measures(classes, result_array[i][0], result_array[i][1], |
|
762 | result_array[i][4]) |
|
763 | cur_timeliness = [start_mismatch[j] + stop_mismatch[j] for j in range(len(classes))] |
|
764 | timeliness_values.append([np.abs(np.array(cur_timeliness[j])) for j in range(len(classes))]) |
|
765 | # Average, <60, >60 |
|
766 | if filename is None: |
|
767 | f = sys.stdout |
|
768 | else: |
|
769 | f = open(filename, 'w') |
|
770 | f.write('\\textbf{Activities} ') |
|
771 | for method in methods: |
|
772 | f.write('& \\textbf{%s} ' % method.replace('_', ' ')) |
|
773 | f.write('\\\\ \\midrule \n') |
|
774 | for i, activity in enumerate(classes): |
|
775 | if i != bg_class_id: |
|
776 | f.write('%s ' % activity.replace('_', ' ')) |
|
777 | # Find maximum and store index |
|
778 | for j, method in enumerate(methods): |
|
779 | if len(timeliness_values[j][i]) == 0: |
|
780 | average_time = 0. |
|
781 | else: |
|
782 | average_time = np.average(timeliness_values[j][i]) |
|
783 | f.write('& %.1f' % average_time) |
|
784 | f.write('\\\\ \n') |
|
785 | f.write('\\bottomrule \n') |
|
786 | ||
787 | ||
788 | def generate_offset_per_table(methods, classes, result_array, |
|
@@ 788-815 (lines=28) @@ | ||
785 | f.write('\\bottomrule \n') |
|
786 | ||
787 | ||
788 | def generate_offset_per_table(methods, classes, result_array, |
|
789 | background_class, filename=None): |
|
790 | bg_class_id = _get_bg_class_id(classes, background_class) |
|
791 | timeliness_values = [] |
|
792 | for i, method in enumerate(methods): |
|
793 | start_mismatch, stop_mismatch = _get_timeoffset_measures(classes, result_array[i][0], result_array[i][1], |
|
794 | result_array[i][4]) |
|
795 | cur_timeliness = [start_mismatch[j] + stop_mismatch[j] for j in range(len(classes))] |
|
796 | timeliness_values.append([np.abs(np.array(cur_timeliness[j])) for j in range(len(classes))]) |
|
797 | # Average, <60, >60 |
|
798 | if filename is None: |
|
799 | f = sys.stdout |
|
800 | else: |
|
801 | f = open(filename, 'w') |
|
802 | f.write('\\textbf{Activities} ') |
|
803 | for method in methods: |
|
804 | f.write('& \\textbf{%s} ' % method.replace('_', ' ')) |
|
805 | f.write('\\\\ \\midrule \n') |
|
806 | for i, activity in enumerate(classes): |
|
807 | if i != bg_class_id: |
|
808 | f.write('%s ' % activity.replace('_', ' ')) |
|
809 | # Find maximum and store index |
|
810 | for j, method in enumerate(methods): |
|
811 | total_num = len(timeliness_values[j][i])/2 |
|
812 | nonzero_num = np.count_nonzero(timeliness_values[j][i]) |
|
813 | f.write('& %d/%d' % (nonzero_num, total_num)) |
|
814 | f.write('\\\\ \n') |
|
815 | f.write('\\bottomrule \n') |
|
816 | ||
817 |