Skip to main content

No project description provided

Project description

AllenNLP integration for sklearn-pandas

CI Release Python PyPI

allennlp-dataframe-mapper is a Python library that provides AllenNLP integration for sklearn-pandas.


Installing the library and dependencies is simple using pip.

$ pip install allennlp-dataframe-mapper


This library enables users to specify the in a jsonnet config file. Here is an example of the mapper for a famous iris dataset.


allennlp-dataframe-mapper is specified the transformations of the mapper in jsonnet config file like following mapper_iris.jsonnet:

    "type": "default",
    "features": [
        [["sepal length (cm)"], null],
        [["sepal width (cm)"], null],
        [["petal length (cm)"], null],
        [["petal width (cm)"], null],
        [["species"], [{"type": "flatten"}, {"type": "label-encoder"}]],
    "df_out": true,


The mapper takes a param of transformations from the config file. We can use the fit_transform shortcut to both fit the mapper and see what transformed data.

from allennlp.common import Params
from allennlp_dataframe_mapper import DataFrameMapper

params = Params.from_file("mapper_iris.jsonnet")
mapper = DataFrameMapper.from_params(params=params)

# DataFrameMapper(df_out=True,
#                 features=[(['sepal length (cm)'], None, {}),
#                           (['sepal width (cm)'], None, {}),
#                           (['petal length (cm)'], None, {}),
#                           (['petal width (cm)'], None, {}),
#                           (['species'], [FlattenTransformer(), LabelEncoder()], {})])




Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

allennlp-dataframe-mapper-0.3.0.tar.gz (4.8 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page