def testDoWithTunerFn(self): self._exec_properties['tuner_fn'] = '%s.%s' % ( tuner_module.tuner_fn.__module__, tuner_module.tuner_fn.__name__) ps_type = ps_pb2.Type( binary_classification=ps_pb2.BinaryClassification(label='class')) ps = ps_pb2.ProblemStatement( owner=['nitroml'], tasks=[ps_pb2.Task( name='mockdata_1', type=ps_type, )]) self._exec_properties['custom_config'] = json_utils.dumps({ 'problem_statement': text_format.MessageToString(message=ps, as_utf8=True), }) tuner = executor.Executor(self._context) tuner.Do(input_dict=self._input_dict, output_dict=self._output_dict, exec_properties=self._exec_properties) self._verify_output()
def testDoWithMajoritVoting(self): exec_properties = self._exec_properties.copy() exec_properties['tuner_fn'] = '%s.%s' % ( tuner_module.tuner_fn.__module__, tuner_module.tuner_fn.__name__) exec_properties['metalearning_algorithm'] = 'majority_voting' input_dict = self._input_dict.copy() ps_type = ps_pb2.Type( binary_classification=ps_pb2.BinaryClassification(label='class')) ps = ps_pb2.ProblemStatement( owner=['nitroml'], tasks=[ps_pb2.Task( name='mockdata_1', type=ps_type, )]) exec_properties['custom_config'] = json_utils.dumps({ 'problem_statement': text_format.MessageToString(message=ps, as_utf8=True), }) hps_artifact = artifacts.KCandidateHyperParameters() hps_artifact.uri = os.path.join(self._testdata_dir, 'MetaLearner.majority_voting', 'hparams_out') input_dict['warmup_hyperparameters'] = [hps_artifact] tuner = executor.Executor(self._context) tuner.Do(input_dict=input_dict, output_dict=self._output_dict, exec_properties=exec_properties) self._verify_output()
def _get_task_type(self): """Creates a `ps_pb2.Type` from the number of classes.""" if self.num_classes == 0: return ps_pb2.Type( one_dimensional_regression=ps_pb2.OneDimensionalRegression( label=self._label_key)) if self.num_classes == 2: return ps_pb2.Type( binary_classification=ps_pb2.BinaryClassification( label=self._label_key)) return ps_pb2.Type( multi_class_classification=ps_pb2.MultiClassClassification( label=self._label_key))
def problem_statement(self) -> ps_pb2.ProblemStatement: """Returns the ProblemStatement associated with this Task.""" # Supervised keys is a two-tuple. _, target_key = self._dataset_builder.info.supervised_keys return ps_pb2.ProblemStatement( owner=['nitroml'], tasks=[ ps_pb2.Task( name=self.name, type=ps_pb2.Type( binary_classification=ps_pb2.BinaryClassification( label=target_key)), ) ])