Skip to main content

AllenNLP integration for sklearn-pandas

CI Release Python PyPI

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

Installation

Installing the library and dependencies is simple using pip.

$ pip install allennlp-dataframe-mapper

Example

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

Config

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,
}

Mapper

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)

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

mapper.fit_transform(df)

License

MIT

Metadata

Release files for allennlp-dataframe-mapper 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for allennlp-dataframe-mapper 0.3.0
File Size Uploaded
allennlp-dataframe-mapper-0.3.0.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for allennlp-dataframe-mapper 0.3.0
File Interpreter ABI Platform
allennlp_dataframe_mapper-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / allennlp-dataframe-mapper-0.3.0.tar.gz

Download URL allennlp-dataframe-mapper-0.3.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
26ef63021540c4b53c13024b99c694c1af3bd6e6edf4b739f3bc0cbdb4a7fc7c
BLAKE2b-256 checksum
How to use checksums
489d1f3dd8c791ba1f9c3f45306d156d275ea68d64f0595c381d98e031173a35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.4 Linux/5.13.0-1021-azure

Release files / allennlp_dataframe_mapper-0.3.0-py3-none-any.whl

Download URL allennlp_dataframe_mapper-0.3.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27353db175e0906b6c1affbd29deca5b34834bceb3238ee3f87697835b229617
BLAKE2b-256 checksum
How to use checksums
7d4363536a7aad10febe2b5a053a3f84118b65bc04f65efd8d00a8f45b8e603d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.4 Linux/5.13.0-1021-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page