On Mon, Jan 13, 2014 at 3:44 PM, Christian Hudon <
chr...@pianocktail.org> wrote:
> Hi again,
>
> I'm trying to use patsy to convert a pandas DataFrame into a matrix that can
> be handed off to a neural network. The training of said neural network is
> done in a separate process (batch) from the prediction requests. So I need
> to save the DesignMatrixBuilder instances that I get from applying the patsy
> formula to the training set, so they can be applied to predict requests.
> However, when I try to pickle the DesignMatrixBuilder instances, I get a
> PicklingError.
>
> Here is an example that shows the problem:
>
> ----cut here----
>
> from patsy import dmatrices, demo_data
> import pickle
> import pandas as pd
>
> dataset = pd.DataFrame(demo_data('a', 'b', 'c', 'x', 'y1', 'y2'))
> formula = "y1 ~ x"
>
> target_matrix, input_matrix = dmatrices(formula, dataset)
> pickle.dumps(input_matrix.design_info.builder)
>
interactions, automatic categorical handling, etc. you don't need