Ludwig: Using sequence combiner

Created on 6 Mar 2019  路  7Comments  路  Source: ludwig-ai/ludwig

I'd like to be able to process a sequence of records in an RNN. The following seems to work:

data:
x,y,label
a b c, d e f, 1
z x y, t r q, 0
a b c, d e f, 1
z x y, t r q, 0
a b c, d e f, 1
...
i.e., the first sequence of records is [[a, d],[b, e], [c, f]] with label 1.

model:
input_features:
name: x
type: sequence
encoder: embed
reduce_output: null
name: y
type: sequence
encoder: embed
reduce_output: null

combiner:
type: sequence
main_sequence_feature: x
encoder: rnn

output_features:
name: label
type: binary

The following does not:

data:
x,y,label
3.4 5.6 6.9, a b c, 1
3.4 5.6 6.9, a b c, 1
3.4 5.6 6.9, a b c, 1
3.4 5.6 6.9, a b c, 1

model
input_features:
name: x
type: timeseries
encoder: embed
reduce_output: null
name: y
type: sequence
encoder: embed
reduce_output: null

combiner:
type: sequence
main_sequence_feature: x
encoder: rnn

output_features:
name: label
type: binary

I don't really want to embed the time series features, but it seems like i need to specify some kind of encoder. At any rate...it doesn't work. Is there any way to support combining categorical and numerical features together and running through an rnn?

thanks!

bug waiting for answer

Most helpful comment

@yanisIk sequnce is a sequence of categories while timeseries is a sequence of numbers, you can combine them with the sequence combiner as long ad they are of the same length. Read the documentation here.

@BenMacKenzie i'm updating and merging the PR. Thank you! Also closing the thread,

All 7 comments

update:
I created a passthrough encoder which does nothing except reshape the input_sequence and changed line 144 in timeseries_feature.py so that the type would be tf.float32 instead of tf.int32 and I am able to train with the data set referenced above. am not very familiar with code base, so don't really know if this makes sense. in particular, is line 144 a bug?

Thanks for this, I was actually working EXACTLY on this issue locally, I just pushed that in this branch https://github.com/uber/ludwig/tree/timeseries_fix . Please try it out with your data and let me know if it works, as in case i will add it to master immediately.

I actually created a PR from that branch: https://github.com/uber/ludwig/pull/179

Out of curiosity, for which type of use case is this data format used ?

I'm asking because I'm looking into doing classification for timeseries data where my columns are numerical and categorical but I can't see how to achieve this with ludwig (the doc only shows the input feature as a sequence of numbers separated by spaces).

Thanks

hidden_size = input.sequence.shape[-1] rather than
hidden_size = input.sequence.shape()[-1] on line 72, but otherwise it seems to work!

thanks so much!!

Out of curiosity, for which type of use case is this data format used ?

I'm asking because I'm looking into doing classification for timeseries data where my columns are numerical and categorical but I can't see how to achieve this with ludwig (the doc only shows the input feature as a sequence of numbers separated by spaces).

Thanks

it's a pattern that we use for credit card or other transaction-oriented fraud detection

@yanisIk sequnce is a sequence of categories while timeseries is a sequence of numbers, you can combine them with the sequence combiner as long ad they are of the same length. Read the documentation here.

@BenMacKenzie i'm updating and merging the PR. Thank you! Also closing the thread,

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donfour10 picture donfour10  路  3Comments

tweak-wtf picture tweak-wtf  路  4Comments

gogasca picture gogasca  路  3Comments

serv picture serv  路  8Comments

samfultonschool picture samfultonschool  路  4Comments