2018-05-09 10:47:51 +02:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-05-13 10:12:19 +02:00
"# NLP-LAB Exercise 02 by Jonas Weinz (2571421)\n",
2018-05-09 16:50:59 +02:00
"## links:\n",
"\n",
"* Article: https://miguelmalvarez.com/2017/03/23/how-can-machine-learning-and-ai-help-solving-the-fake-news-problem/\n",
" * corresponding code: https://github.com/kjam/random_hackery/blob/master/Attempting%20to%20detect%20fake%20news.ipynb\n",
"\n",
"* Tutorial on Datacamp: https://www.datacamp.com/community/tutorials/scikit-learn-fake-news\n",
"\n",
"* liar dataset paper: https://www.cs.ucsb.edu/~william/papers/acl2017.pdf\n",
2018-05-17 10:38:34 +02:00
" * dataset: https://www.cs.ucsb.edu/~william/data/liar_dataset.zip\n",
"\n",
"* Mex Vocabulary: http://jens-lehmann.org/files/2015/semantics_mex.pdf"
2018-05-09 19:13:08 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-05-09 16:50:59 +02:00
"## Dependencies for this Notebook:\n",
2018-05-09 10:47:51 +02:00
"* library [rdflib](https://github.com/RDFLib/rdflib)\n",
2018-05-09 19:13:08 +02:00
" * install: `pip3 install rdflib`\n"
2018-05-09 10:47:51 +02:00
]
},
{
"cell_type": "code",
2018-05-09 19:13:08 +02:00
"execution_count": 1,
2018-05-09 10:47:51 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
]
}
],
"source": [
2018-05-11 12:19:53 +02:00
"%pylab inline"
2018-05-09 16:50:59 +02:00
]
},
{
"cell_type": "code",
2018-05-11 12:19:53 +02:00
"execution_count": 2,
2018-05-09 16:50:59 +02:00
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import itertools\n",
"import sklearn.utils as sku\n",
2018-05-09 19:13:08 +02:00
"from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer, HashingVectorizer\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.linear_model import PassiveAggressiveClassifier\n",
"from sklearn.naive_bayes import MultinomialNB\n",
"from sklearn import metrics\n",
"import matplotlib.pyplot as plt\n",
2018-05-13 12:44:36 +02:00
"from pprint import pprint as pp\n",
"from IPython.display import display, Markdown, Latex\n",
"import collections\n",
"import traceback\n",
2018-05-17 12:06:34 +02:00
"import os\n"
2018-05-09 16:50:59 +02:00
]
},
2018-05-09 19:13:08 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Tools used later"
]
},
{
"cell_type": "code",
2018-05-11 12:19:53 +02:00
"execution_count": 3,
2018-05-09 19:13:08 +02:00
"metadata": {},
"outputs": [],
"source": [
"def plot_confusion_matrix(cm, classes,\n",
" title,\n",
" normalize=False,\n",
" cmap=plt.cm.Blues):\n",
" fig_1, ax_1 = plt.subplots()\n",
" \"\"\"\n",
" See full source and example: \n",
" http://scikit-learn.org/stable/auto_examples/model_selection/plot_confusion_matrix.html\n",
" \n",
" This function prints and plots the confusion matrix.\n",
" Normalization can be applied by setting `normalize=True`.\n",
" \"\"\"\n",
" plt.imshow(cm, interpolation='nearest', cmap=cmap)\n",
2018-05-13 13:36:21 +02:00
" plt.title('Confusion Matrix for:\\n' + title)\n",
2018-05-09 19:13:08 +02:00
" plt.colorbar()\n",
" tick_marks = np.arange(len(classes))\n",
" plt.xticks(tick_marks, classes, rotation=45)\n",
" plt.yticks(tick_marks, classes)\n",
"\n",
" if normalize:\n",
" cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n",
" print(\"Normalized confusion matrix\")\n",
" else:\n",
" print('Confusion matrix, without normalization')\n",
"\n",
" thresh = cm.max() / 2.\n",
2018-05-17 10:38:34 +02:00
" \n",
" pp(cm)\n",
" \n",
2018-05-09 19:13:08 +02:00
" for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):\n",
" plt.text(j, i, cm[i, j],\n",
" horizontalalignment=\"center\",\n",
" color=\"white\" if cm[i, j] > thresh else \"black\")\n",
"\n",
" plt.tight_layout()\n",
" plt.ylabel('True label')\n",
" plt.xlabel('Predicted label')"
]
},
2018-05-13 10:12:19 +02:00
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
2018-05-13 12:44:36 +02:00
"def test_classifier(labels, title, Xt, yt, clf):\n",
" pred = clf.predict(Xt)\n",
" score = metrics.accuracy_score(yt, pred)\n",
" pp(\"score: \" + str(score))\n",
" cm = metrics.confusion_matrix(yt, pred, labels=labels)\n",
2018-05-22 16:40:46 +02:00
" plot_confusion_matrix(cm, classes=labels, title=title)\n",
" return cm"
2018-05-13 10:12:19 +02:00
]
},
2018-05-09 16:50:59 +02:00
{
2018-05-17 12:06:34 +02:00
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 5,
2018-05-09 16:50:59 +02:00
"metadata": {},
2018-05-17 12:06:34 +02:00
"outputs": [
{
"data": {
"text/plain": [
"\"\\nfrom rdflib import Graph, Literal, BNode, RDF, Namespace\\nfrom rdflib.namespace import FOAF, DC, XSD\\n\\nmexcore = Namespace('http://mex.aksw.org/mex-core#')\\nmexperf = Namespace('http://mex.aksw.org/mex-perf#')\\nmexalgo = Namespace('http://mex.aksw.org/mex-algo#')\\nprov = Namespace('http://www.w3.org/ns/prov#')\\n\\ndef create_mex_graph():\\n graph = Graph()\\n graph.bind(mexcore)\\n graph.bind(mexperf)\\n graph.bind(mexalgo)\\n graph.bind(prov)\\n graph.bind(FOAF)\\n graph.bind(DC)\\n graph.bind(XSD)\\n \\n return graph\\n\\ndef mex_performance(experiment, model, dataset, performance, phase='Train', graph=create_mex_graph()):\\n \\n p = BNode()\\n \\n\""
]
},
2018-05-22 16:40:46 +02:00
"execution_count": 5,
2018-05-17 12:06:34 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
2018-05-09 16:50:59 +02:00
"source": [
2018-05-17 12:06:34 +02:00
"'''\n",
"from rdflib import Graph, Literal, BNode, RDF, Namespace\n",
"from rdflib.namespace import FOAF, DC, XSD\n",
2018-05-09 16:50:59 +02:00
"\n",
2018-05-17 12:06:34 +02:00
"mexcore = Namespace('http://mex.aksw.org/mex-core#')\n",
"mexperf = Namespace('http://mex.aksw.org/mex-perf#')\n",
"mexalgo = Namespace('http://mex.aksw.org/mex-algo#')\n",
"prov = Namespace('http://www.w3.org/ns/prov#')\n",
"\n",
"def create_mex_graph():\n",
" graph = Graph()\n",
" graph.bind(mexcore)\n",
" graph.bind(mexperf)\n",
" graph.bind(mexalgo)\n",
" graph.bind(prov)\n",
" graph.bind(FOAF)\n",
" graph.bind(DC)\n",
" graph.bind(XSD)\n",
" \n",
" return graph\n",
"\n",
"def mex_performance(experiment, model, dataset, performance, phase='Train', graph=create_mex_graph()):\n",
" \n",
" p = BNode()\n",
" \n",
"'''"
2018-05-09 16:50:59 +02:00
]
},
2018-05-17 12:06:34 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Generate/Download Datasets we are working on\n",
"\n",
"* running bash script to download all needed data and store it into the `data` subfolder"
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 6,
2018-05-17 12:06:34 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"================================================================================\n",
"checking whether unzip is installed\n",
"================================================================================\n",
"UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.\n",
"\n",
"Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip/ ;\n",
"see ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites.\n",
"\n",
"Compiled with gcc 6.3.0 20170415 for Unix (Linux ELF).\n",
"\n",
"UnZip special compilation options:\n",
" ACORN_FTYPE_NFS\n",
" COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)\n",
" SET_DIR_ATTRIB\n",
" SYMLINKS (symbolic links supported, if RTL and file system permit)\n",
" TIMESTAMP\n",
" UNIXBACKUP\n",
" USE_EF_UT_TIME\n",
" USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)\n",
" USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)\n",
" UNICODE_SUPPORT [wide-chars, char coding: UTF-8] (handle UTF-8 paths)\n",
" LARGE_FILE_SUPPORT (large files over 2 GiB supported)\n",
" ZIP64_SUPPORT (archives using Zip64 for large files supported)\n",
" USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version 1.0.6, 6-Sept-2010)\n",
" VMS_TEXT_CONV\n",
" WILD_STOP_AT_DIR\n",
" [decryption, version 2.11 of 05 Jan 2007]\n",
"\n",
"UnZip and ZipInfo environment options:\n",
" UNZIP: [none]\n",
" UNZIPOPT: [none]\n",
" ZIPINFO: [none]\n",
" ZIPINFOOPT: [none]\n",
"================================================================================\n",
"successfully finished action: checking whether unzip is installed\n",
"================================================================================\n",
"================================================================================\n",
"downloading and unpacking https://www.cs.ucsb.edu/~william/data/liar_dataset.zip if not already existing\n",
"================================================================================\n",
"================================================================================\n",
"successfully finished action: downloading and unpacking https://www.cs.ucsb.edu/~william/data/liar_dataset.zip if not already existing\n",
"================================================================================\n",
"================================================================================\n",
"downloading and unpacking https://raw.githubusercontent.com/GeorgeMcIntire/fake_real_news_dataset/master/fake_or_real_news.csv.zip if not already existing\n",
"================================================================================\n",
"================================================================================\n",
"successfully finished action: downloading and unpacking https://raw.githubusercontent.com/GeorgeMcIntire/fake_real_news_dataset/master/fake_or_real_news.csv.zip if not already existing\n",
"================================================================================\n",
"================================================================================\n",
"downloading Helper script: script_dataset3.py\n",
"================================================================================\n",
"================================================================================\n",
"successfully finished action: downloading Helper script: script_dataset3.py\n",
"================================================================================\n"
]
}
],
2018-05-09 16:50:59 +02:00
"source": [
"%%bash\n",
"./Task_2_gen_data.sh"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-05-13 10:12:19 +02:00
"----\n",
"## configuration 1"
2018-05-09 16:50:59 +02:00
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 7,
2018-05-09 16:50:59 +02:00
"metadata": {},
"outputs": [],
"source": [
"df_1 = pd.read_csv('data/fake_or_real_news.csv').set_index('Unnamed: 0')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* display first 10 entries"
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 8,
2018-05-09 16:50:59 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"data": {
"text/plain": [
"(6335, 3)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"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>title</th>\n",
" <th>text</th>\n",
" <th>label</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Unnamed: 0</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>8476</th>\n",
" <td>You Can Smell Hillary’ s Fear</td>\n",
" <td>Daniel Greenfield, a Shillman Journalism Fello...</td>\n",
" <td>FAKE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10294</th>\n",
" <td>Watch The Exact Moment Paul Ryan Committed Pol...</td>\n",
" <td>Google Pinterest Digg Linkedin Reddit Stumbleu...</td>\n",
" <td>FAKE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3608</th>\n",
" <td>Kerry to go to Paris in gesture of sympathy</td>\n",
" <td>U.S. Secretary of State John F. Kerry said Mon...</td>\n",
" <td>REAL</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10142</th>\n",
" <td>Bernie supporters on Twitter erupt in anger ag...</td>\n",
" <td>— Kaydee King (@KaydeeKing) November 9, 2016 T...</td>\n",
" <td>FAKE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>875</th>\n",
" <td>The Battle of New York: Why This Primary Matters</td>\n",
" <td>It's primary day in New York and front-runners...</td>\n",
" <td>REAL</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6903</th>\n",
" <td>Tehran, USA</td>\n",
" <td>\\nI’ m not an immigrant, but my grandparents ...</td>\n",
" <td>FAKE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7341</th>\n",
" <td>Girl Horrified At What She Watches Boyfriend D...</td>\n",
" <td>Share This Baylee Luciani (left), Screenshot o...</td>\n",
" <td>FAKE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>‘ Britain’ s Schindler’ Dies at 106</td>\n",
" <td>A Czech stockbroker who saved more than 650 Je...</td>\n",
" <td>REAL</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4869</th>\n",
" <td>Fact check: Trump and Clinton at the 'commande...</td>\n",
" <td>Hillary Clinton and Donald Trump made some ina...</td>\n",
" <td>REAL</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2909</th>\n",
" <td>Iran reportedly makes new push for uranium con...</td>\n",
" <td>Iranian negotiators reportedly have made a las...</td>\n",
" <td>REAL</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" title \\\n",
"Unnamed: 0 \n",
"8476 You Can Smell Hillary’ s Fear \n",
"10294 Watch The Exact Moment Paul Ryan Committed Pol... \n",
"3608 Kerry to go to Paris in gesture of sympathy \n",
"10142 Bernie supporters on Twitter erupt in anger ag... \n",
"875 The Battle of New York: Why This Primary Matters \n",
"6903 Tehran, USA \n",
"7341 Girl Horrified At What She Watches Boyfriend D... \n",
"95 ‘ Britain’ s Schindler’ Dies at 106 \n",
"4869 Fact check: Trump and Clinton at the 'commande... \n",
"2909 Iran reportedly makes new push for uranium con... \n",
"\n",
" text label \n",
"Unnamed: 0 \n",
"8476 Daniel Greenfield, a Shillman Journalism Fello... FAKE \n",
"10294 Google Pinterest Digg Linkedin Reddit Stumbleu... FAKE \n",
"3608 U.S. Secretary of State John F. Kerry said Mon... REAL \n",
"10142 — Kaydee King (@KaydeeKing) November 9, 2016 T... FAKE \n",
"875 It's primary day in New York and front-runners... REAL \n",
"6903 \\nI’ m not an immigrant, but my grandparents ... FAKE \n",
"7341 Share This Baylee Luciani (left), Screenshot o... FAKE \n",
"95 A Czech stockbroker who saved more than 650 Je... REAL \n",
"4869 Hillary Clinton and Donald Trump made some ina... REAL \n",
"2909 Iranian negotiators reportedly have made a las... REAL "
]
},
"metadata": {},
"output_type": "display_data"
}
],
2018-05-09 16:50:59 +02:00
"source": [
"display(df_1.shape)\n",
"display(df_1[:10])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* create test dataset"
2018-05-09 10:47:51 +02:00
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 9,
2018-05-09 10:47:51 +02:00
"metadata": {},
"outputs": [],
2018-05-09 16:50:59 +02:00
"source": [
2018-05-13 13:36:21 +02:00
"X1, Xt1, y1, yt1 = train_test_split(df_1.drop('label', axis=1)['text'], df_1.label, test_size=0.25, random_state=4222)"
2018-05-09 16:50:59 +02:00
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 10,
2018-05-09 16:50:59 +02:00
"metadata": {},
"outputs": [],
2018-05-09 19:13:08 +02:00
"source": [
2018-05-17 10:38:34 +02:00
"vectorizer_1 = TfidfVectorizer(stop_words='english', max_df=0.7)\n",
2018-05-13 18:29:18 +02:00
"vec_train_1 = vectorizer_1.fit_transform(X1)\n",
"vec_test_1 = vectorizer_1.transform(Xt1)"
2018-05-09 19:13:08 +02:00
]
},
{
2018-05-17 10:38:34 +02:00
"cell_type": "markdown",
2018-05-09 19:13:08 +02:00
"metadata": {},
2018-05-11 12:19:53 +02:00
"source": [
2018-05-17 10:38:34 +02:00
"* trying a Random Forest classifier "
2018-05-11 12:19:53 +02:00
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 11,
2018-05-11 12:19:53 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'score: 0.9960008419280152'\n",
"Confusion matrix, without normalization\n",
"array([[2342, 3],\n",
" [ 16, 2390]])\n",
"'score: 0.8478535353535354'\n",
"Confusion matrix, without normalization\n",
"array([[737, 82],\n",
" [159, 606]])\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUcAAAEmCAYAAADx4VKUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xm8VHX9x/HX+4IgCokIuAGSprmVqLhkppim4L6vqZjmktli+cssFbeyMjNzzdwt1DLL3chEc0FFQ8VUEMUEkT0DEYTL5/fH+V4cxrl3Bpi5M3Pv+8njPO7M95w55zMzl8/9fr/ne75HEYGZmS2todoBmJnVIidHM7MCnBzNzApwcjQzK8DJ0cysACdHM7MCnBzbGEldJN0r6X1Jf1yB/Rwl6W/ljK0aJD0o6djlfO2FkmZIeq/ccVntc3KsEklHShotaa6kKek/8Y5l2PXBwJrAGhFxyPLuJCJ+HxG7lyGepUgaJCkk3Z1XvkUqH1nifoZJuq3YdhExJCJuXo44+wHfAzaNiLWW9fVW/5wcq0DS6cBlwE/IElk/4CpgvzLsfj1gXEQsKsO+KmU68AVJa+SUHQuMK9cBlFmR3+9+wMyImLYcx+64Ase1WhERXlpxAVYD5gKHtLBNZ7Lk+W5aLgM6p3WDgElktZppwBTguLTuPOAjYGE6xvHAMOC2nH33BwLomJ4PBd4E5gBvAUfllD+R87odgOeA99PPHXLWjQQuAJ5M+/kb0LOZ99YU/zXAqamsAzAZOAcYmbP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BblZbWZWgGuOZmZ5PM7RzKwZblabmeXzUB4zs8Ia3Od
"text/plain": [
2018-05-28 19:13:57 +02:00
"<matplotlib.figure.Figure at 0x7f5d5e84a8d0>"
2018-05-22 16:40:46 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUAAAAEmCAYAAAATPUntAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XecVOX1x/HPd+mIghQJUi3YYkFFxI5iAWxoFFEjaDCosURN+Rk1RhNNTLMQoybRCGqCkhgjKhERNZaICgqI0UgRAoh0EVmQdn5/PM/AsNndGZa5OzM7583rvnbm3jv3nplhzz7PLeeRmeGcc6WoLN8BOOdcvngCdM6VLE+AzrmS5QnQOVeyPAE650qWJ0DnXMnyBFjHSGoi6WlJKyT9ZRu2c76k53MZWz5I+oekwTV87a2Slkj6NNdxucLgCTBPJJ0naaKkLyQtiL+oR+Zg02cBbYFWZnZ2TTdiZn8ysxNzEM8WJPWSZJKerDD/gDj/5Sy3c7OkRzOtZ2Z9zWxEDeLsBHwH2MfMvrK1r3fFwRNgHki6FrgL+CkhWXUC7gVOz8HmOwMfmdn6HGwrKYuBwyS1Sps3GPgoVztQsC3/vzsBS81sUQ32XX8b9utqk5n5VIsT0Bz4Aji7mnUaERLkJ3G6C2gUl/UC5hFaJ4uABcBFcdktwFpgXdzHEOBm4NG0bXcBDKgfn18IzAJWAh8D56fNfy3tdYcDbwMr4s/D05a9DPwEeD1u53mgdRXvLRX//cDlcV49YD5wE/By2rp3A3OBz4FJwFFxfp8K73NKWhy3xThWA7vHeRfH5fcBT6Rt/+fAeEAVYjw+vn5j3P7wOP804H3gs7jdvdNeMxv4P2Aq8GXq8/WpsKe8B1BqU/zlX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f5d5e84a048>"
2018-05-22 16:40:46 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
2018-05-11 12:19:53 +02:00
"source": [
2018-05-17 10:38:34 +02:00
"from sklearn.ensemble import RandomForestClassifier as RFC\n",
"clf_a = RFC(criterion='entropy', random_state=4222)\n",
"max_size=10000\n",
"clf_a.fit(vec_train_1[:max_size], y1[:max_size])\n",
2018-05-13 18:29:18 +02:00
"test_classifier(labels=[\"FAKE\",\"REAL\"], title=\"Configuration 1, model a -- train\", Xt=vec_train_1,yt=y1, clf=clf_a)\n",
2018-05-22 16:40:46 +02:00
"cm_1 = test_classifier(labels=[\"FAKE\",\"REAL\"], title=\"Configuration 1, model a -- test\", Xt=vec_test_1,yt=yt1, clf=clf_a)"
2018-05-11 12:19:53 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-05-13 10:12:19 +02:00
"----\n",
2018-05-13 10:35:15 +02:00
"## configuration 2\n",
2018-05-13 10:12:19 +02:00
"\n",
"* read data"
2018-05-11 12:19:53 +02:00
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 12,
2018-05-11 12:19:53 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"data": {
"text/markdown": [
"----\n",
"#### Train Data:"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"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>id</th>\n",
" <th>label</th>\n",
" <th>statement</th>\n",
" <th>subjects</th>\n",
" <th>speaker</th>\n",
" <th>job</th>\n",
" <th>state</th>\n",
" <th>party</th>\n",
" <th>#barely_true</th>\n",
" <th>#false</th>\n",
" <th>#half_true</th>\n",
" <th>#mostly_true</th>\n",
" <th>#pants_on_fire</th>\n",
" <th>context</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2635.json</td>\n",
" <td>false</td>\n",
" <td>Says the Annies List political group supports ...</td>\n",
" <td>abortion</td>\n",
" <td>dwayne-bohac</td>\n",
" <td>State representative</td>\n",
" <td>Texas</td>\n",
" <td>republican</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>a mailer</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1123.json</td>\n",
" <td>false</td>\n",
" <td>Health care reform legislation is likely to ma...</td>\n",
" <td>health-care</td>\n",
" <td>blog-posting</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>none</td>\n",
" <td>7.0</td>\n",
" <td>19.0</td>\n",
" <td>3.0</td>\n",
" <td>5.0</td>\n",
" <td>44.0</td>\n",
" <td>a news release</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>12465.json</td>\n",
" <td>true</td>\n",
" <td>The Chicago Bears have had more starting quart...</td>\n",
" <td>education</td>\n",
" <td>robin-vos</td>\n",
" <td>Wisconsin Assembly speaker</td>\n",
" <td>Wisconsin</td>\n",
" <td>republican</td>\n",
" <td>0.0</td>\n",
" <td>3.0</td>\n",
" <td>2.0</td>\n",
" <td>5.0</td>\n",
" <td>1.0</td>\n",
" <td>a an online opinion-piece</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>5947.json</td>\n",
" <td>false</td>\n",
" <td>When Mitt Romney was governor of Massachusetts...</td>\n",
" <td>history,state-budget</td>\n",
" <td>mitt-romney</td>\n",
" <td>Former governor</td>\n",
" <td>Massachusetts</td>\n",
" <td>republican</td>\n",
" <td>34.0</td>\n",
" <td>32.0</td>\n",
" <td>58.0</td>\n",
" <td>33.0</td>\n",
" <td>19.0</td>\n",
" <td>an interview with CBN News</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>620.json</td>\n",
" <td>true</td>\n",
" <td>McCain opposed a requirement that the governme...</td>\n",
" <td>federal-budget</td>\n",
" <td>barack-obama</td>\n",
" <td>President</td>\n",
" <td>Illinois</td>\n",
" <td>democrat</td>\n",
" <td>70.0</td>\n",
" <td>71.0</td>\n",
" <td>160.0</td>\n",
" <td>163.0</td>\n",
" <td>9.0</td>\n",
" <td>a radio ad</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id label statement \\\n",
"0 2635.json false Says the Annies List political group supports ... \n",
"3 1123.json false Health care reform legislation is likely to ma... \n",
"5 12465.json true The Chicago Bears have had more starting quart... \n",
"12 5947.json false When Mitt Romney was governor of Massachusetts... \n",
"16 620.json true McCain opposed a requirement that the governme... \n",
"\n",
" subjects speaker job \\\n",
"0 abortion dwayne-bohac State representative \n",
"3 health-care blog-posting NaN \n",
"5 education robin-vos Wisconsin Assembly speaker \n",
"12 history,state-budget mitt-romney Former governor \n",
"16 federal-budget barack-obama President \n",
"\n",
" state party #barely_true #false #half_true #mostly_true \\\n",
"0 Texas republican 0.0 1.0 0.0 0.0 \n",
"3 NaN none 7.0 19.0 3.0 5.0 \n",
"5 Wisconsin republican 0.0 3.0 2.0 5.0 \n",
"12 Massachusetts republican 34.0 32.0 58.0 33.0 \n",
"16 Illinois democrat 70.0 71.0 160.0 163.0 \n",
"\n",
" #pants_on_fire context \n",
"0 0.0 a mailer \n",
"3 44.0 a news release \n",
"5 1.0 a an online opinion-piece \n",
"12 19.0 an interview with CBN News \n",
"16 9.0 a radio ad "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"----\n",
"#### Test Data:"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"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>id</th>\n",
" <th>label</th>\n",
" <th>statement</th>\n",
" <th>subjects</th>\n",
" <th>speaker</th>\n",
" <th>job</th>\n",
" <th>state</th>\n",
" <th>party</th>\n",
" <th>#barely_true</th>\n",
" <th>#false</th>\n",
" <th>#half_true</th>\n",
" <th>#mostly_true</th>\n",
" <th>#pants_on_fire</th>\n",
" <th>context</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>11972.json</td>\n",
" <td>true</td>\n",
" <td>Building a wall on the U.S.-Mexico border will...</td>\n",
" <td>immigration</td>\n",
" <td>rick-perry</td>\n",
" <td>Governor</td>\n",
" <td>Texas</td>\n",
" <td>republican</td>\n",
" <td>30</td>\n",
" <td>30</td>\n",
" <td>42</td>\n",
" <td>23</td>\n",
" <td>18</td>\n",
" <td>Radio interview</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>11685.json</td>\n",
" <td>false</td>\n",
" <td>Wisconsin is on pace to double the number of l...</td>\n",
" <td>jobs</td>\n",
" <td>katrina-shankland</td>\n",
" <td>State representative</td>\n",
" <td>Wisconsin</td>\n",
" <td>democrat</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>a news conference</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>11096.json</td>\n",
" <td>false</td>\n",
" <td>Says John McCain has done nothing to help the ...</td>\n",
" <td>military,veterans,voting-record</td>\n",
" <td>donald-trump</td>\n",
" <td>President-Elect</td>\n",
" <td>New York</td>\n",
" <td>republican</td>\n",
" <td>63</td>\n",
" <td>114</td>\n",
" <td>51</td>\n",
" <td>37</td>\n",
" <td>61</td>\n",
" <td>comments on ABC's This Week.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>5962.json</td>\n",
" <td>true</td>\n",
" <td>Over the past five years the federal governmen...</td>\n",
" <td>federal-budget,pensions,retirement</td>\n",
" <td>brendan-doherty</td>\n",
" <td>NaN</td>\n",
" <td>Rhode Island</td>\n",
" <td>republican</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>a campaign website</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>7070.json</td>\n",
" <td>true</td>\n",
" <td>Says that Tennessee law requires that schools ...</td>\n",
" <td>county-budget,county-government,education,taxes</td>\n",
" <td>stand-children-tennessee</td>\n",
" <td>Child and education advocacy organization.</td>\n",
" <td>Tennessee</td>\n",
" <td>none</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>in a post on Facebook.</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id label statement \\\n",
"0 11972.json true Building a wall on the U.S.-Mexico border will... \n",
"1 11685.json false Wisconsin is on pace to double the number of l... \n",
"2 11096.json false Says John McCain has done nothing to help the ... \n",
"5 5962.json true Over the past five years the federal governmen... \n",
"6 7070.json true Says that Tennessee law requires that schools ... \n",
"\n",
" subjects speaker \\\n",
"0 immigration rick-perry \n",
"1 jobs katrina-shankland \n",
"2 military,veterans,voting-record donald-trump \n",
"5 federal-budget,pensions,retirement brendan-doherty \n",
"6 county-budget,county-government,education,taxes stand-children-tennessee \n",
"\n",
" job state party \\\n",
"0 Governor Texas republican \n",
"1 State representative Wisconsin democrat \n",
"2 President-Elect New York republican \n",
"5 NaN Rhode Island republican \n",
"6 Child and education advocacy organization. Tennessee none \n",
"\n",
" #barely_true #false #half_true #mostly_true #pants_on_fire \\\n",
"0 30 30 42 23 18 \n",
"1 2 1 0 0 0 \n",
"2 63 114 51 37 61 \n",
"5 1 2 1 1 0 \n",
"6 0 0 0 0 0 \n",
"\n",
" context \n",
"0 Radio interview \n",
"1 a news conference \n",
"2 comments on ABC's This Week. \n",
"5 a campaign website \n",
"6 in a post on Facebook. "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"----\n",
"#### Valid Data:"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"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>id</th>\n",
" <th>label</th>\n",
" <th>statement</th>\n",
" <th>subjects</th>\n",
" <th>speaker</th>\n",
" <th>job</th>\n",
" <th>state</th>\n",
" <th>party</th>\n",
" <th>#barely_true</th>\n",
" <th>#false</th>\n",
" <th>#half_true</th>\n",
" <th>#mostly_true</th>\n",
" <th>#pants_on_fire</th>\n",
" <th>context</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>7891.json</td>\n",
" <td>false</td>\n",
" <td>Says Having organizations parading as being so...</td>\n",
" <td>campaign-finance,congress,taxes</td>\n",
" <td>earl-blumenauer</td>\n",
" <td>U.S. representative</td>\n",
" <td>Oregon</td>\n",
" <td>democrat</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>a U.S. Ways and Means hearing</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>9416.json</td>\n",
" <td>false</td>\n",
" <td>Says when armed civilians stop mass shootings ...</td>\n",
" <td>guns</td>\n",
" <td>jim-rubens</td>\n",
" <td>Small business owner</td>\n",
" <td>New Hampshire</td>\n",
" <td>republican</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>in an interview at gun shop in Hudson, N.H.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>6861.json</td>\n",
" <td>true</td>\n",
" <td>Says Tennessee is providing millions of dollar...</td>\n",
" <td>education,state-budget</td>\n",
" <td>andy-berke</td>\n",
" <td>Lawyer and state senator</td>\n",
" <td>Tennessee</td>\n",
" <td>democrat</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>a letter to state Senate education committee c...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>1122.json</td>\n",
" <td>false</td>\n",
" <td>The health care reform plan would set limits s...</td>\n",
" <td>health-care</td>\n",
" <td>club-growth</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>none</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>a TV ad</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>13138.json</td>\n",
" <td>true</td>\n",
" <td>Says Donald Trump started his career back in 1...</td>\n",
" <td>candidates-biography,diversity,housing</td>\n",
" <td>hillary-clinton</td>\n",
" <td>Presidential candidate</td>\n",
" <td>New York</td>\n",
" <td>democrat</td>\n",
" <td>40</td>\n",
" <td>29</td>\n",
" <td>69</td>\n",
" <td>76</td>\n",
" <td>7</td>\n",
" <td>the first presidential debate</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id label statement \\\n",
"2 7891.json false Says Having organizations parading as being so... \n",
"5 9416.json false Says when armed civilians stop mass shootings ... \n",
"6 6861.json true Says Tennessee is providing millions of dollar... \n",
"7 1122.json false The health care reform plan would set limits s... \n",
"8 13138.json true Says Donald Trump started his career back in 1... \n",
"\n",
" subjects speaker \\\n",
"2 campaign-finance,congress,taxes earl-blumenauer \n",
"5 guns jim-rubens \n",
"6 education,state-budget andy-berke \n",
"7 health-care club-growth \n",
"8 candidates-biography,diversity,housing hillary-clinton \n",
"\n",
" job state party #barely_true #false \\\n",
"2 U.S. representative Oregon democrat 0 1 \n",
"5 Small business owner New Hampshire republican 1 1 \n",
"6 Lawyer and state senator Tennessee democrat 0 0 \n",
"7 NaN NaN none 4 5 \n",
"8 Presidential candidate New York democrat 40 29 \n",
"\n",
" #half_true #mostly_true #pants_on_fire \\\n",
"2 1 1 0 \n",
"5 0 1 0 \n",
"6 0 0 0 \n",
"7 4 2 0 \n",
"8 69 76 7 \n",
"\n",
" context \n",
"2 a U.S. Ways and Means hearing \n",
"5 in an interview at gun shop in Hudson, N.H. \n",
"6 a letter to state Senate education committee c... \n",
"7 a TV ad \n",
"8 the first presidential debate "
]
},
"metadata": {},
"output_type": "display_data"
}
],
2018-05-11 12:19:53 +02:00
"source": [
2018-05-13 10:12:19 +02:00
"names = [\n",
" \"id\",\n",
" \"label\",\n",
" \"statement\",\n",
" \"subjects\",\n",
" \"speaker\",\n",
" \"job\",\n",
" \"state\",\n",
" \"party\",\n",
" \"#barely_true\",\n",
" \"#false\",\n",
" \"#half_true\",\n",
" \"#mostly_true\",\n",
" \"#pants_on_fire\",\n",
" \"context\"\n",
"]\n",
"\n",
"df_2_train = pd.read_csv(\"data/train.tsv\", delimiter='\\t', names=names)\n",
"df_2_test = pd.read_csv(\"data/test.tsv\", delimiter='\\t', names=names)\n",
2018-05-13 13:36:21 +02:00
"df_2_valid= pd.read_csv(\"data/valid.tsv\", delimiter='\\t', names=names)\n",
2018-05-13 10:12:19 +02:00
"\n",
"# use only 'False' and 'True' statements\n",
"df_2_train = df_2_train[df_2_train['label'].isin([\"false\",\"true\"])]\n",
"df_2_test = df_2_test[df_2_test['label'].isin([\"false\",\"true\"])]\n",
2018-05-13 13:36:21 +02:00
"df_2_valid = df_2_valid[df_2_valid['label'].isin([\"false\",\"true\"])]\n",
2018-05-13 10:12:19 +02:00
"\n",
2018-05-13 12:44:36 +02:00
"display(Markdown(\"----\\n#### Train Data:\"))\n",
2018-05-13 10:12:19 +02:00
"display(df_2_train.head())\n",
2018-05-13 12:44:36 +02:00
"display(Markdown(\"----\\n#### Test Data:\"))\n",
2018-05-13 13:36:21 +02:00
"display(df_2_test.head())\n",
"display(Markdown(\"----\\n#### Valid Data:\"))\n",
"display(df_2_valid.head())"
2018-05-11 12:19:53 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-05-13 10:12:19 +02:00
"#### tdidf vectorizer on new dataset\n"
2018-05-11 12:19:53 +02:00
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 13,
2018-05-11 12:19:53 +02:00
"metadata": {},
2018-05-13 10:12:19 +02:00
"outputs": [],
"source": [
2018-05-13 10:35:15 +02:00
"X2 = df_2_train['statement']\n",
"y2 = df_2_train['label']\n",
"Xt2 = df_2_test['statement']\n",
2018-05-13 12:44:36 +02:00
"yt2 = df_2_test['label']\n",
2018-05-13 13:36:21 +02:00
"Xv2 = df_2_valid['statement']\n",
"yv2 = df_2_valid['label']\n"
2018-05-13 10:12:19 +02:00
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 14,
2018-05-13 10:12:19 +02:00
"metadata": {},
"outputs": [],
"source": [
2018-05-17 10:38:34 +02:00
"vectorizer_2 = TfidfVectorizer(stop_words='english', max_df=0.7)\n",
2018-05-13 18:29:18 +02:00
"vec_train_2 = vectorizer_2.fit_transform(X2)\n",
"vec_test_2 = vectorizer_2.transform(Xt2)"
2018-05-13 10:12:19 +02:00
]
},
{
2018-05-13 10:35:15 +02:00
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 15,
2018-05-17 10:38:34 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Object `MLPClassifier` not found.\n"
]
}
],
2018-05-17 10:38:34 +02:00
"source": [
"?MLPClassifier"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* trying a MLP as classifier "
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 16,
2018-05-13 10:12:19 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"data": {
"text/plain": [
"MLPClassifier(activation='relu', alpha=0.0001, batch_size='auto', beta_1=0.9,\n",
" beta_2=0.999, early_stopping=False, epsilon=1e-08,\n",
" hidden_layer_sizes=(100,), learning_rate='constant',\n",
" learning_rate_init=0.001, max_iter=200, momentum=0.9,\n",
" nesterovs_momentum=True, power_t=0.5, random_state=4222,\n",
" shuffle=True, solver='adam', tol=0.0001, validation_fraction=0.1,\n",
" verbose=False, warm_start=False)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
2018-05-13 10:12:19 +02:00
"source": [
2018-05-17 10:38:34 +02:00
"from sklearn.neural_network import MLPClassifier\n",
"clf_b = MLPClassifier(hidden_layer_sizes=(100,), random_state=4222)\n",
2018-05-13 18:29:18 +02:00
"clf_b.fit(vec_train_2, y2)"
2018-05-13 10:12:19 +02:00
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 17,
2018-05-13 10:12:19 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'score: 0.9997275946608554'\n",
"Confusion matrix, without normalization\n",
"array([[1675, 1],\n",
" [ 0, 1995]])\n",
"'score: 0.5776805251641138'\n",
"Confusion matrix, without normalization\n",
"array([[109, 99],\n",
" [ 94, 155]])\n",
"'score: 0.6041666666666666'\n",
"Confusion matrix, without normalization\n",
"array([[ 92, 77],\n",
" [ 94, 169]])\n"
]
},
{
"data": {
"text/plain": [
"array([[ 92, 77],\n",
" [ 94, 169]])"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUYAAAEmCAYAAAAeIzmqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmcneP9//HXe5IIlRCElETEFhq+te+CtihK0ZZStdRedNON8q2lpbrQX9VWvvVFaSzFlxJVXbSEICKWWGMJiZTEvkRI8vn9cV2TnDmZOefM5J45c2beT4/7kXOue/ucGecz13Xd931digjMzGyhpnoHYGbW3TgxmpmVcWI0MyvjxGhmVsaJ0cysjBOjmVkZJ8YeRNJSkv4s6S1J1y3GcQ6Q9NciY6sHSbdJOriD+/5U0ixJ/yk6Luv+nBjrQNJXJE2Q9K6kGfkLvG0Bh/4SMARYISL26ehBIuKqiNi5gHhakLSDpJB0Y1n5Brn8zhqPc6qkK6ttFxG7RsTlHYhzOPBdYFREfLy9+1vjc2LsYpKOB/4fcCYpiQ0HLgD2LODwqwFPR8TcAo7VWWYCW0laoaTsYODpok6gZHH+3x4OvBYRr3bg3H0X47zWXUSEly5agGWBd4F9KmzTn5Q4X87L/wP653U7ANNItZlXgRnA1/K604APgY/yOQ4DTgWuLDn2CCCAvvn9IcBzwDvA88ABJeV3l+y3NfAA8Fb+d+uSdXcCPwHG5eP8FRjcxmdrjv8i4Nhc1geYDvwYuLNk298ALwFvAw8Co3P5LmWf8+GSOM7IccwG1splh+f1FwLXlxz/58DfAZXFuGPef34+/mW5/PPAZODNfNxPlOzzAvBD4BFgTvP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:57 +02:00
"<matplotlib.figure.Figure at 0x7f5d5e737f28>"
2018-05-22 16:40:46 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUAAAAEmCAYAAAATPUntAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmcXFWZ//HPtzp7AgQIm4EQhbAPu6goixsCgkFG/IEoIDjIqo47wgiyieOIIyIyYcSwyeIIDsqmogyLICD7TlgTCGTDkD3p7uf3xzmdVDrdXdWd6q6uvt93XvfVVefeOveprq4n55x777mKCMzMiqhU7wDMzOrFCdDMCssJ0MwKywnQzArLCdDMCssJ0MwKywlwAJE0XNLvJM2V9OvVqOdwSX+oZWz1IOkWSUf28LVnS5ol6Y1ax2X9hxNgHUj6jKQHJc2XND1/UT9Qg6o/BWwArBsRh/S0koi4KiL2qUE8K5G0t6SQdEO78h1y+R1V1nOGpCsrbRcR+0XEZT2IcxzwNWCbiNiwu6+3xuEE2MckfRX4T+BcUrIaB1wETKxB9ZsCz0VEcw3q6i0zgfdJWres7EjguVrtQMnq/G2PA2ZHxIwe7HvQauzX+lpEeOmjBVgLmA8c0sU2Q0kJ8vW8/CcwNK/bG5hGap3MAKYDn8/rvgcsBZblfRwDnAFcWVb3eCCAQfn5UcCLwDzgJeDwsvK7y163O/AAMDf/3L1s3R3AWcA9uZ4/AGM6eW9t8V8MnJjLmoDXgO8Cd5Rt+xNgKvA28Hdgj1y+b7v3+WhZHOfkOBYBm+eyL+T1Pwd+U1b/D4DbAbWL8SP59a25/sm5/BPAk8A/cr1bl73mZeBbwGPAkrbfr5f+v9Q9gCIt+cvb3NUXBDgTuA9YH1gP+CtwVl63d379mcBgYH9gIbB2Xt8+4XWaAIGROblsmddtBGybHy9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e/P664G/lXSOyWNInWtru2ktdgd95IOkJyUp7GaSOqKt3kU2FbSjpKGkaaZr2QNYE5ELJa0G/CZsnUzSdNpvauT19ZsWi1JY4E/kw4k9caMKx29l4uBUyRtm2NYS9Ih+fG7c+t4MOk/lsWsmFrsTTr/nVidOQH2gYhoIY11bU46wjiNNBszwKWkyUHvJJ17thg4uQb7XEo68HEM6UY+nyUlmyV5/XOke4v8CXgeuLvjmlZyAnCmpHmkcbflsypHmtT0HOCe3E18b7t4ajmt1hdISeWMsq7s/B7U06GO3ktE3EC6kdI1kt4GngD2yy9Zk3Sg6i1St3428MO87hfANrme32L9ik+ELhBJfwMujgifM2eGW4ADmqS9JG2Yu5xHkk5dubXecZn1F76J88C2JambOpJ0M6BP+fQMsxXcBTazwnIX2MwKa8B1gUevs25sNHZcvcOwdoYM8v+1/dVjjzw0KyLWq1V9TWtuGtG8qOJ2sWjmbRGxb6322xMDLgFuNHYcv7zhL/UOw9oZv96IyhtZXWw0emj7K3RWSzQvYuiWn6643eJHflbtVUS9ZsAlQDOrMwlK/Wn2tM45AZpZ7VV/z/q6cgI0s9pb6RL0/ssJ0MxqTG4BmllBCY8BmllRyV1gMyswd4HNrLDcAjSzQvJ5gGZWaO4Cm1kx+TQYMyuyUmOMATZGmjazxtF2HmClpVI10qWSZkh6oqzsDEmvSXokL/uXrTtF0hRJz0r6WDWhOgGaWY3lLnClpbLJQEfTZf04InbMy80AkrYBDgW2za+5SFLFLOsEaGa1J1VeKoiIO0k3oK/GROCaiFgSES8BU1j5NrAdcgI0s9qrrgU4RtKDZcuxVdZ+kqTHchd57Vw2lnTz+jbTclmXfBDEzGqr+vMAZ0XErt2s/efAWUDknz8
"text/plain": [
2018-05-28 19:13:57 +02:00
"<matplotlib.figure.Figure at 0x7f5d5b205fd0>"
2018-05-22 16:40:46 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUAAAAEmCAYAAAATPUntAAAABH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itxB7AS+LSy0lX7kA3FOzwIbClpmzR/dWoF+xwFvBQRr0ragWzOrsNcshJab+zms7mV0pI0EfgrcG5EVKvKyrVkCft0sr+PjvJg5cpzdSkiniGr7HOapMHKnvz3gTIfs37kBFgl6TqwD5A9nOdZsmdhfDStvpCsIOgtZA8jehU4LodjLgc+TPZApAVkJZz+RFa7joh4nOyX+ybgCbKTHOUcA5wuaRHZvNuqSsrpbOyZwO2SFkjasVM8eZbS+gRZoj21ZCi7uA/76Vaa77uK7MFIvypZVa48V08OAt5GVnLsFLoo/2+143JYA5yku4DzI8LXzJl14h7gACNpV0lvSEPOQ4E3k/VezKwTP8R54NmMbJg6guwBQPtFxOzahmRWnzwENrPC8hDYzAprwA2Bx46bEBMn+VKrejOkxf/W1qv7779vXkSsndf+mtfaMKKttex20Tr3hojYM6/j9sWAS4ATJ03mN9d3d52r1cqUtUeU38hqYtgg5Xp3SrS1MmSzj5Td7tUHflTzwhADLgGaWY1J0FRPldS65wRoZvmr/Jn1NeUEaGb5U7nbpOuDE6CZ5UzuAZpZQQnPAZpZUclDYDMrMA+Bzayw3AM0s0LydYBmVmgeAptZMfkyGDMrsibPAZpZEfk6QDMrLg+BzazIGuQymMZI02bWWNRUfim3C+lCSXMkPdKp/ThJj0qaLuk7Je0nSpoh6TFJ760kTPcAzSxf+V0HeBFwLiXPUpa0O7APsHVELJO0TmrfAjgA2BJYH7hJ0tT0fO5uuQdoZvmTyi9
"text/plain": [
2018-05-28 19:13:57 +02:00
"<matplotlib.figure.Figure at 0x7f5d5b1ebfd0>"
2018-05-22 16:40:46 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
2018-05-11 12:19:53 +02:00
"source": [
2018-05-13 18:29:18 +02:00
"test_classifier(labels=[\"true\", \"false\"], title=\"configuration 2 -- train\", Xt=vec_train_2, yt=y2, clf=clf_b)\n",
2018-05-22 16:40:46 +02:00
"cm_2 = test_classifier(labels=[\"true\", \"false\"], title=\"configuration 2 -- test\", Xt=vec_test_2, yt=yt2, clf=clf_b)\n",
2018-05-13 18:29:18 +02:00
"test_classifier(labels=[\"true\", \"false\"], title=\"configuration 2 -- valid\", Xt=vectorizer_2.transform(Xv2), yt=yv2, clf=clf_b)"
2018-05-13 10:35:15 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----\n",
"## configuration 3"
2018-05-09 19:13:08 +02:00
]
},
2018-05-13 12:44:36 +02:00
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 18,
2018-05-13 12:44:36 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'score: 0.5142231947483589'\n",
"Confusion matrix, without normalization\n",
"array([[ 7, 201],\n",
" [ 21, 228]])\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUEAAAEmCAYAAAD8/yLTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XecVOX1x/HPd0E6Cgpio4iKNYpiSTQqRmzYjWLvxhKNMSYmRv3ZoomJJcYYNRq7BiXBQhALEokVC0rRCCgtgnQRQTqc3x/PM3gZd3dmd+fu7OycN6/7YubeO/eemZ09+zy3nEdmhnPOlauKYgfgnHPF5EnQOVfWPAk658qaJ0HnXFnzJOicK2ueBJ1zZc2TYCMjqaWkf0laIOkfddjOyZJeKmRsxSDpeUmn1/K1N0iaK2lmoeNyDYcnwSKRdJKk9yQtkjQj/rJ+vwCbPhboBGxgZsfVdiNm9riZHViAeNYiqbckk/R01vyd4vzheW7nWkmP5VrPzA4xs4drEWcX4OfAdma2UU1f70qHJ8EikHQpcDvwW0LC6gLcBRxZgM13BSaY2coCbCstc4DvSdogMe90YEKhdqCgLt/vLsA8M5tdi303rcN+XX0zM5/qc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zM+tOKP9/qaT9CZ/b5KzPra2Z9a1sP5WJ3/v7CYnzh5ZVpLaxKKUk+A7hF+YmSa0ltZC0V1zWH/iZpM0ltSH8xX+yilZjTbxFOGlyUSwhdSShW54xGtheUk9JLQjHWXJpC3xhZksl7U449pYxh3BsrnsVry1YSStJB0jaWVITSesSjsnNJxw3K7Qq4zazqYTu7XWSmimMuJfs3j9G6DYfFGNtoTBi3WZ57Lct4eTDIoV
"text/plain": [
2018-05-28 19:13:57 +02:00
"<matplotlib.figure.Figure at 0x7f5d5e7375c0>"
2018-05-22 16:40:46 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
2018-05-13 12:44:36 +02:00
"source": [
"yt2_c3 = yt2.copy()\n",
"yt2_c3[yt2_c3 == \"true\"] = \"REAL\"\n",
"yt2_c3[yt2_c3 == \"false\"] = \"FAKE\"\n",
"\n",
2018-05-22 16:40:46 +02:00
"cm_3b=test_classifier(labels=[\"REAL\", \"FAKE\"], \n",
2018-05-13 12:44:36 +02:00
" title=\"configuration 3: model a) → dataset 2\",\n",
2018-05-13 18:29:18 +02:00
" Xt=vectorizer_1.transform(Xt2),\n",
2018-05-13 12:44:36 +02:00
" yt=yt2_c3, clf=clf_a)"
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 19,
2018-05-13 12:44:36 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'score: 0.5391414141414141'\n",
"Confusion matrix, without normalization\n",
"array([[274, 491],\n",
" [239, 580]])\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUAAAAEmCAYAAAATPUntAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XecFPX9x/H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q5pS2CWxT+DUWVLHpVaX9LehBbCzoQWZkN+uK41m3gSL0tlZssUrlmdJ6mLZV8Gfk7K4xXlPC/Zd7q4twQWWukx2OmEnzeEMdrjJaUm+frAa1nGuP7zN7N1cXgjtbRYU0IreAOS3gH2TrPtRwl/PMraktI/91LvXdKphGuwO8ZZTUhT5ivDd+Zhwmf1uKQWhOudryJ8bvUJZc5KNlWEl+zaQL60AGcAHVR+Hb3yyketofQvZFXMBtqWGfNpn/K4VKkplT+YXvZC60cJg+/tzaw5YSwmU4mnEtVVlgrC92BjSifTpKSLezawiUJFmtRlJWYQhjNapEyNzSzbgfn1Py+FyjHtKD2m1YXQI9iAme1jZio7EVqscwjDBOWZTenvyfr3I2krwnDMYMIQQAtCFzndd6DC70zsmQwxsx0JxVmPJBSYnUEY6mmZ8rk1M7OS0368AECULwlwDOGLdZOkxnHwd/+47DHgojiY3oRws6EnKmgtVsbbhIMDgxXKQPWldFflQ2AnSd0kNSKMOWXSFPjWzFZK6k7pX6J5hLG4bSp4bWJlqSQdImm3OCjejNA9XAhMruy2slBh3GY2ndClHSKpgcKd8VJbe8MJXeXDYqyNFA5Utcty33tIOjb+4byQkBTegXAAgTBm9nI
"text/plain": [
2018-05-28 19:13:57 +02:00
"<matplotlib.figure.Figure at 0x7f5d5e71c320>"
2018-05-22 16:40:46 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
2018-05-13 12:44:36 +02:00
"source": [
"yt1_c3 = yt1.copy()\n",
"yt1_c3[yt1_c3 == \"REAL\"] = \"true\"\n",
"yt1_c3[yt1_c3 == \"FAKE\"] = \"false\"\n",
"\n",
2018-05-22 16:40:46 +02:00
"cm_3a=test_classifier(labels=[\"true\", \"false\"], \n",
2018-05-13 12:44:36 +02:00
" title=\"configuration 3: model b) → dataset 1\",\n",
2018-05-13 18:29:18 +02:00
" Xt=vectorizer_2.transform(Xt1),\n",
2018-05-13 12:44:36 +02:00
" yt=yt1_c3, clf=clf_b)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----\n",
"## configuration 4)"
]
},
2018-05-13 13:36:21 +02:00
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 20,
2018-05-13 13:36:21 +02:00
"metadata": {},
"outputs": [],
"source": [
"def get_dataset3_split(dataset1_in, dataset2_in):\n",
" try:\n",
" print('processing datasets')\n",
" print('ds1=', dataset1_in)\n",
" print('ds2=', dataset2_in)\n",
"\n",
" print('-- fake news')\n",
" df1 = pd.read_csv(dataset1_in, sep=',', usecols=['title','text','label'])\n",
" df1['claim'] = df1[['title', 'text']].apply(lambda x: '. '.join(x), axis=1)\n",
" del df1['title']\n",
" del df1['text']\n",
" df1.rename(index=str, columns={'label': 'y'}, inplace=True)\n",
" print(df1.keys())\n",
" print(len(df1[df1['y']=='REAL']))\n",
" print(len(df1[df1['y']=='FAKE']))\n",
" df1['y'] = np.where(df1['y'] == 'FAKE', 'false', 'true')\n",
" print(len(df1))\n",
"\n",
" print('-- liar liar')\n",
" df2 = pd.read_csv(dataset2_in, sep='\\t', header=None, usecols=[1,2], names=['y', 'claim'])\n",
" print(df2.keys())\n",
" print(set(df2.y), len(df2))\n",
" print(len(df2[df2['y'] == 'true']))\n",
" print(len(df2[df2['y'] == 'false']))\n",
" df2=df2[(df2['y'] == 'true') | (df2['y'] == 'false')]\n",
" print(set(df2.y), len(df2))\n",
"\n",
" df3=pd.concat([df1, df2], ignore_index=True)\n",
"\n",
" print(df3['y'].value_counts())\n",
" print('done')\n",
2018-05-17 10:38:34 +02:00
" return train_test_split(df3['claim'], df3['y'], test_size=0.3, random_state=4222)\n",
2018-05-13 13:36:21 +02:00
" except Exception as e:\n",
" print(e)"
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 21,
2018-05-13 13:36:21 +02:00
"metadata": {},
2018-05-22 16:40:46 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"processing datasets\n",
"ds1= data/fake_or_real_news.csv\n",
"ds2= data/train.tsv\n",
"-- fake news\n",
"Index(['y', 'claim'], dtype='object')\n",
"3171\n",
"3164\n",
"6335\n",
"-- liar liar\n",
"Index(['y', 'claim'], dtype='object')\n",
2018-05-28 19:13:57 +02:00
"{'pants-fire', 'false', 'mostly-true', 'true', 'barely-true', 'half-true'} 10240\n",
2018-05-22 16:40:46 +02:00
"1676\n",
"1995\n",
2018-05-28 19:13:57 +02:00
"{'true', 'false'} 3671\n",
2018-05-22 16:40:46 +02:00
"false 5159\n",
"true 4847\n",
"Name: y, dtype: int64\n",
"done\n"
]
}
],
2018-05-13 13:36:21 +02:00
"source": [
"X3, Xt3, y3, yt3 = get_dataset3_split('data/fake_or_real_news.csv', 'data/train.tsv')"
]
},
{
"cell_type": "code",
2018-05-22 16:40:46 +02:00
"execution_count": 22,
2018-05-13 13:36:21 +02:00
"metadata": {},
"outputs": [],
"source": [
2018-05-17 10:38:34 +02:00
"vectorizer_3 = TfidfVectorizer(stop_words='english', max_df=0.7)\n",
2018-05-13 18:29:18 +02:00
"vec_train_3 = vectorizer_3.fit_transform(X3)\n",
"vec_test_3 = vectorizer_3.transform(Xt3)"
2018-05-13 13:36:21 +02:00
]
},
2018-05-17 10:38:34 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* using MLP again"
]
},
2018-05-13 13:36:21 +02:00
{
"cell_type": "code",
2018-06-06 13:31:15 +02:00
"execution_count": 23,
2018-05-13 13:36:21 +02:00
"metadata": {},
2018-06-06 13:31:15 +02:00
"outputs": [
{
"data": {
"text/plain": [
"MLPClassifier(activation='relu', alpha=0.0001, batch_size='auto', beta_1=0.9,\n",
" beta_2=0.999, early_stopping=False, epsilon=1e-08,\n",
" hidden_layer_sizes=(16, 16), learning_rate='constant',\n",
" learning_rate_init=0.001, max_iter=200, momentum=0.9,\n",
" nesterovs_momentum=True, power_t=0.5, random_state=4222,\n",
" shuffle=True, solver='adam', tol=0.0001, validation_fraction=0.1,\n",
" verbose=False, warm_start=False)"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
2018-05-13 13:36:21 +02:00
"source": [
2018-05-17 10:38:34 +02:00
"clf_3 = MLPClassifier(hidden_layer_sizes=(16,16), random_state=4222)\n",
2018-05-13 18:29:18 +02:00
"clf_3.fit(vec_train_3, y3)"
2018-05-13 13:36:21 +02:00
]
},
{
"cell_type": "code",
2018-06-06 13:31:15 +02:00
"execution_count": 24,
2018-05-13 13:36:21 +02:00
"metadata": {},
2018-06-06 13:31:15 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'score: 0.9997144488863506'\n",
"Confusion matrix, without normalization\n",
"array([[3367, 1],\n",
" [ 1, 3635]])\n",
"'score: 0.7714856762158561'\n",
"Confusion matrix, without normalization\n",
"array([[1136, 343],\n",
" [ 343, 1180]])\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUYAAAEmCAYAAAAeIzmqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XecVdW5//HPdxhahEi1gcaGLd6IvVx7IbZETTTXEsUWe7xeNdFoij2aGJOYRI3+JGpMLNfEKyqGYO8GUSzYABUFUUGUiCJSnt8few2eOcyccxj2zJkz83372i/OWbustQfnYa1dnqWIwMzMvlBX7QaYmbU3DoxmZkUcGM3MijgwmpkVcWA0MyviwGhmVsSBsQOR1FPSnZJmS/rfZTjOIZL+mWfbqkHSPZKGt3DfCyTNlPRu3u2y9s+BsQokHSzpaUlzJE1Pv8Db5nDo/YEVgf4RcUBLDxIRf4mIYTm0pxFJO0oKSbcXlW+Uyh+s8DjnSLqx3HYRsUdEXN+Cdq4GnAZsEBErLe3+VvscGNuYpFOB3wAXkQWx1YArgH1yOPxXgNciYkEOx2otM4CtJfUvKBsOvJZXBcosy//bqwEfRMT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bAraoZL6ALdL2pAsf+i7ZHlCrwbOAM5btgY35h6jmeWr4TnGcstSiIiPgAeA3SNiehouzwP+RDaJHGQZ4Vct2G1wKmuuvFkOjGaWv3zuSg9MPUUk9QR2A15J1w0bpsjYF3gx7TISOCzdnd4KmB0R04HRwDBJfSX1Jcs+P7pU3R5Km1nOlNcD3isD10vqQtaJuzUi7pJ0v6SBWUWMJ5uIDLJ5iPYEJpFNOHYEQETMknQ+MDZ
"text/plain": [
"<matplotlib.figure.Figure at 0x7f5d5ac59f98>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUYAAAEmCAYAAAAeIzmqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XucXdPdx/HPN3cRJBJSQhqVuLcI4lIqrq27p0W16tKqa7RVdeepupZWtTxEHkqptkpdHlTc6lKlkiYhVBCZkFQQuUiCJEgmv+ePvSY5czKXM2PPnDkz33de+zVnr73O2uvMZH6z1l57r6WIwMzMVuhU7gqYmbU1DoxmZkUcGM3MijgwmpkVcWA0MyviwGhmVsSBsR2RtIqkByQtkPSXz1DOEZIezbNu5SDpIUlHN/O9l0iaI2lm3vWyts+BsQwkfVvSeEkfSXo3/QLvnEPRhwD9gb4RcWhzC4mIP0bE3jnUpxZJwyWFpHuL0rdM6U+VWM7PJP2hsXwRsU9E3NqMeg4EfgJsFhGfa+r7rfI5MLYySacBvwEuIwtiA4GRwEE5FP954PWIWJpDWS1lNrCjpL4FaUcDr+d1AmU+y//tgcDciJjVjHN3+QzntbYiIry10gasAXwEHNpAnu5kgfOdtP0G6J6ODQdmkLVmZgHvAt9Nxy4EPgWWpHMcC/wM+ENB2YOAALqk/WOAN4APgTeBIwrSnyl4307AOGBB+rp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U+B0Yzy5cEnVo9tLwNrF+wv15Ko4H0ennwxczyJzW+5et+4HBJ3SVtAAwB/gWMA4ZI2kBSN7IBmvsbK8wtRjP
"text/plain": [
"<matplotlib.figure.Figure at 0x7f5d5e7e90f0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
2018-05-13 13:36:21 +02:00
"source": [
2018-05-13 18:29:18 +02:00
"test_classifier(labels=[\"true\",\"false\"], title=\"Configuration 4 -- train\", Xt=vec_train_3, yt=y3, clf=clf_3)\n",
2018-05-22 16:40:46 +02:00
"cm_4=test_classifier(labels=[\"true\",\"false\"], title=\"Configuration 4 -- test\", Xt=vec_test_3, yt=yt3, clf=clf_3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### exporting"
]
},
{
"cell_type": "code",
2018-06-06 13:31:15 +02:00
"execution_count": 25,
2018-05-22 16:40:46 +02:00
"metadata": {},
"outputs": [],
"source": [
"def recall(cm):\n",
" return cm[0,0] / (cm[0,0] + cm[0,1])\n",
"def precision(cm):\n",
" return cm[0,0] / (cm[0,0] + cm[1,0])\n",
"\n",
"def accuracy(cm):\n",
" return (cm[0,0] + cm[1,1]) / np.sum(cm)"
]
},
{
"cell_type": "code",
2018-06-06 13:31:15 +02:00
"execution_count": 26,
2018-05-22 16:40:46 +02:00
"metadata": {},
"outputs": [],
"source": [
"from rdflib import Namespace, Graph, Literal\n",
"from rdflib.namespace import DCTERMS, RDF"
]
},
{
"cell_type": "code",
2018-06-06 13:31:15 +02:00
"execution_count": 29,
2018-05-22 16:40:46 +02:00
"metadata": {},
"outputs": [],
"source": [
2018-05-28 19:13:57 +02:00
"class mexcore_graph(object):\n",
" def __init__(self, name_exp):\n",
" self.nsp = {\n",
" \"this\": Namespace(\"http://mex.aksw.org/examples/\"),\n",
" \"xsd\": Namespace(\"http://www.w3.org/2001/XMLSchema#\"),\n",
" \"rdfs\": Namespace(\"http://www.w3.org/2000/01/rdf-schema#\"),\n",
" \"mexcore\": Namespace(\"http://mex.aksw.org/mex-core#\"),\n",
" \"mexperf\": Namespace(\"http://mex.aksw.org/mex-perf#\"),\n",
" \"mexalgo\": Namespace(\"http://mex.aksw.org/mex-algo#\"),\n",
" \"prov\": Namespace(\"http://www.w3.org/ns/prov#\"),\n",
" \"dct\": DCTERMS,\n",
" \"rdf\": RDF\n",
" }\n",
" self.g = Graph()\n",
2018-05-22 16:40:46 +02:00
"\n",
2018-06-06 13:31:15 +02:00
" for i in self.nsp.items():\n",
2018-05-28 19:13:57 +02:00
" self.g.bind(i[0],i[1])\n",
" \n",
" self.exp = self.nsp[\"this\"][name_exp]\n",
" self.g.add((self.nsp[\"this\"][name_exp], self.nsp[\"rdf\"].type, self.nsp[\"mexcore\"].Experiment))\n",
" \n",
" def add_dataset(self,dset_name):\n",
" self.g.add((self.nsp[\"this\"][dset_name], self.nsp[\"rdf\"].type, self.nsp[\"mexcore\"].dataset))\n",
" self.g.add((self.nsp[\"this\"][dset_name], self.nsp[\"rdfs\"].label, Literal(dset_name)))\n",
" \n",
" \n",
" def add_datasets(self, dset_names):\n",
" for dset_name in dset_names:\n",
" self.add_dataset(dset_name)\n",
" \n",
" def add_model(self, model_name, literal):\n",
" self.g.add((self.nsp[\"this\"][model_name],self.nsp[\"rdf\"].type,self.nsp[\"mexalgo\"].Algorithm))\n",
" self.g.add((self.nsp[\"this\"][model_name],self.nsp[\"rdfs\"].label,Literal(model_name)))\n",
" self.g.add((self.nsp[\"this\"][model_name],self.nsp[\"dct\"].identifier,Literal(literal)))\n",
" \n",
" def add_configuration(self, conf_name, used_model, used_dset):\n",
" self.g.add((self.nsp[\"this\"][conf_name],self.nsp[\"rdf\"].type,self.nsp[\"mexcore\"].ExperimentConfiguration))\n",
" self.g.add((self.nsp[\"this\"][conf_name],self.nsp[\"rdfs\"].label,Literal(conf_name)))\n",
" self.g.add((self.nsp[\"this\"][conf_name],self.nsp[\"prov\"].used, self.nsp[\"this\"][used_model]))\n",
" self.g.add((self.nsp[\"this\"][conf_name],self.nsp[\"prov\"].used, self.nsp[\"this\"][used_dset]))\n",
" self.g.add((self.nsp[\"this\"][conf_name],self.nsp[\"prov\"].wasStartedBy, self.exp))\n",
" \n",
" def add_measurement(self, meas_name, used_conf, confusion_matrix):\n",
" self.g.add((self.nsp[\"this\"][meas_name],self.nsp[\"rdf\"].type,self.nsp[\"mexcore\"].PerformanceMeasure))\n",
" self.g.add((self.nsp[\"this\"][meas_name],self.nsp[\"mexperf\"].precision,Literal(str(precision(confusion_matrix)),datatype=self.nsp[\"xsd\"].float)))\n",
" self.g.add((self.nsp[\"this\"][meas_name],self.nsp[\"mexperf\"].recall,Literal(str(recall(confusion_matrix)),datatype=self.nsp[\"xsd\"].float)))\n",
" self.g.add((self.nsp[\"this\"][meas_name],self.nsp[\"mexperf\"].accuracy,Literal(str(accuracy(confusion_matrix)),datatype=self.nsp[\"xsd\"].float)))\n",
" self.g.add((self.nsp[\"this\"][meas_name],self.nsp[\"prov\"].wasGeneratedBy,self.nsp[\"this\"][used_conf]))\n",
2018-05-22 16:40:46 +02:00
"\n",
"\n",
2018-05-28 19:13:57 +02:00
" "
2018-05-22 16:40:46 +02:00
]
},
{
"cell_type": "code",
2018-06-06 13:31:15 +02:00
"execution_count": 30,
2018-05-22 16:40:46 +02:00
"metadata": {},
"outputs": [],
"source": [
2018-05-28 19:13:57 +02:00
"mg = mexcore_graph(\"jonas_weinz_task_2\")\n",
"mg.add_datasets([\"Dataset01\",\"Dataset02\",\"Dataset03\"])\n",
"\n",
"mg.add_model(\"model_a\", \"RandomForestClassifier\")\n",
"mg.add_model(\"model_b\", \"MLPClassifier\")\n",
"mg.add_model(\"model_c\", \"MLPClassifier\")\n",
"\n",
"mg.add_configuration(\"conf1\",\"model_a\",\"Dataset01\")\n",
"mg.add_configuration(\"conf2\",\"model_b\", \"Dataset02\")\n",
"mg.add_configuration(\"conf3a\",\"model_b\", \"Dataset01\")\n",
"mg.add_configuration(\"conf3b\", \"model_a\", \"Dataset02\")\n",
"mg.add_configuration(\"conf4\", \"model_c\", \"Dataset03\")\n",
"\n",
"mg.add_measurement(\"measure1\", \"conf1\", cm_1)\n",
"mg.add_measurement(\"measure2\", \"conf2\", cm_2)\n",
"mg.add_measurement(\"measure3a\", \"conf3a\", cm_3a)\n",
"mg.add_measurement(\"measure3b\", \"conf3b\", cm_3b)\n",
"mg.add_measurement(\"measure4\", \"conf4\", cm_4)\n",
"\n",
"mg.g.serialize(destination='output.ttl', format='turtle')"
2018-05-13 13:36:21 +02:00
]
},
2018-05-09 19:13:08 +02:00
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
2018-05-09 10:47:51 +02:00
}
],
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}