Sameer Asal
Sameer Asal

Reputation: 133

Sequence Pattern recognition with Pybrain

I am trying to use Recurrent Neural networks to classify a series of contiguous data. To be more specific, I have a sequence (that that are continuous in time) of reading from sensors, I need to learn an algorithm that looking at the way the readings change can detect the state related to this pattern.

Example:

Time step_1: 1.4

Time step_2: 1

Time step_3: 0.8

State = Walking. New Sequence:

Time step 1: 0.4

Time step 2: 0.3

Time step 3: 0.1

State = sitting

I actually have 12 sensors, I am only showing one sequence of numbers for convenience. (Numbers are not real, I am just trying to get the idea across) !

I am trying to build my network with Pybrain RNN, However, I can't find a data set container that can detect that kind of information. I tried using SequentialData but after some testing I thing what it it learns is the next element in a sequence of numbers. Here how I build my DataSet:

self.alldata = SequentialDataSet(ds.num_features, 1)
# Now add the samples to the data set.
idx = 1 
self.alldata.newSequence()
for sample in ds.all_moves:
  self.alldata.addSample(sample.get_features(), [ds.get_classes().index(sample.class_)])
  idx += 1
  if (idx%6 == 0): #I want every 6 consecutive readings at a time
    pdb.set_trace()
    self.alldata.newSequence()


self.tstdata, self.trndata = self.alldata.splitWithProportion(0.25)

Any Ideas on how I can do this differently, Does Pybrain deal with this kind of classification Problem anyway ?

Upvotes: 1

Views: 1248

Answers (1)

jorgenkg
jorgenkg

Reputation: 4275

A solution

You could implement this strategy: enter image description here

You should probably have 12 sensor inputs plus one extra input which represents the classification from timestep t-1. I've simplified the drawing by only showing 4 inputs.

Upvotes: 1

Related Questions