added some statistical evaluation

This commit is contained in:
Jonas Weinz 2018-06-11 21:26:49 +02:00
parent 63a838df5e
commit 0a97b9aff1

View File

@ -2412,6 +2412,86 @@
"display(testlist)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* exactly correct labeled sentences:"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.21221374045801528\n"
]
}
],
"source": [
"print (sum([1 if sample[1]['teacher'] == sample[1]['predict'] else 0 for sample in testlist.iterrows()]) / testlist.shape[0])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* mean squared error:"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.02218067, 0.02490165, 0.00302656])"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"teacher_sentiments = np.array([sample[1]['teacher_sentiment'] for sample in testlist.iterrows()])\n",
"predicted_sentiments = np.array([sample[1]['predicted_sentiment'] for sample in testlist.iterrows()])\n",
"\n",
"mean_squared_error = ((teacher_sentiments - predicted_sentiments)**2).mean(axis=0)\n",
"display(mean_squared_error)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* by an overall variance of:"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Variance teacher: [0.02183094 0.02513847 0.00285735]\n",
"Variance prediction: [0.00863898 0.00919997 0.00082446]\n"
]
}
],
"source": [
"print(\"Variance teacher: \", np.var(teacher_sentiments, axis=0))\n",
"print(\"Variance prediction: \", np.var(predicted_sentiments, axis=0))"
]
},
{
"cell_type": "code",
"execution_count": 35,
@ -2541,13 +2621,13 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9c34c24b4df140f9ab22ded811cf8f89",
"model_id": "8a4248b8f8d147a58cdc02f4be7fbe03",
"version_major": 2,
"version_minor": 0
},
@ -2561,12 +2641,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7fb503b1cbb9472da347289cc130f838",
"model_id": "525901f072994db2a57e654faa5b9b39",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Button(description='get smiley', icon='check', style=ButtonStyle(), tooltip='Click me'), Output…"
"VBox(children=(Button(description='get emoji', icon='check', style=ButtonStyle(), tooltip='Click me'), Output(…"
]
},
"metadata": {},
@ -2578,7 +2658,7 @@
"\n",
"t = widgets.Text()\n",
"b = widgets.Button(\n",
" description='get smiley',\n",
" description='get emoji',\n",
" disabled=False,\n",
" button_style='', # 'success', 'info', 'warning', 'danger' or ''\n",
" tooltip='Click me',\n",
@ -2593,7 +2673,7 @@
" with out:\n",
" pred = clf.predict(vectorizer.transform([t.value]))\n",
" \n",
" display(Markdown(\"# \" + str(sent2emoji(pred, lookup_emojis))))\n",
" display(Markdown(\"# \" + str(sent2emoji(pred, lookup_emojis)[0])))\n",
"\n",
"b.on_click(handle_submit)\n",
" \n",
@ -2627,10 +2707,8 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": []
}
],