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


Python ClassificationDataSet.loadFromFile方法代码示例

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


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

示例1: main

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import loadFromFile [as 别名]
def main():
    DS = ClassificationDataSet.loadFromFile("ClassifierDataSet")
    print DS.calculateStatistics()

    print type(DS)
    rates = measuredLearning(DS)
开发者ID:DanSGraham,项目名称:School-Projects,代码行数:8,代码来源:learner.py

示例2: buildNetwork

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import loadFromFile [as 别名]
from pybrain.structure import RecurrentNetwork, FeedForwardNetwork
from pybrain.structure import LinearLayer, SigmoidLayer, TanhLayer
from pybrain.structure import FullConnection
from pybrain.datasets import SupervisedDataSet, ClassificationDataSet
from pybrain.utilities import percentError
from pybrain.tools.shortcuts import buildNetwork
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.structure.modules import SoftmaxLayer, BiasUnit
from pylab import ion, ioff, figure, draw, contourf, clf, show, hold, plot
from scipy import diag, arange, meshgrid, where
from numpy.random import multivariate_normal
from numpy import array_equal
import pickle

DSSuperRaw = SupervisedDataSet.loadFromFile("Data/DSSuperRaw")
DSClassRaw = ClassificationDataSet.loadFromFile("Data/DSClassRaw")

DSSuperWhiten = SupervisedDataSet.loadFromFile("Data/DSSuperWhiten")
DSClassWhiten = ClassificationDataSet.loadFromFile("Data/DSClassWhiten")

DSSuperNorm = SupervisedDataSet.loadFromFile("Data/DSSuperNorm")
DSClassNorm = ClassificationDataSet.loadFromFile("Data/DSClassNorm")

layers = (14, 14, 8)

net = buildNetwork(*layers, hiddenclass=TanhLayer, bias=True, outputbias=True, outclass=SoftmaxLayer, recurrent=True)

TrainDS, TestDS = DSSuperNorm.splitWithProportion(0.7)

# TrainDS._convertToOneOfMany()
# TestDS._convertToOneOfMany()
开发者ID:audioocelot,项目名称:Website,代码行数:33,代码来源:NN_Pybrain.py

示例3: splitWithProportion

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import loadFromFile [as 别名]
# Produce two new datasets, the first one containing the fraction given by proportion of the samples.
# splitWithProportion(proportion=0.5)
# print len(ds)

# tstdata, trndata = alldata.splitWithProportion( 0.25 )

# for input, target in ds:
	# print input,target
	
# print ds['input']

# print ds['target']

#hidden class by default sigmoid
all_data=ClassificationDataSet.loadFromFile("nn-data")

# tstdata, trndata = all_data.splitWithProportion( 0.25 )
tstdata_temp, partdata_temp = all_data.splitWithProportion( 0.25 )

trndata_temp,validata_temp = partdata_temp.splitWithProportion(0.50)

tstdata = ClassificationDataSet(200, 1, nb_classes=2)
for n in xrange(0, tstdata_temp.getLength()):
	tstdata.addSample( tstdata_temp.getSample(n)[0], tstdata_temp.getSample(n)[1] )

trndata = ClassificationDataSet(200, 1, nb_classes=2)
for n in xrange(0, trndata_temp.getLength()):
    trndata.addSample( trndata_temp.getSample(n)[0], trndata_temp.getSample(n)[1] )
	
validata= ClassificationDataSet(200, 1, nb_classes=2)
开发者ID:thak123,项目名称:IASNLP-2016,代码行数:32,代码来源:nn-supervised.py

示例4: range

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import loadFromFile [as 别名]
from pybrain.datasets import ClassificationDataSet
print "Reading data set..."
DS = ClassificationDataSet.loadFromFile('dataset.csv')

#Split validation set
TestDS, TrainDS = DS.splitWithProportion( 0.25 )

#train svm
from svm import svm_problem, svm_parameter, libsvm, gen_svm_nodearray

#define problem with data from the pybrain dataset.
# best python explanation for libsvm is here: https://github.com/arnaudsj/libsvm/tree/master/python
#we have to convert the data to ints and lists because of the low-level c interface

prob = svm_problem([int(t) for t in TrainDS['target']],[list(i) for i in TrainDS['input']])
param = svm_parameter()
# option: -t 0: linear kernel. Best for classification.
# option: -c 0.01: regularization parameter. smaller is more regularization
# see below for all options
param.parse_options('-t 0 -c 0.01') 
print "Training svm..."
model = libsvm.svm_train(prob,param)

print "Testing svm with three random inputs"
from random import randrange
for j in range(3):
    i = randrange(0,len(TestDS))
    #again some conversion needed because of low level interface
    x0,m_idx = gen_svm_nodearray(list(TestDS['input'][i]))
    prediction = libsvm.svm_predict(model, x0)
    print("Target:{0}, prediction:{1}".format(TestDS['target'][i],prediction))
开发者ID:antonvh,项目名称:PySpamfilters,代码行数:33,代码来源:train_svm.py


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