本文整理汇总了Python中neuralnet.NeuralNet.score_data方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNet.score_data方法的具体用法?Python NeuralNet.score_data怎么用?Python NeuralNet.score_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neuralnet.NeuralNet
的用法示例。
在下文中一共展示了NeuralNet.score_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import score_data [as 别名]
def main():
"""Testing file to show neural network can learn linearly separable
data."""
data = np.genfromtxt("training.csv", delimiter=',').tolist()
shuffle(data)
# NOTE: We have to wrap every target value into a tuple, for the
# purpose of being able to classify n-tuples later
targets = list((sample[-1] if sample[-1] == 1 else 0,) for sample in data)
features = list(sample[:-1] for sample in data)
print "Starting to train..."
start = time()
num_features = len(features[0]) # Subtract one because of target values
nn = NeuralNet(num_features, max_epochs=2, default_bias="random",
learn_rate=.85, scale=0.1, verbose=True)
nn.train(features, targets)
print "Done with training. Took {0} seconds to train." \
.format(round(time() - start, 2))
print "Beginning with scoring..."
start = time()
scored_data = np.genfromtxt("data_features.csv", delimiter=",")
correct = np.genfromtxt("data_targets.csv", delimiter=",")
prediction = nn.score_data(scored_data)
print "Done with scoring. Took {0} seconds to score the dataset" \
.format(round(time() - start, 2))
num_incorrect = sum(1 for i in xrange(len(correct)) \
if correct[i] != prediction[i])
print "Total number incorrect: {0}".format(num_incorrect)