本文整理汇总了Python中pybrain.datasets.ClassificationDataSet.assignClasses方法的典型用法代码示例。如果您正苦于以下问题:Python ClassificationDataSet.assignClasses方法的具体用法?Python ClassificationDataSet.assignClasses怎么用?Python ClassificationDataSet.assignClasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.datasets.ClassificationDataSet
的用法示例。
在下文中一共展示了ClassificationDataSet.assignClasses方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_dataset
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import assignClasses [as 别名]
def create_dataset(filename):
dataset = ClassificationDataSet(13, 1, class_labels=['0', '1', '2'])
football_data = FootballDataCsv(filename)
total_min = football_data.total_min()
total_max = football_data.total_max()
for data in football_data:
normalized_features = [normalize(x, min_value=total_min, max_value=total_max) for x in data.to_list()]
dataset.addSample(normalized_features, [data.binarized_output])
dataset.assignClasses()
dataset._convertToOneOfMany()
return dataset
示例2: generateClassificationData
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import assignClasses [as 别名]
def generateClassificationData(size, nClasses=3):
""" generate a set of points in 2D belonging to two or three different classes """
if nClasses==3:
means = [(-1,0),(2,4),(3,1)]
else:
means = [(-2,0),(2,1),(6,0)]
cov = [diag([1,1]), diag([0.5,1.2]), diag([1.5,0.7])]
dataset = ClassificationDataSet(2, 1, nb_classes=nClasses)
for _ in xrange(size):
for c in range(3):
input = multivariate_normal(means[c],cov[c])
dataset.addSample(input, [c%nClasses])
dataset.assignClasses()
return dataset
示例3: generate_data
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import assignClasses [as 别名]
def generate_data( hour_to_use_app = 10):
"""
Generate sample data to verify a classification learning NN.
"""
dataset = ClassificationDataSet(4, 1, nb_classes=2)
for month in xrange(1,12): # month 12 reserved for tests
for day in xrange(1,8):
for hour in xrange(0,24):
for minute in xrange(1,7):
if hour == hour_to_use_app :
c = 1
else :
c = 0
input = [month,day,hour,minute]
dataset.addSample(input, [c])
dataset.assignClasses()
return dataset
示例4: range
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import assignClasses [as 别名]
# 0 is red, 1 is blue
color_class = [
0, 0, 0, 0,
0, 0, 0, 0,
1, 1, 1, 1,
1, 1, 1, 1
]
# add samples to dataset
for i in range(len(color)):
indata = color[i]
outdata = color_class[i]
trndata.addSample(indata, [outdata])
print('[%d, %d, %d], [%d]' % (indata[0], indata[1], indata[2], outdata))
trndata.assignClasses()
net = buildNetwork(trndata.indim, 6, trndata.outdim)
# net = buildNetwork(
# trndata.indim, 6, trndata.outdim, recurrent=False, bias=False
# )
trainer = BackpropTrainer(
net, dataset=trndata, learningrate=0.01, momentum=0.5, verbose=True
)
# # train on dataset with X epochs
# t.trainOnDataset(ds, 50)
# t.testOnData(verbose=True)
print('')