コード例 #1
0
    def searchSolve(self, X, Y, updates, randomState=None):
        if "max_attempts" in updates:
            tempAttempts = updates["max_attempts"]
        else:
            tempAttempts = self.maxAttempts

        if "restarts" in updates:
            tempRestarts = updates["restarts"]
        else:
            tempRestarts = self.numRestarts

        if randomState is None:
            tempRandomState = self.randomState
        else:
            tempRandomState = randomState

        if "learning_rate" in updates:
            tempLearnRate = updates["learning_rate"]
        else:
            tempLearnRate = self.learnRate

        if "max_iters" in updates:
            tempMaxIters = updates["max_iters"]
        else:
            tempMaxIters = self.maxIters

        self.model = mlrose.NeuralNetwork(hidden_nodes = [5], activation = 'relu', \
                                        algorithm = self.algorithm, max_iters = tempMaxIters, \
                                        bias = True, is_classifier = True, learning_rate = tempLearnRate, \
                                        early_stopping = True, clip_max = 1e10, max_attempts = tempAttempts, \
                                        restarts = tempRestarts, curve = True, random_state = tempRandomState)
        self.model.fit(X, Y)
        yPred = self.model.predict(X)
        score = metrics.accuracy_score(Y, yPred)
        return score
コード例 #2
0
 def createModel(self):
     self.model = mlrose.NeuralNetwork(hidden_nodes = [5], activation = 'relu', \
                             algorithm = self.algorithm, max_iters = self.maxIters, \
                             bias = True, is_classifier = True, learning_rate = self.learnRate, \
                             early_stopping = False, clip_max = 1e10, max_attempts = self.maxAttempts, \
                             pop_size = self.popSize, mutation_prob = self.mutationProb, \
                             curve = True, random_state = self.randomState)
コード例 #3
0
 def solve(self, X, Y):
     self.model = mlrose.NeuralNetwork(hidden_nodes = [5], activation = 'relu', \
                                     algorithm = self.algorithm, max_iters = self.maxIters, \
                                     bias = True, is_classifier = True, learning_rate = self.learnRate, \
                                     early_stopping = False, clip_max = 1e10, max_attempts = self.maxAttempts, \
                                     restarts = self.numRestarts, curve = True, random_state = self.randomState)
     self.model.fit(X, Y)
     yPred = self.model.predict(X)
     score = metrics.accuracy_score(Y, yPred)
     return score