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


Python ClassificationDataSet.getClass方法代码示例

本文整理汇总了Python中pybrain.datasets.ClassificationDataSet.getClass方法的典型用法代码示例。如果您正苦于以下问题:Python ClassificationDataSet.getClass方法的具体用法?Python ClassificationDataSet.getClass怎么用?Python ClassificationDataSet.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pybrain.datasets.ClassificationDataSet的用法示例。


在下文中一共展示了ClassificationDataSet.getClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: range

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import getClass [as 别名]
#Target dimension is supposed to be 1
#The targets are class labels starting from zero
for i in range(N):
    alldata.appendLinked(Xdf.ix[i,:],Ydf['default_Yes'].ix[i,:])
#generate training and testing data sets
tstdata, trndata = alldata.splitWithProportion(0.10)
#classes are encoded into one output unit per class, that takes on a certain value if the class is present
trndata._convertToOneOfMany( )
tstdata._convertToOneOfMany( )
len(tstdata), len(trndata)
#calculate statistics and generate histograms
alldata.calculateStatistics()
print alldata.classHist
print alldata.nClasses
print alldata.getClass(1)

#########################################################################################
#########################################################################################
#########################################################################################
#########################################################################################
#construct the network
from pybrain.structure import FeedForwardNetwork
net=FeedForwardNetwork()

#constructing the input, hidden and output layers
from pybrain.structure import LinearLayer, SigmoidLayer
inLayer = LinearLayer(3,name="input_nodes")
hiddenLayer1 = SigmoidLayer(3,name="hidden_nodes1")
hiddenLayer2 = SigmoidLayer(3,name="hidden_nodes1")
outLayer = LinearLayer(2,name="output_node")
开发者ID:golbeck,项目名称:Classification,代码行数:32,代码来源:default_neuralnet2.py

示例2: range

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import getClass [as 别名]
        ds_training.appendLinked(image_vector, [category])
    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)
开发者ID:amatelin,项目名称:neural-networks,代码行数:33,代码来源:Image_processing.py


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