def __init__(self, experiment, parameters): self.experiment = experiment title = "Experiment Results" metadata = {} text_parts = [] datafile = experiment.estimators[list( experiment.estimators.keys())[0]].datafile if datafile.density is not None: text_parts.append( report_line("Known Shannon entropy: ", datafile.density)) text_parts.append(NewLine()) text_parts.append(Word("Estimations: ", {'align': 'center'})) estimations = list(experiment.estimators.values()) table = Table([{ 'size': 2, 'options': { 'align': 'left' } }, { 'size': 5, 'options': { 'align': 'left' } }, { 'size': 3, 'options': { 'align': 'right' } }, { 'size': 2, 'options': { 'align': 'center' } }]) table.add_header(['No.', 'Name', 'Result', 'Score']) if parameters is not None and 'sort_by' in parameters: sort_key = parameters['sort_by'] def sorter(item): v = item.get_sort_value(sort_key) return v estimations = sorted(estimations, key=sorter) for i in range(len(estimations)): e = estimations[i] table.add_row([ Word(str(i + 1).rjust(len(str(len(estimations))))), Link(e.name, e.id, self.open), Result(e.output), Word(e.review.score) ]) text_parts += table.get_lines() super().__init__(title, metadata, text_parts)
def __init__(self, repeated_experiment, parameters): self.repeated_experiment = repeated_experiment title = "Repeated Experiment Results" metadata = {} text_parts = [] text_parts.append(Word("Estimators: ", {'align': 'center'})) self.statistics = repeated_experiment.statistics estimations = list(self.statistics.keys()) table = Table([{ 'size': 2, 'options': { 'align': 'left' } }, { 'size': 4, 'options': { 'align': 'left' } }, { 'size': 3, 'options': { 'align': 'center' } }, { 'size': 3, 'options': { 'align': 'center' } }]) table.add_header(['No.', 'Name', 'Avg Pos', 'Trust']) if parameters is not None and 'sort_by' in parameters: sort_key = parameters['sort_by'] if sort_key is None: sort_key = 'name' def sorter(item): v = self.statistics[item][sort_key] if sort_key == 'score': v = 1 / v if v > 0 else 1000000 return v estimations = sorted(estimations, key=sorter) for i in range(len(estimations)): name = estimations[i] s = self.statistics[name] table.add_row([ Word(str(i + 1).rjust(len(str(len(estimations))))), Link(name, name, self.open), Result(s['avg_pos']), Word(s['score']) ]) text_parts += table.get_lines() super().__init__(title, metadata, text_parts)
def report_line(title, result): tword = Word(title, {'align': 'left'}) rword = Result(result, {'align': 'right'}) return DocumentLine([6, 6], [tword, rword])
def __init__(self, statistics, parameters=None): self.statistics = statistics title = "Density Estimator statistics" metadata = {} text_parts = [] text_parts.append(report_line("Overall score: ", statistics['score'])) text_parts.append(Word("Estimation score: ")) text_parts.append(report_line(" Minimum: ", statistics['min_score'])) text_parts.append(report_line(" Maximum: ", statistics['max_score'])) text_parts.append(report_line(" Average: ", statistics['avg_score'])) text_parts.append( report_line(" Standard deviation: ", statistics['std_score'])) text_parts.append(NewLine()) text_parts.append(Word("Experiment position: ")) text_parts.append(report_line(" Minimum: ", statistics['min_pos'])) text_parts.append(report_line(" Maximum: ", statistics['max_pos'])) text_parts.append(report_line(" Average: ", statistics['avg_pos'])) text_parts.append( report_line(" Standard deviation: ", statistics['std_pos'])) text_parts.append(NewLine()) text_parts.append(Word("Experiments: ", {'align': 'center'})) self.participations = statistics['participations'] experiments = list(self.participations.keys()) table = Table([{ 'size': 2, 'options': { 'align': 'left' } }, { 'size': 6, 'options': { 'align': 'left' } }, { 'size': 2, 'options': { 'align': 'center' } }, { 'size': 2, 'options': { 'align': 'right' } }]) table.add_header(['No.', 'Name', 'Score', 'Pos']) if parameters is not None and 'sort_by' in parameters: sort_key = parameters['sort_by'] if sort_key is None: sort_key = 'name' def sorter(item): v = self.participations[sort_key] if sort_key == 'score': v = 1 / v return v experiments = sorted(experiments, key=sorter) for i in range(len(experiments)): name = experiments[i] s = self.participations[name] table.add_row([ Word(str(i + 1).rjust(len(str(len(experiments))))), Word(name), Result(s['score']), Result(s['pos']) ]) text_parts += table.get_lines() super().__init__(title, metadata, text_parts)