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 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
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.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec9c9daaa224e8b7f9e423c2551063b0cd0e3cd62683c9f92bc79432ac0116c8 |
|
MD5 | a3c8d35ec6b7bcdfbd943f6c4a91b7c9 |
|
BLAKE2b-256 | 634d9adfcc32c10c04540896d1332006c9aea6f898b140b4ed21612070bf7835 |
Close
Hashes for allennlp_dataframe_mapper-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c2cbd9befe6a19693c802b21ea8464b80237789a2aa8b23dee568e2b48085c4 |
|
MD5 | 2238c7de954075548022716735ebf645 |
|
BLAKE2b-256 | 51cd54105ab7e0c4d5f91b2e12a9476ae3a856bb3ef95bba3fbf5606893740d2 |