1
$\begingroup$

How should I select interactions in order to be able to encode multi-level features using interactions of main features in my design?

I'm wanting to create an experimental design to be used to create a predictive model based on a number of categorical features with varying numbers of levels. I am using Python and have been playing with the pyDOE2 library. There are some key features where I'd like to maintain a full factorial design but use interactions between these features to encode other features.

Within this library, the fractional factorial function (fracfact) works well for my needs apart from it only allows binary features. For example, if I pass it a generator 'a b c abc' I get a full factorial design for three binary features with the fourth column created from the interactions between the first three.

import pyDOE2 as doe

doe.fracfact('a b c abc')

... results in ...

  a     b     c    abc
[-1,   -1,   -1,   -1],
[ 1,   -1,   -1,    1],
[-1,    1,   -1,    1],
[ 1,    1,   -1,   -1],
[-1,   -1,    1,    1],
[ 1,   -1,    1,   -1],
[-1,    1,    1,   -1],
[ 1,    1,    1,    1]

If my factors consisted of one factor with 4 levels, another with 8 and a final with only two I could represent these with a number of binary variables. The first 4 level factor could be represented by two binary factors (2^2 = 4 say a b). The second eight level factor by three binary factors (2^3 = 8 say c d e) and the third two level factor as a single binary factor (2^1 = 2 say f).

factor1 = 'a b '
factor2 = 'c d e '
factor3 = 'f'

doe.fracfact(factor1+factor2+factor3)

The above code will give me a full factorial design with the six binary factors required to encode the factors listed above. This give 2^6 rows (64 rows)

  a    b    c    d    e    f
[-1., -1., -1., -1., -1., -1.],
[ 1., -1., -1., -1., -1., -1.],
...

I have been trying to reuse combinations of these bits in order to encode other variables using interactions. For example:

factor4 = ' acf bcf adf bdf'

doe.fracfact(factor1+factor2+factor3+factor4)

The resulting four factors (acf, bcf, adf, bdf) do not encode all of the combinations expected for four two bit variables.

Below are the frequencies of all the combinations of these four factors generated from interactions:

acf bcf adf bdf count
-1  -1  -1  -1  8
1   -1  -1  -1  0
-1  1   -1  -1  0
1   1   -1  -1  8
-1  -1  1   -1  0
1   -1  1   -1  8
-1  1   1   -1  8
1   1   1   -1  0
-1  -1  -1  1   0
1   -1  -1  1   8
-1  1   -1  1   8
1   1   -1  1   0
-1  -1  1   1   8
1   -1  1   1   0
-1  1   1   1   0
1   1   1   1   8

How should I select interactions in order to be able to encode multi-level features using interactions of main features in my design? How do I ensure that if creating multiple multi-level features that I am aware of any interactions created between them?

$\endgroup$
  • $\begingroup$ You could try using an incomplete block design approach. $\endgroup$ – Dave2e May 20 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.