Skip to content

Instantly share code, notes, and snippets.

@swati210994
Created October 14, 2020 06:21
Show Gist options
  • Select an option

  • Save swati210994/d1b2429551c10f16c5b4fb94f1e7d4bc to your computer and use it in GitHub Desktop.

Select an option

Save swati210994/d1b2429551c10f16c5b4fb94f1e7d4bc to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>label</th>\n",
" <th>text</th>\n",
" <th>gt</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3544</th>\n",
" <td>ham</td>\n",
" <td>thank meet monday</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3984</th>\n",
" <td>ham</td>\n",
" <td>whatever juliana whatever want</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>675</th>\n",
" <td>ham</td>\n",
" <td>dont knw drink milk</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1872</th>\n",
" <td>ham</td>\n",
" <td>didnt know meant yep baby jontin</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1416</th>\n",
" <td>ham</td>\n",
" <td>hours went hair cut</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" label text gt\n",
"3544 ham thank meet monday 0\n",
"3984 ham whatever juliana whatever want 0\n",
"675 ham dont knw drink milk 0\n",
"1872 ham didnt know meant yep baby jontin 0\n",
"1416 ham hours went hair cut 0"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data['gt'] = data['label'].map({'ham':0,'spam':1})\n",
"data.head()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(5572, 5572)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sentences=data['text']\n",
"labels=data['gt']\n",
"len(sentences),len(labels)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment