minor adjustments
This commit is contained in:
parent
eaa40ec370
commit
5e2af0697e
@ -22,7 +22,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -36,7 +36,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -60,7 +60,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -76,7 +76,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -99,7 +99,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -1191,7 +1191,7 @@
|
||||
"[68733 rows x 9 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -1210,7 +1210,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1229,7 +1229,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1247,7 +1247,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1264,7 +1264,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1277,18 +1277,11 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"mlb_multi = MultiLabelBinarizer()\n",
|
||||
"mlb_single = MultiLabelBinarizer()\n",
|
||||
"\n",
|
||||
"multi_labels = mlb_multi.fit_transform(emojis)\n",
|
||||
"single_labels = mlb_single.fit_transform(np.array([latest(x) for x in emojis]))\n",
|
||||
"\n",
|
||||
"mlb = mlb_single if SINGLE_LABEL else mlb_multi\n",
|
||||
"labels = single_labels if SINGLE_LABEL else multi_labels"
|
||||
"labels = [emoji2sent(latest(x)) for x in emojis]"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1300,7 +1293,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1341,7 +1334,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1350,16 +1343,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"y1_weights = np.array([(sum([emoji_weights[e] for e in e_list]) / len(e_list)) if len(e_list) > 0 else 0 for e_list in mlb.inverse_transform(y1)])"
|
||||
"y1_weights = np.array([(sum([emoji_weights[e] for e in e_list]) / len(e_list)) if len(e_list) > 0 else 0 for e_list in sent2emoji(y1)])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1619,7 +1612,9 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# build a dataframe to visualize test results:\n",
|
||||
"testlist = pd.DataFrame({'text': Xt1, 'teacher': (mlb_single if SINGLE_LABEL else mlb).inverse_transform(yt1), 'predict': (mlb_single if SINGLE_LABEL else mlb).inverse_transform(binary_pred)})"
|
||||
"testlist = pd.DataFrame({'text': Xt1, \n",
|
||||
" 'teacher': mlb_single.inverse_transform(yt1) if SINGLE_LABEL else sent2emoji(yt1), \n",
|
||||
" 'predict': mlb_single.inverse_transform(binary_pred) if SINGLE_LABEL else sent2emoji(binary_pred)})"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -2214,7 +2209,7 @@
|
||||
" \n",
|
||||
" binary_pred = np.array(binary_pred)\n",
|
||||
" \n",
|
||||
" display(Markdown(\"# \" + str((mlb_single if SINGLE_LABEL else mlb).inverse_transform(binary_pred))))\n",
|
||||
" display(Markdown(\"# \" + str(mlb_single.inverse_transform(binary_pred) if SINGLE_LABEL else sent2emoji(binary_pred))))\n",
|
||||
"\n",
|
||||
"b.on_click(handle_submit)\n",
|
||||
" \n",
|
||||
|
Loading…
Reference in New Issue
Block a user