How to do Onehotencoding in Sklearn Pipeline : <p>I am trying to oneHotEncode the categorical variables of my Pandas dataframe, which includes both categorical and continues variables. I realise this can be done easily with the pandas .get_dummies() function, but I need to use a pipeline so I can generate a PMML-file later on.</p>

<p>This is the code to create a mapper. The categorical variables I would like to encode are stored in a list called 'dummies'.</p>

<pre><code>from sklearn_pandas import DataFrameMapper
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import LabelEncoder

mapper = DataFrameMapper(
    [(d, LabelEncoder()) for d in dummies] +
    [(d, OneHotEncoder()) for d in dummies]
)
</code></pre>

<p>And this is the code to create a pipeline, including the mapper and linear regression.</p>

<pre><code>from sklearn2pmml import PMMLPipeline
from sklearn.linear_model import LinearRegression

lm = PMMLPipeline([("mapper", mapper),
                   ("regressor", LinearRegression())])
</code></pre>

<p>When I now try to fit (with 'features' being a dataframe, and 'targets' a series), it gives an error 'could not convert string to float'.</p>

<pre><code>lm.fit(features, targets)
</code></pre>

<p>Anyone who can help me out? I am desperate for working pipelines including the preprocessing of data... Thanks in advance!</p>
