-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notebook to create pickle file for fms and labels
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
|
||
synergy-dataset/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pathlib import Path\n", | ||
"import pickle\n", | ||
"\n", | ||
"import synergy_dataset as sd\n", | ||
"import asreview as asr\n", | ||
"\n", | ||
"from asreview.models.feature_extraction import Tfidf\n", | ||
"\n", | ||
"print(\"synergy-dataset version\", sd.__version__)\n", | ||
"print(\"asreview version:\", asr.__version__)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"folder_pickle_files = Path(\"synergy-dataset\", \"pickles\")\n", | ||
"folder_pickle_files.mkdir(parents=True, exist_ok=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for dataset in sd.iter_datasets():\n", | ||
"\n", | ||
" df = dataset.to_frame().reset_index()\n", | ||
"\n", | ||
" X = Tfidf().fit_transform(df[\"title\"].fillna(\"\").values, df[\"abstract\"].fillna(\"\").values)\n", | ||
"\n", | ||
" with open(folder_pickle_files / f\"{dataset.name}.pkl\", \"wb\") as f:\n", | ||
" pickle.dump((X, df[\"label_included\"]), f)\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "asreview-dev", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |