本文整理汇总了Python中pybrain.datasets.supervised.SupervisedDataSet.appendLinked方法的典型用法代码示例。如果您正苦于以下问题:Python SupervisedDataSet.appendLinked方法的具体用法?Python SupervisedDataSet.appendLinked怎么用?Python SupervisedDataSet.appendLinked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.datasets.supervised.SupervisedDataSet
的用法示例。
在下文中一共展示了SupervisedDataSet.appendLinked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NN_data
# 需要导入模块: from pybrain.datasets.supervised import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.supervised.SupervisedDataSet import appendLinked [as 别名]
def NN_data(ts, max_lag):
'''Function for creating a normalized dataset suitable for training
PyBrain's neural networks from pandas Series object.
Returns: dataset suitable for neural net training, max value of
dataset for denormalization purposes'''
ds = SupervisedDataSet(max_lag, 1)
times = ts.index
prices = [item for item in normalize(ts.values)[0]]
target = list()
for item in prices:
target.append(item)
input_cols = list()
for i in range(1, max_lag+1):
col = prices[:-i]
while len(col) < len(prices):
col = ['nan'] + list(col)
input_cols.append(col)
#convert input columns to input rows
input_rows = zip(*input_cols)
#Remove rows containing 'nan'
input_rows = input_rows[max_lag:]
target = target[max_lag:]
for i in range(0, len(target)):
ds.appendLinked(input_rows[i], target[i])
return ds, normalize(ts.values)[1]
示例2: load_full
# 需要导入模块: from pybrain.datasets.supervised import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.supervised.SupervisedDataSet import appendLinked [as 别名]
import matplotlib.pyplot as plt
frame, _wea = load_full()
# frame = pandas.DataFrame(fnl)
# frame = (frame - frame.mean()) / (frame.max() - frame.min())
frame = (frame - frame.mean()) / (frame.var())
for k in [30]:
for i in frame.columns:
fnn = buildNetwork(k,10,1)
DS = SupervisedDataSet(k, 1)
dta = frame[i][:5000]
for j in xrange(0, len(dta) - (k+1)):
DS.appendLinked(dta[j:j+k], [dta[j+k+1]])
test = frame[i][5000:]
testDS = SupervisedDataSet(k, 1)
for j in xrange(0, len(test) - (k+1)):
testDS.appendLinked(test[j:j+k], [test[5000+i+k+1]])
trainer = BackpropTrainer(fnn, dataset=DS, momentum=0.1, verbose=False, weightdecay=0.01)
# for ep in range(0, 5):
# trainer.trainEpochs()
trainer.trainUntilConvergence(maxEpochs=20)
res = fnn.activateOnDataset(testDS)