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


Python SupervisedDataSet.appendLinked方法代码示例

本文整理汇总了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]
开发者ID:martin1,项目名称:thesis,代码行数:29,代码来源:neural_networks.py

示例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)
开发者ID:xldenis,项目名称:instabike,代码行数:31,代码来源:neural.py


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