Feb 26, 2015

PDX Python User Group

Lightning Talk

 

 

Hobson Lane

@hobsonlane

Data

$ pip install pug
>>> df = pug.data.weather.get_airport('Fresno, CA')

pug now has data!

For testing machine learning approaches

which cleans csv from this URL:

Daily weather for any US airport:

pybrain.Network pug.ann.util.build_neural_net():

def build_neural_net(N_inp=7, N_hid=2):
    nn = pb.structure.FeedForwardNetwork()

    # layers
    inlay = pb.structure.LinearLayer(N_inp, name='input')
    nn.addInputModule(inlay)
    outlay = pb.structure.LinearLayer(1, name='output')
    nn.addOutputModule(outlay)

    # connections
    if N_hid:
        hidlay = pb.structure.LinearLayer(N_hid, name='hidden')
        nn.addModule(hidlay)
        in_to_hid = pb.structure.FullConnection(inlay, hidlay)
        hid_to_out = pb.structure.FullConnection(hidlay, outlay)
        nn.addConnection(in_to_hid)
        nn.addConnection(hid_to_out)
    else:
        in_to_out = pb.structure.FullConnection(inlay, outlay)
        nn.addConnection(in_to_out)

    nn.sortModules()
    return nn
def pybrain_dataset_from_dataframe(df, 
        inputs=['Max Humidity', ' Mean Humidity', ' Min Humidity'],
        outputs=['Max TemperatureF']):
    N_inp = len(inputs)
    N_out = len(outputs)

    ds = pb.datasets.SupervisedDataSet(N_inp, N_out)
    for sample in df[inputs + outputs].values:
        ds.addSample(sample[:N_inp], sample[N_inp:])
    return ds

pybrain.Dataset pug.ann.util.pybrain_dataset_from_dataframe():

Example ipynb 

pybrain -- lightning talk

By Hobson Lane

pybrain -- lightning talk

  • 3,286