No project description provided
Project description
AllenNLP integration for sklearn-pandas
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 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 params of transformations from the config file.
We can use the fit_transform
shortcut to bot 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for allennlp-dataframe-mapper-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9b051d0b4c11ff2c7a4b529574b923ac0fe59d35bce5fe3cd6894c0344167c2 |
|
MD5 | a7cabbed2578d8dd2a6093b9028222ab |
|
BLAKE2b-256 | a08d235b1accdc7dbc6fafe91e347486b858440d6755c9ec70921423f407ddc9 |
Close
Hashes for allennlp_dataframe_mapper-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fbae34c0be0a80939c8cabc80ad6cdb94250a393e1c8d8d4d2d3d397d0e1553 |
|
MD5 | 71c3c85e4508b7b8b72db40d6748f89c |
|
BLAKE2b-256 | 815832b1b6e50b9ca087db779437cc327720db090adc18b65dc421a3cb61e7fc |