示例#1
0
    def mli_test_weights(self, weights: Weights) -> ProposedWeights:
        current_weights = self.mli_get_current_weights()
        self.set_weights(weights)

        vote_score = self.test(self.xg_vote)
        test_score = self.test(self.xg_test)

        vote = self.vote_score >= vote_score

        self.set_weights(current_weights)
        return ProposedWeights(weights=weights,
                               vote_score=vote_score,
                               test_score=test_score,
                               vote=vote)
示例#2
0
    def mli_test_weights(self, weights: Weights) -> ProposedWeights:
        current_weights = self.mli_get_current_weights()
        self.set_weights(weights)

        vote_score = self.test(self.train_data, self.train_labels)

        test_score = self.test(self.test_data, self.test_labels)

        vote = self.vote_score <= vote_score

        self.set_weights(current_weights)
        return ProposedWeights(weights=weights,
                               vote_score=vote_score,
                               test_score=test_score,
                               vote=vote)
    def mli_test_weights(self, weights: Weights = None) -> ProposedWeights:
        try:
            if weights:
                response = self.stub.TestWeights(
                    weights_to_iterator(weights, encode=False))
            else:
                raise Exception(
                    "mli_test_weights(None) is not currently supported")

            return ProposedWeights(weights=weights,
                                   vote_score=response.vote_score,
                                   test_score=response.test_score,
                                   vote=response.vote)
        except grpc.RpcError as ex:
            _logger.exception(f"Failed to test_model: {ex}")
            raise ConnectionError(f"GRPC error: {ex}")
示例#4
0
    def mli_test_weights(self, weights) -> ProposedWeights:
        if weights.weights > self.current_value:
            test_score = 1.0
            vote_score = 1.0
            vote = True
        elif weights == self.current_value:
            test_score = 0.5
            vote_score = 0.5
            vote = False
        else:
            test_score = 0.0
            vote_score = 0.0
            vote = False

        result = ProposedWeights(weights=weights,
                                 vote_score=vote_score,
                                 test_score=test_score,
                                 vote=vote)

        return result
示例#5
0
    def mli_test_weights(self, weights: Weights) -> ProposedWeights:
        """
        Tests given weights on training and test set and returns weights with score values
        :param weights: Weights to be tested
        :return: ProposedWeights - Weights with vote and test score
        """

        current_weights = self.mli_get_current_weights()
        self.set_weights(weights)

        vote_score = self.test(self.vote_data, self.vote_labels)

        test_score = self.test(self.test_data, self.test_labels)

        vote = self.vote_score <= vote_score

        self.set_weights(current_weights)
        return ProposedWeights(weights=weights,
                               vote_score=vote_score,
                               test_score=test_score,
                               vote=vote)
示例#6
0
    def mli_test_weights(self, weights: Weights) -> ProposedWeights:
        """
        Tests given weights on training and test set and returns weights with score values
        :param weights: Weights to be tested
        :return: ProposedWeights - Weights with vote and test score
        """
        current_weights = self.mli_get_current_weights()
        self.set_weights(weights)

        vote_score = self.test(self.train_loader)

        if self.test_loader:
            test_score = self.test(self.test_loader)
        else:
            test_score = 0
        vote = self.vote(vote_score)

        self.set_weights(current_weights)
        return ProposedWeights(weights=weights,
                               vote_score=vote_score,
                               test_score=test_score,
                               vote=vote)