Report class-wise averages

        Returns
        -------
        str
            result report in string format
977641
def result_report_class_wise_average(self):
        

        results = self.results_class_wise_average_metrics()

        output = self.ui.section_header('Class-wise average metrics (macro-average)', indent=2) + '\n'

        if results['f_measure']:
            output += self.ui.line('F-measure', indent=2) + '\n'
            output += self.ui.data(field='F-measure (F1)', value=float(results['f_measure']['f_measure']) * 100,
                                   unit='%', indent=4) + '\n'
            output += self.ui.data(field='Precision', value=float(results['f_measure']['precision']) * 100,
                                   unit='%', indent=4) + '\n'
            output += self.ui.data(field='Recall', value=float(results['f_measure']['recall']) * 100,
                                   unit='%', indent=4) + '\n'

        if results['error_rate']:
            output += self.ui.line('Error rate', indent=2) + '\n'
            output += self.ui.data(field='Error rate (ER)', value=float(results['error_rate']['error_rate']),
                                   indent=4) + '\n'
            output += self.ui.data(field='Deletion rate', value=float(results['error_rate']['deletion_rate']),
                                   indent=4) + '\n'
            output += self.ui.data(field='Insertion rate', value=float(results['error_rate']['insertion_rate']),
                                   indent=4) + '\n'

        if results['accuracy']:
            output += self.ui.line('Accuracy', indent=2) + '\n'
            output += self.ui.data(field='Sensitivity', value=float(results['accuracy']['sensitivity']*100),
                                   unit='%', indent=4) + '\n'
            output += self.ui.data(field='Specificity', value=float(results['accuracy']['specificity'] * 100),
                                   unit='%', indent=4) + '\n'
            output += self.ui.data(field='Balanced accuracy', value=float(results['accuracy']['balanced_accuracy'] * 100),
                                   unit='%', indent=4) + '\n'
            output += self.ui.data(field='Accuracy', value=float(results['accuracy']['accuracy'] * 100),
                                   unit='%', indent=4) + '\n'

        output += "  \n"

        return output
393672
def _str(value, depth):
    
    output = []
    if depth >0 and _get(value, CLASS) in data_types:
        for k, v in value.items():
            output.append(str(k) + "=" + _str(v, depth - 1))
        return "{" + ",\n".join(output) + "}"
    elif depth >0 and is_list(value):
        for v in value:
            output.append(_str(v, depth-1))
        return "[" + ",\n".join(output) + "]"
    else:
        return str(type(value))
184912
def results(self):
        

        results = {
            'overall': self.results_overall_metrics(),
            'class_wise': self.results_class_wise_metrics(),
            'class_wise_average': self.results_class_wise_average_metrics()
        }

        return results
224417
def loads(self, string):
    '''  '''
    for line in string.split("\n"):
      if len(line) < 10:
        continue

      try:
        report = ish_report()
        report.loads(line)
        self._reports.append(report)
      except BaseException as exp:
        ''' don't complain TOO much '''
        logging.warning('unable to load report, error: %s' % exp)
1352394
def _dict_to_report_line(cls, report_dict):
        ''''''
        return '\t'.join([str(report_dict[x]) for x in report.columns])
1052786
def _parse_uptime_string(self, uptime):
        
        uptime = uptime.strip()
        load_averages = uptime[uptime.find('load average:') :].split(':')[1].strip().split(',')
        load_averages = [float(load_avg) for load_avg in load_averages]
        return load_averages
191754
def str_to_class(s):
    """"""
    lst = s.split(".")
    klass = lst[-1]
    mod_list = lst[:-1]
    module = ".".join(mod_list)
    try:
        mod = __import__(module)
        if hasattr(mod, klass):
            return getattr(mod, klass)
        else:
            return None
    except ImportError:
        return None
1073850
def get_quality_report_string(self):
    """"""
    if not self._quality_distro:
      self.analyze_quality()
    ostr = ""
    for type in sorted(self._quality_distro.keys()):
      total = sum([ord(x)*self._quality_distro[type][x] for x in self._quality_distro[type]])
      cnt = sum([self._quality_distro[type][x] for x in self._quality_distro[type]])
      if cnt == 0: continue
      print 'type: '+type+' '+str(cnt)+' '+str(float(total)/float(cnt))
    return ostr
359023
def desc(self):
        
        if 'ects' in self:
            fmt = '%s (%s, S%d) [%s, %.2f ECTS]'
            fields = ('title', 'code', 'semester', 'status', 'ects')
        else:
            fmt = '%s'
            fields = ('title',)

        s = fmt % tuple([self[f] for f in fields])

        if self['followed'] and self['session']:
            res = self['result']
            if self.get('jury', 0) > 0:
                res = self['jury']

            s += ' --> %.2f/20 (%s)' % (res, self['session'])

        return s
200926
def _str_to_type_from_member_module(cls, module_, string):
        

        module_name_short, class_name = string.split(cls._DELIMITER_MODULE)
        members = inspect.getmembers(module_, inspect.ismodule)

        for name, module_member in members:
            if module_name_short == name:
                return getattr(module_member, class_name)

        error_message = cls._ERROR_COULD_NOT_FIND_CLASS.format(string)

        raise exception.BunqException(error_message)
