コード例 #1
0
    def get_fit_solution_results(self, request_id, max_results=None):

        request = core_pb2.GetFitSolutionResultsRequest(
            request_id=request_id, )

        LOGGER.debug("%s: %s", request.__class__.__name__, request)

        fitted_solutions = []
        for solution in self.stub.GetFitSolutionResults(request):
            LOGGER.debug("%s: %s", solution.__class__.__name__, solution)

            fitted_solutions.append(solution)

            if max_results and len(fitted_solutions) >= max_results:
                break

        return fitted_solutions
コード例 #2
0
    def get_fit_solution_results(self, rid):
        logger.info("Getting fit solution results for request with id: %s" %
                    rid)
        msg = core_pb2.GetFitSolutionResultsRequest(request_id=rid)
        results = None
        for reply in self.serv.GetFitSolutionResults(msg):

            if reply.progress.state == core_pb2.PENDING:
                logger.debug(
                    "Fitting model to solution is still pending and hasn't begin"
                )
            elif reply.progress.state == core_pb2.RUNNING:
                logger.debug(
                    "Fitting model to solution is currently running and has not completed: %s"
                    % reply.progress.status)
            elif reply.progress.state == core_pb2.COMPLETED:
                logger.info(
                    "Fitting model to solution has completed successfully: %s"
                    % reply.progress.status)
                # logger.debug("Got reply: %s" % str(reply))
                results = reply
            elif reply.progress.state == core_pb2.ERRORED:
                logger.error(
                    "Fitting model to solution has completed in an error state: %s"
                    % reply.progress.status)
            else:
                logger.warning(
                    "Fittin model to solution is in an unknown state: %s" %
                    str(reply.progress))

        request = self.fitted_solution_requests.pop(rid, None)

        for i in results.exposed_outputs:
            if i == 'predictions':
                logger.debug(results.exposed_outputs[i])
                if results.exposed_outputs[i].HasField("csv_uri"):
                    # logger.debug(results.exposed_outputs[i].csv_uri)
                    result_data = pd.read_csv(
                        results.exposed_outputs[i].csv_uri)
                    # logger.debug(result_data.head())
            else:
                logger.debug("Output label: %s" % i)
            # logger.debug(results.exposed_outputs[value_pb2.CSV_URI])

        return results.fitted_solution_id, result_data
コード例 #3
0
    def do_train(self, solution_id, dataset_path):
        fitted_solution = None
        try:
            response = self.core.FitSolution(
                pb_core.FitSolutionRequest(
                    solution_id=solution_id,
                    inputs=[pb_value.Value(dataset_uri=dataset_path, )],
                    expose_outputs=[],
                    expose_value_types=['CSV_URI'],
                    users=[self.user],
                ))
            # Results
            results = self.core.GetFitSolutionResults(
                pb_core.GetFitSolutionResultsRequest(
                    request_id=response.request_id, ))
            for result in results:
                if result.progress.state == pb_core.COMPLETED:
                    fitted_solution = result.fitted_solution_id
        except:
            logger.exception("Exception training %r", solution_id)

        return fitted_solution
コード例 #4
0
def get_fit_solution_results_request(request_id):
    request = core_pb2.GetFitSolutionResultsRequest(request_id=request_id)
    return request