Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f8287f0
custom data loader
ArshdeepSekhon Oct 29, 2020
bb1e021
custom textattack dataset from local files or in memory using hugging…
ArshdeepSekhon Oct 30, 2020
9195e1e
load user dataset from local files and convert to TextAttack dataset …
ArshdeepSekhon Nov 4, 2020
c1bd607
load user dataset from local files and convert to TextAttack dataset …
ArshdeepSekhon Nov 4, 2020
157bd21
load user dataset from local files and convert to textattack dataset …
ArshdeepSekhon Nov 4, 2020
3edd74b
load user dataset from local files and convert to textattack dataset …
ArshdeepSekhon Nov 4, 2020
29b0d9a
custom dataset: add attribute error
ArshdeepSekhon Nov 4, 2020
ea15f9a
custom dataset: remove stray prints
ArshdeepSekhon Nov 4, 2020
34b02ec
fix output column for custom dataset
ArshdeepSekhon Nov 4, 2020
af379af
custom dataset: add support for dict
ArshdeepSekhon Nov 4, 2020
6e07bd5
custom dataset: checks
ArshdeepSekhon Nov 4, 2020
2105de2
option to test on entire dataset
ArshdeepSekhon Oct 22, 2020
5f9a4c2
eval on entire dataset, checks
ArshdeepSekhon Oct 22, 2020
f238449
fix failed checks
ArshdeepSekhon Oct 22, 2020
2f00e33
custom data loader
ArshdeepSekhon Oct 29, 2020
793dbe0
custom textattack dataset from local files or in memory using hugging…
ArshdeepSekhon Oct 30, 2020
ae1c1f0
load user dataset from local files and convert to TextAttack dataset …
ArshdeepSekhon Nov 4, 2020
799f29e
load user dataset from local files and convert to TextAttack dataset …
ArshdeepSekhon Nov 4, 2020
97ea615
load user dataset from local files and convert to textattack dataset …
ArshdeepSekhon Nov 4, 2020
6172e24
load user dataset from local files and convert to textattack dataset …
ArshdeepSekhon Nov 4, 2020
d3e4269
custom dataset: add attribute error
ArshdeepSekhon Nov 4, 2020
92a54a5
custom dataset: remove stray prints
ArshdeepSekhon Nov 4, 2020
7b167ca
fix output column for custom dataset
ArshdeepSekhon Nov 4, 2020
601371d
custom dataset: add support for dict
ArshdeepSekhon Nov 4, 2020
9d0ed54
custom dataset: checks
ArshdeepSekhon Nov 4, 2020
12aab83
skeleton code for custom dataset
ArshdeepSekhon Nov 24, 2020
474bfa7
Merge branch 'custom_dataset' of https://github.com/ArshdeepSekhon/Te…
ArshdeepSekhon Nov 24, 2020
7f746d1
add utils for reading from files
ArshdeepSekhon Nov 25, 2020
7d91be2
add support for reading from csv, df, txt
ArshdeepSekhon Nov 25, 2020
7d2f976
fix format errors
ArshdeepSekhon Dec 4, 2020
9222066
update the confusing word"Successes" to "True Positive/Positive"
qiyanjun Dec 4, 2020
5c172b2
update the confusing uses of "Successes" to "True Positive/Positive"
qiyanjun Dec 4, 2020
11d2930
Merge branch 'master' into custom_dataset
ArshdeepSekhon Dec 4, 2020
36c83b3
black,isort formatting
ArshdeepSekhon Dec 4, 2020
f6fb8c5
Update dataset.py
qiyanjun Dec 5, 2020
41c5ef5
fix a wrong typo
qiyanjun Dec 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
custom dataset: add support for dict
  • Loading branch information
ArshdeepSekhon committed Nov 4, 2020
commit af379af99155b3167b0e1941bb125d125b0dddf4
22 changes: 12 additions & 10 deletions textattack/datasets/custom_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
self,
name,
infile_format=None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think file_format is an easier term to remember.

split="train",
split=None,
label_map=None,
subset=None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see subset argument being used anywhere in the code when loading the examples (other than in logging part). I think subset is used in HuggingFaceDataset because datasets like glue has subsets (e.g. sst2), but I don't see the point here. Do you think it is redundant?

output_scale_factor=None,
Expand All @@ -49,20 +49,21 @@ def __init__(
self._name = name

if infile_format in ["csv", "json", "text", "pandas"]:
self._dataset = datasets.load_dataset(infile_format, data_files=self._name)[
split
]
self._dataset = datasets.load_dataset(infile_format, data_files=self._name)

else:
if isinstance(self._name, dict):
self._dataset = datasets.Dataset.from_dict(self._name)[split]
self._dataset = datasets.Dataset.from_dict(self._name)
elif isinstance(self._name, pd.DataFrame):
self._dataset = datasets.Dataset.from_pandas(self._name)[split]
self._dataset = datasets.Dataset.from_pandas(self._name)
else:
raise ValueError(
"Only accepts csv, json, text, pandas file infile_format or dicts and pandas DataFrame"
"Only accepts csv, json, text, pandas file infile_format, dict and pandas DataFrame"
)

if split is not None:
self._dataset = self._dataset[split]

subset_print_str = f", subset {_cb(subset)}" if subset else ""

textattack.shared.logger.info(
Expand Down Expand Up @@ -91,17 +92,18 @@ def __init__(
# if user hasnt specified an output column or dataset_columns is None, all dataset_columns are
# treated as input_columns
dataset_columns.append(None)

# if user has specified an output column, check if it exists in the inferred column names
# user can explicitly specify output column as None
if (
dataset_columns[1] is not None
and dataset_columns[1] not in self._dataset.column_names
):
# if user has specified an output column, user can specify output column as None

raise ValueError(
f"Could not find output column {dataset_columns[1]}. Found keys: {self._dataset.column_names}"
)
self.output_column = dataset_columns[1]
print(self.output_column)

self._i = 0
self.examples = list(self._dataset)

Expand Down