Python - 如何实现概率神经网络?

时间:2017-04-22 02:24:36

标签: python neural-network

我想应用概率神经网络。我的data.csv文件包含第一列中的值。值是浮点值。我遇到了以下错误:

  

回溯(最近一次调用最后一次):文件" G:/Setups/Python/pnn-1.py",   第10行,在       input_dataset_target = genfromtxt(filename,delimiter =',',skip_header = 0,usecols =(TARGET_COLUMN-1))文件   " G:\ Setups \ Python \ lib \ site-packages \ numpy \ lib \ npyio.py",第1769行,   genfromtxt       提出ValueError(errmsg)

我执行的代码:

import numpy as np
from sklearn.cross_validation import StratifiedKFold
from neupy.algorithms import PNN

filename = "data.csv"
TARGET_COLUMN = 2

from numpy import genfromtxt
input_dataset_data = 
genfromtxt(filename,delimiter=',',skip_header=0,usecols=
(range(0,TARGET_COLUMN-1)))
input_dataset_target = genfromtxt(filename, delimiter=',', skip_header=0, 
usecols=(TARGET_COLUMN-1))

kfold_number = 2

skfold = StratifiedKFOld(input_dataset_target, kfold_number, shuffle=True)
average_result = 0

print("> Start classify input_dataset dataset")

for i, (train, test) in enumerate(skfold, start=1):

pnn_network = PNN(std=0.1, step=0.2, verbose=True)

pnn_network.train(input_dataset_data[train], input_dataset_target[train])
predictions = pnn_network.predict(input_dataset_data[test])

print(predictions)
#print(input_dataset_target[test])

mcc = matthews_corrcoef(input_dataset_target[test], predictions)
print ("The Matthews correlation coefficient is %f" % mcc)

print("kfold #{:<2}: Guessed {} out of {}".format(
    i, np.sum(predictions == input_dataset_target[test]), test.size
    ))

0 个答案:

没有答案