本文整理汇总了Python中pybrain.datasets.ClassificationDataSet.getField方法的典型用法代码示例。如果您正苦于以下问题:Python ClassificationDataSet.getField方法的具体用法?Python ClassificationDataSet.getField怎么用?Python ClassificationDataSet.getField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.datasets.ClassificationDataSet
的用法示例。
在下文中一共展示了ClassificationDataSet.getField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ClassificationDataSet
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import getField [as 别名]
har_data=pd.read_csv('./HAR3.csv');
har_test_data = har_data.iloc[100000:110000,0:17];
har_test_label = har_data.iloc[100000:110000,17:18];
#error = 0.0120909090909
clf1 = joblib.load('./clfGB.pkl');
predict_test = clf1.predict(har_test_data);
test_accuracy_gb = clf1.score(har_test_data, har_test_label);
test_error_gb = 1-test_accuracy_gb;
#nn error = 0.245666666667
fnn = joblib.load('./nn.pkl');
alldata = ClassificationDataSet(17, nb_classes=5);
for i in range(len(har_test_data)):
t=int(har_test_label.iloc[i])-1;
alldata.addSample(har_test_data.iloc[i],[t]);
alldata._convertToOneOfMany(bounds=[0, 1]);
out = fnn.activateOnDataset(alldata);
out = out.argmax(axis=1);
out2=alldata.getField('target').argmax(axis=1);
length = len(out);
count=0;
for i in range(len(out)):
if out[i]!=out2[i]:
count+=1;
test_error_nn = float(count)/float(length);
test_accuracy_nn = 1-test_error_nn;
示例2: float
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import getField [as 别名]
ratio = float(float(num) / float(len(possibilities[names[i]])))
nr.append(ratio)
print ratio, column
else:
print column, "not an int or long", possibilities[names[i]], names[i]
return np.array(nr[:-1]), nr[-1]
dataset = ClassificationDataSet(46, 1, class_labels=possibilities['readmitted'])
for row in cursor.execute("select %s from diabetic_data limit 0, 10000" % columns):
xd, yd = createNPRow(row)
dataset.addSample(xd, yd)
nn = buildNetwork(dataset.indim, 20, dataset.outdim, outclass=SoftmaxLayer)
trainer = BackpropTrainer(nn, dataset=dataset, momentum=0.1, verbose=True, weightdecay=0.01)
print possibilities['readmitted']
print dataset.getField('target')
for x in range(10):
error = trainer.train()
print error
errors, success = 0,0
for row in cursor.execute("select %s from diabetic_data limit 50000, 101766" % columns):
xd, yd = createNPRow(row)
check = int(round(nn.activate(xd[:46])[0]))
if check > 1: check = 1
prediction = possibilities['readmitted'][check]
actual = possibilities['readmitted'][yd]
if prediction == actual:
match = "match"
success += 1
else:
示例3: range
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import getField [as 别名]
category+=1
category = 0
for shape in shapes:
for i in range(8):
image = imread('C:/Users/alexis.matelin/Documents/Neural Networks/Visual classification/shapes/testing/'+shape+str(i+1)+'.png', as_grey=True, plugin=None, flatten=None)
image_vector = image.flatten()
ds_testing.appendLinked(image_vector, [category])
ds_training.calculateStatistics()
ds_training.getClass(0)
print(ds_training.getField('target'))
ds_training._convertToOneOfMany(bounds=[0, 1])
ds_testing._convertToOneOfMany(bounds=[0, 1])
print(ds_training.getField('target'))
net = buildNetwork(1024,12, 12, 3, hiddenclass = TanhLayer, outclass=SoftmaxLayer)
trainer = BackpropTrainer(net, dataset=ds_training, verbose=True, learningrate=0.01)
trainer.trainUntilConvergence()
out = net.activateOnDataset(ds_testing)
out = out.argmax(axis=1)
示例4: range
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import getField [as 别名]
for i in range( epochs ):
mse = trainer.train()
rmse = sqrt(mse)
print "training RMSE, epoch {}: {}".format( i + 1, rmse )
#trainer.trainUntilConvergence( verbose = True, validationProportion = 0.15, maxEpochs = 1000, continueEpochs = 10 )
lb = preprocessing.LabelBinarizer()
lb.fit(YtestPos)
list(lb.classes_)
YtestPos = lb.transform(YtestPos)
ds.setField( 'input', XtestPos )
ds.setField( 'target', YtestPos )
x = ds.getField('input')
y = ds.getField('target')
trnresult = percentError( trainer.testOnClassData(),trndata['class'] )
tstresult = percentError( trainer.testOnClassData(dataset=x ), YtestPos.T )
print "epoch: %4d" % trainer.totalepochs, " train error: %5.2f%%" % trnresult,
" test error: %5.2f%%" % tstresult