Example #1
0
 def model_sort_criterion(
         chunk: Tuple[ModelRepr, Tuple[Penalty,
                                       List[InstanceRepr]]]) -> Any:
     model, (penalty, instances) = chunk
     return (
         model_get_ordering_key(model),
         len(instances),
         len(model_get_name(model)),
     )
Example #2
0
    def export_compact(
        self
    ) -> Iterator[Optional[Tuple[Optional[str], Union[int, str], str, int]]]:
        for subject in map(subject_from_response_bytes, self.subjects):
            subject_name: Optional[str] = subject.name
            for model, model_penalty, instances in subject.best_models:
                yield (subject_name, model_penalty.to_csv(),
                       model_get_name(model), len(instances))
                subject_name = None  # don't repeat these

            yield None  # bump progress
Example #3
0
    def export_detailed(
            self
    ) -> Iterator[Optional[Tuple[str, Optional[int], int, str, str]]]:
        for subject in map(subject_from_response_bytes, self.subjects):
            for model, penalty, instances in subject.best_models:
                for instance in sorted(instances):
                    yield (subject.name,
                           penalty.lower_bound if penalty.lower_bound
                           == penalty.upper_bound else None,
                           penalty.upper_bound, model_get_name(model),
                           base64.b64encode(instance).decode('ascii'))

            yield None  # bump progress
Example #4
0
 def __init__(self, parent_node: 'EstimationResult.Subject', row: int,
              model: model.Model, penalty: Penalty,
              instances: List[InstanceRepr]) -> None:
     subject = parent_node.subject
     Node.__init__(
         self,
         parent_node,
         row,
         fields=(model_get_name(model), penalty,
                 '%d instances' % len(instances)),
         child_count=len(instances),
     )
     self.instances = instances
     self.subject = subject