当前位置: 首页>>代码示例>>Python>>正文


Python NeuralNet.score_data方法代码示例

本文整理汇总了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)
开发者ID:hlin117,项目名称:FF-Neural-Net,代码行数:33,代码来源:main.py


注:本文中的neuralnet.NeuralNet.score_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。