Exemple #1
0
 def register(self, feature_values_pandas_frame, target_values_pandas_frame):
     register_request = OptimizerService_pb2.RegisterObservationsRequest(
         OptimizerHandle=self.optimizer_handle,
         Observations=OptimizerService_pb2.Observations(
             Features=OptimizerService_pb2.Features(FeaturesJsonString=feature_values_pandas_frame.to_json(orient='index', double_precision=15)),
             ObjectiveValues=OptimizerService_pb2.ObjectiveValues(
                 ObjectiveValuesJsonString=target_values_pandas_frame.to_json(orient='index', double_precision=15)
             )
         )
     )
     self._optimizer_stub.RegisterObservations(register_request)
Exemple #2
0
    def register(self, parameter_values_pandas_frame, target_values_pandas_frame, context_values_pandas_frame=None):
        if context_values_pandas_frame is not None:
            raise NotImplementedError("Context not currently supported on remote optimizers")

        feature_values_pandas_frame = parameter_values_pandas_frame
        register_request = OptimizerService_pb2.RegisterObservationsRequest(
            OptimizerHandle=self.optimizer_handle_for_optimizer_service,
            Observations=OptimizerService_pb2.Observations(
                Features=OptimizerService_pb2.Features(FeaturesJsonString=feature_values_pandas_frame.to_json(orient='index', double_precision=15)),
                ObjectiveValues=OptimizerService_pb2.ObjectiveValues(
                    ObjectiveValuesJsonString=target_values_pandas_frame.to_json(orient='index', double_precision=15)
                )
            )
        )
        self._optimizer_stub.RegisterObservations(register_request) # TODO: we should be using the optimizer_stub for this.
Exemple #3
0
    def register(self, feature_values_pandas_frame,
                 target_values_pandas_frame):  # pylint: disable=unused-argument
        # TODO: implement RegisterObservations <- plural
        #
        features_dicts_per_record = feature_values_pandas_frame.to_dict(
            orient='records')
        objectives_dicts_per_record = target_values_pandas_frame.to_dict(
            orient='records')

        # TODO: Either implement streaming or arrow flight or batch.
        #
        for feature_dict, objective_dict in zip(features_dicts_per_record,
                                                objectives_dicts_per_record):
            register_request = OptimizerService_pb2.RegisterObservationRequest(
                OptimizerHandle=self.optimizer_handle,
                Observation=OptimizerService_pb2.Observation(
                    Features=OptimizerService_pb2.Features(
                        FeaturesJsonString=json.dumps(feature_dict)),
                    ObjectiveValues=OptimizerService_pb2.ObjectiveValues(
                        ObjectiveValuesJsonString=json.dumps(objective_dict))))
            self._optimizer_stub.RegisterObservation(register_request)