1223608
def report(self):
        
        aggregations = dict(
            (test, Counter().rollup(values))
            for test, values in self.socket_warnings.items()
        )
        total = sum(
            len(warnings)
            for warnings in self.socket_warnings.values()
        )

        def format_test_statistics(test, counter):
            return "%s:\n%s" % (
                test,
                '\n'.join(
                    '  - %s: %s' % (socket, count)
                    for socket, count in counter.items()
                )
            )

        def format_statistics(aggregations):
            return '\n'.join(
                format_test_statistics(test, counter)
                for test, counter in aggregations.items()
            )

        # Only print the report if there are actually things to report.
        if aggregations:
            print('=' * 70, file=self.stream)
            print(
                'NON-WHITELISTED SOCKETS OPENED: %s' % total,
                file=self.stream,
            )
            print('-' * 70, file=self.stream)
            print(format_statistics(aggregations), file=self.stream)
460558
final String printToString(boolean reportMismatchesOnly) {
    StringBuilder sb = new StringBuilder();

    if (!isMatched()) {
      sb.append("Differences were found:\n");
      printContents(/* includeMatches = */ false, /* fieldPrefix = */ "", sb);

      if (!reportMismatchesOnly && isAnyChildMatched()) {
        sb.append("\nFull diff report:\n");
        printContents(/* includeMatches = */ true, /* fieldPrefix = */ "", sb);
      }
    } else {
      sb.append("No differences were found.");
      if (!reportMismatchesOnly) {
        if (isAnyChildIgnored()) {
          sb.append("\nSome fields were ignored for comparison, however.\n");
        } else {
          sb.append("\nFull diff report:\n");
        }
        printContents(/* includeMatches = */ true, /* fieldPrefix = */ "", sb);
      }
    }

    return sb.toString();
  }
227188
def str_def(self):
        
        return "classname={!r}; read_timeout={!r}; read_retries={!r}; " \
            "message={!r};". \
            format(self.__class__.__name__, self.read_timeout,
                   self.read_retries, self.args[0])
1339491
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        pretty = spaces + 'class ' + self.name
        if self.superclasses:
            superclasses = ', '.join(self.superclasses)
            pretty += '(' + superclasses + ')'
        pretty += ':\n'
        if self.members:
            pretty += '\n\n'.join(
                    c.pretty_str(indent + 2)
                    for c in self.members
            )
        else:
            pretty += spaces + '  [declaration]'
        return pretty
337989
def results_class_wise_average_metrics(self):
        

        class_wise_results = self.results_class_wise_metrics()

        class_wise_eer = []
        class_wise_fmeasure = []
        class_wise_precision = []
        class_wise_recall = []

        for class_label in class_wise_results:
            if class_wise_results[class_label]['eer']['eer'] is not None:
                class_wise_eer.append(class_wise_results[class_label]['eer']['eer'])

            if class_wise_results[class_label]['f_measure']['f_measure'] is not None:
                class_wise_fmeasure.append(class_wise_results[class_label]['f_measure']['f_measure'])
                class_wise_precision.append(class_wise_results[class_label]['f_measure']['precision'])
                class_wise_recall.append(class_wise_results[class_label]['f_measure']['recall'])

        if class_wise_eer:
            eer = float(numpy.nanmean(class_wise_eer))

        else:
            eer = None

        if class_wise_fmeasure:
            f_measure = float(numpy.nanmean(class_wise_fmeasure))

        else:
            f_measure = None

        if class_wise_precision:
            precision = float(numpy.nanmean(class_wise_precision))

        else:
            precision = None

        if class_wise_recall:
            recall = float(numpy.nanmean(class_wise_recall))

        else:
            recall = None

        return {
            'eer': {
                'eer': eer
            },
            'f_measure': {
                'f_measure': f_measure,
                'precision': precision,
                'recall': recall,
            }
        }
258474
def get_string(self):
    
    ostr = ''
    ostr += str(len(self._alignment_errors))+" Alignments\n"
    ostr += 'Target: '+"\n"
    totbases = sum([len(x.get_target_sequence()) for x in self._alignment_errors])
    ostr += '  '+str(totbases)+" Target Bases\n"
    adjerror = sum([sum([y.get_error_probability() for y in x.get_target_errors()]) for x in self._alignment_errors])
    ostr += '  '+str(adjerror)+" Approximate error count\n"
    ostr += '  '+str(float(adjerror)/float(totbases))+" Error rate\n"
    ostr += 'Query: '+"\n"
    totbases = sum([len(x.get_query_sequence()) for x in self._alignment_errors])
    ostr += '  '+str(totbases)+" Query Bases\n"
    adjerror = sum([sum([y.get_error_probability() for y in x.get_query_errors()]) for x in self._alignment_errors])
    ostr += '  '+str(adjerror)+" Approximate error count\n"
    ostr += '  '+str(float(adjerror)/float(totbases))+" Error rate\n"
    return ostr
1061614
def _format_results(_keywords, combined_keywords, split, scores):
    
    combined_keywords.sort(key=lambda w: _get_average_score(w, _keywords), reverse=True)
    if scores:
        return [(word, _get_average_score(word, _keywords)) for word in combined_keywords]
    if split:
        return combined_keywords
    return "\n".join(combined_keywords)