本文整理汇总了Python中NeuralNetwork.NeuralNetwork.normalize方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNetwork.normalize方法的具体用法?Python NeuralNetwork.normalize怎么用?Python NeuralNetwork.normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork.NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork.normalize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NeuralNetwork
# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import normalize [as 别名]
""" Which dataset would you like to test?"""
# 0 = Iris dataset
# 1 = Pima Indians dataset
dataset = 0
if dataset == 0:
filename = "datasets/iris.data"
targets = ['Iris-setosa', 'Iris-virginica', 'Iris-versicolor']
elif dataset == 1:
filename = "datasets/pima-indians-diabetes.data"
targets = [0, 1]
# Create the network
nn = NeuralNetwork()
nn.loadDataset(filename)
nn.normalize()
nn.createNetwork([2, 3], targets)
numCorrect = 0
# Make the predictions
for i in range(1):
nn.feed(nn.testingSet[i])
print("Instance", i + 1, ": predicted =", nn.getClassification(), "actual =", nn.testingSet[i][-1])
if nn.getClassification() == nn.testingSet[i][-1]:
numCorrect += 1
nn.propagateBack()
# Output the accuracy
accuracy = (float(numCorrect) / len(nn.testingSet)) * 100.0