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


Python ClassificationDataSet.calculateStatistics方法代码示例

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


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

示例1: classifer

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import calculateStatistics [as 别名]
 def classifer(labels, data):
     """ data in format (value, label)
     """
     clsff = ClassificationDataSet(2,class_labels=labels)
     for d in data:
         clsff.appendLinked(d[0], d[1])
     clsff.calculateStatistics()
开发者ID:saromanov,项目名称:pybrainmongo,代码行数:9,代码来源:pybrainmongo.py

示例2: createDataset

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import calculateStatistics [as 别名]
def createDataset():
    data = ClassificationDataSet(100,nb_classes=len(lettersDict.keys()), class_labels=lettersDict.keys())
    allTheLetters = string.uppercase
    for letter in lettersDict.keys():
        data.addSample(lettersDict[letter], allTheLetters.index(letter)) 
    
    data._convertToOneOfMany(bounds=[0, 1])
    print data.calculateStatistics()

    return data
开发者ID:ssteku,项目名称:SoftComputing,代码行数:12,代码来源:CustomNetwork.py

示例3: bootstrap

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import calculateStatistics [as 别名]
def bootstrap(trndata, iter=100):
    """
    check http://sci2s.ugr.es/keel/pdf/specific/articulo/jain_boot_87.pdf for notation
    """
    print trndata.calculateStatistics()
    np_array = np.hstack((trndata['input'], trndata['target']))
    my_range = range(np_array.shape[0])

    print trndata['target'].shape

    app_sum = 0
    e0_sum = 0
    for i in range(iter):
        indices = list(set([random.choice(my_range) for i in my_range]))
        np_train_array = np.vstack(np_array[indices])
        new_training_samples = ClassificationDataSet(attributes, classes_number)
        new_training_samples.setField('input', np_train_array[:, :54])
        new_training_samples.setField('target', np_train_array[:, 54:55])
        new_training_samples._convertToOneOfMany()

        test_indices = list(set(my_range) - set(indices))
        new_test_samples = ClassificationDataSet(attributes, classes_number)
        np_test_array = np.vstack(np_array[test_indices])

        new_test_samples.setField('input', np_test_array[:, :54])
        new_test_samples.setField('target', np_test_array[:, 54:55])
        new_test_samples._convertToOneOfMany()

        print new_training_samples.calculateStatistics()
        print new_test_samples.calculateStatistics()

        model = FNNClassifier()
        model.train(new_training_samples, new_test_samples)

        (xtrn, ytrn) = model.predict(new_training_samples)
        (xtest, ytest) = model.predict(new_test_samples)

        app_sum += (1 - accuracy(xtrn, ytrn))
        e0_sum += (1 - accuracy(xtest, ytest))

    app = app_sum / float(iter)
    e0 = e0_sum / float(iter)

    e632 = 0.368 * app + 0.632 * e0

    print e632
    return e632
开发者ID:sacherus,项目名称:pca-image,代码行数:49,代码来源:forest_main.py

示例4: range

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import calculateStatistics [as 别名]
#convert back to a single column of class labels
#alldata._convertToClassNb()

#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")
开发者ID:golbeck,项目名称:Classification,代码行数:32,代码来源:default_neuralnet2.py

示例5: ClassificationDataSet

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import calculateStatistics [as 别名]
'''

# one-hot encoding  
wm_df = pd.get_dummies(df)
X = wm_df[wm_df.columns[1:-2]]  # input
Y = wm_df[wm_df.columns[-2:]]  # output
label = wm_df.columns._data[-2:] # class label

# construction of data in pybrain's formation
from pybrain.datasets import ClassificationDataSet
ds = ClassificationDataSet(19, 1, nb_classes=2, class_labels=label)  
for i in range(len(Y)): 
    y = 0
    if Y['好瓜_是'][i] == 1: y = 1
    ds.appendLinked(X.values[i], y)
ds.calculateStatistics()

# generation of train set and test set (3:1)
tstdata_temp, trndata_temp = ds.splitWithProportion(0.25)  
tstdata = ClassificationDataSet(19, 1, nb_classes=2, class_labels=label)
for n in range(0, tstdata_temp.getLength()):
    tstdata.appendLinked( tstdata_temp.getSample(n)[0], tstdata_temp.getSample(n)[1] )

trndata = ClassificationDataSet(19, 1, nb_classes=2, class_labels=label)
for n in range(0, trndata_temp.getLength()):
    trndata.appendLinked( trndata_temp.getSample(n)[0], trndata_temp.getSample(n)[1] )

trndata._convertToOneOfMany()
tstdata._convertToOneOfMany()

'''
开发者ID:LIUYONG04,项目名称:Machine-Learning_ZhouZhihua,代码行数:33,代码来源:BP_network.py

示例6: ClassificationDataSet

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import calculateStatistics [as 别名]
    data = [map(float, line.rstrip().split()) for line in f]
    # outputs = [[gene[-1]] for gene in data]
    # for gene in data:
    #     del gene[-1]

ds = ClassificationDataSet(6, 1)

for i, gene in enumerate(data):
    ds.addSample(gene[:-1], gene[-1])

tstdata, trndata = ds.splitWithProportion( 0.25 )

trndata._convertToOneOfMany( )
tstdata._convertToOneOfMany( )

print ds.calculateStatistics()
print ds.nClasses

print "Number of training patterns: ", len(trndata)
print "Input and output dimensions: ", trndata.indim, trndata.outdim
print "First sample (input, target, class):"
print trndata['input'][0], trndata['target'][0], trndata['class'][0]


fnn = buildNetwork( trndata.indim, 7, trndata.outdim, outclass=LinearLayer )

trainer = BackpropTrainer( fnn, dataset=trndata, momentum=0.1, verbose=True, weightdecay=0.01)

#
# ticks = arange(-3.,6.,0.2)
# X, Y = meshgrid(ticks, ticks)
开发者ID:jlsalmon,项目名称:sga,代码行数:33,代码来源:nntest.py

示例7: range

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


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