-
Notifications
You must be signed in to change notification settings - Fork 456
custom dataset loader #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
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 bb1e021
custom textattack dataset from local files or in memory using hugging…
ArshdeepSekhon 9195e1e
load user dataset from local files and convert to TextAttack dataset …
ArshdeepSekhon c1bd607
load user dataset from local files and convert to TextAttack dataset …
ArshdeepSekhon 157bd21
load user dataset from local files and convert to textattack dataset …
ArshdeepSekhon 3edd74b
load user dataset from local files and convert to textattack dataset …
ArshdeepSekhon 29b0d9a
custom dataset: add attribute error
ArshdeepSekhon ea15f9a
custom dataset: remove stray prints
ArshdeepSekhon 34b02ec
fix output column for custom dataset
ArshdeepSekhon af379af
custom dataset: add support for dict
ArshdeepSekhon 6e07bd5
custom dataset: checks
ArshdeepSekhon 2105de2
option to test on entire dataset
ArshdeepSekhon 5f9a4c2
eval on entire dataset, checks
ArshdeepSekhon f238449
fix failed checks
ArshdeepSekhon 2f00e33
custom data loader
ArshdeepSekhon 793dbe0
custom textattack dataset from local files or in memory using hugging…
ArshdeepSekhon ae1c1f0
load user dataset from local files and convert to TextAttack dataset …
ArshdeepSekhon 799f29e
load user dataset from local files and convert to TextAttack dataset …
ArshdeepSekhon 97ea615
load user dataset from local files and convert to textattack dataset …
ArshdeepSekhon 6172e24
load user dataset from local files and convert to textattack dataset …
ArshdeepSekhon d3e4269
custom dataset: add attribute error
ArshdeepSekhon 92a54a5
custom dataset: remove stray prints
ArshdeepSekhon 7b167ca
fix output column for custom dataset
ArshdeepSekhon 601371d
custom dataset: add support for dict
ArshdeepSekhon 9d0ed54
custom dataset: checks
ArshdeepSekhon 12aab83
skeleton code for custom dataset
ArshdeepSekhon 474bfa7
Merge branch 'custom_dataset' of https://github.com/ArshdeepSekhon/Te…
ArshdeepSekhon 7f746d1
add utils for reading from files
ArshdeepSekhon 7d91be2
add support for reading from csv, df, txt
ArshdeepSekhon 7d2f976
fix format errors
ArshdeepSekhon 9222066
update the confusing word"Successes" to "True Positive/Positive"
qiyanjun 5c172b2
update the confusing uses of "Successes" to "True Positive/Positive"
qiyanjun 11d2930
Merge branch 'master' into custom_dataset
ArshdeepSekhon 36c83b3
black,isort formatting
ArshdeepSekhon f6fb8c5
Update dataset.py
qiyanjun 41c5ef5
fix a wrong typo
qiyanjun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
custom dataset: add support for dict
- Loading branch information
commit af379af99155b3167b0e1941bb125d125b0dddf4
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,7 @@ def __init__( | |
| self, | ||
| name, | ||
| infile_format=None, | ||
| split="train", | ||
| split=None, | ||
| label_map=None, | ||
| subset=None, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see |
||
| output_scale_factor=None, | ||
|
|
@@ -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( | ||
|
|
@@ -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) | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
file_formatis an easier term to remember.