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-09 19:13:08 +02:00
" * dataset: https://www.cs.ucsb.edu/~william/data/liar_dataset.zip"
]
},
{
"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-09 16:50:59 +02:00
"import os"
]
},
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",
" 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",
" plot_confusion_matrix(cm, classes=labels, title=title)"
2018-05-13 10:12:19 +02:00
]
},
2018-05-09 16:50:59 +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-13 12:44:36 +02:00
"execution_count": 5,
2018-05-09 16:50:59 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"================================================================================\n",
2018-05-11 12:19:53 +02:00
"checking whether unzip is installed\n",
2018-05-09 16:50:59 +02:00
"================================================================================\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",
2018-05-11 12:19:53 +02:00
"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",
2018-05-09 16:50:59 +02:00
"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",
2018-05-13 10:12:19 +02:00
"================================================================================\n",
"================================================================================\n",
"downloading Helper script: script_dataset3.py\n",
"================================================================================\n",
"================================================================================\n",
"successfully finished action: downloading Helper script: script_dataset3.py\n",
2018-05-09 16:50:59 +02:00
"================================================================================\n"
]
}
],
"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-13 12:44:36 +02:00
"execution_count": 6,
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-13 12:44:36 +02:00
"execution_count": 7,
2018-05-09 16:50:59 +02:00
"metadata": {},
"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"
}
],
"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-13 12:44:36 +02:00
"execution_count": 8,
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-13 12:44:36 +02:00
"execution_count": 9,
2018-05-09 16:50:59 +02:00
"metadata": {},
"outputs": [],
2018-05-09 19:13:08 +02:00
"source": [
2018-05-13 18:29:18 +02:00
"vectorizer_1 = CountVectorizer(stop_words='english')\n",
"vec_train_1 = vectorizer_1.fit_transform(X1)\n",
"vec_test_1 = vectorizer_1.transform(Xt1)"
2018-05-09 19:13:08 +02:00
]
},
{
"cell_type": "code",
2018-05-13 13:36:21 +02:00
"execution_count": 10,
2018-05-09 19:13:08 +02:00
"metadata": {},
"outputs": [],
"source": [
2018-05-13 18:29:18 +02:00
"#tfidf_vectorizer_1 = TfidfVectorizer(stop_words='english', max_df=0.7)\n",
"#tfidf_train_1 = tfidf_vectorizer_1.fit_transform(X1)\n",
"#tfidf_test_1 = tfidf_vectorizer_1.transform(Xt1)"
2018-05-09 16:50:59 +02:00
]
2018-05-09 19:13:08 +02:00
},
{
"cell_type": "code",
2018-05-13 13:36:21 +02:00
"execution_count": 11,
2018-05-09 19:13:08 +02:00
"metadata": {},
2018-05-13 10:12:19 +02:00
"outputs": [],
2018-05-09 19:13:08 +02:00
"source": [
2018-05-13 12:44:36 +02:00
"#display(count_vectorizer.get_feature_names()[0:10])\n",
"#display(count_vectorizer.get_feature_names()[-10:])\n"
2018-05-09 19:13:08 +02:00
]
},
{
"cell_type": "code",
2018-05-13 13:36:21 +02:00
"execution_count": 12,
2018-05-09 19:13:08 +02:00
"metadata": {},
2018-05-13 10:12:19 +02:00
"outputs": [],
2018-05-09 19:13:08 +02:00
"source": [
2018-05-13 12:44:36 +02:00
"#display(tfidf_vectorizer.get_feature_names()[:10])\n",
"#display(tfidf_vectorizer.get_feature_names()[-10:])"
2018-05-09 19:13:08 +02:00
]
},
{
"cell_type": "code",
2018-05-13 13:36:21 +02:00
"execution_count": 13,
2018-05-09 19:13:08 +02:00
"metadata": {},
"outputs": [],
"source": [
"#count_df = pd.DataFrame(count_train.A, columns=count_vectorizer.get_feature_names())\n",
"#tfidf_df = pd.DataFrame(count_train.A, columns=tfidf_vectorizer.get_feature_names())\n",
"#diff = set(count_df.columns) - set(tfidf_df.columns)\n",
"#pp(count_df.equals(tfidf_df))"
]
},
{
"cell_type": "code",
2018-05-13 13:36:21 +02:00
"execution_count": 14,
2018-05-09 19:13:08 +02:00
"metadata": {},
2018-05-13 13:36:21 +02:00
"outputs": [],
2018-05-11 12:19:53 +02:00
"source": [
2018-05-13 13:36:21 +02:00
"#clf = MultinomialNB()\n",
"#clf.fit(tfidf_train_1, y1)\n",
"#pred = clf.predict(tfidf_test_1)\n",
"#score = metrics.accuracy_score(yt1, pred)\n",
"#pp(\"score: \" + str(score))\n",
"#cm = metrics.confusion_matrix(yt1, pred, labels=[\"FAKE\", \"REAL\"])\n",
"#plot_confusion_matrix(cm, classes=[\"FAKE\", \"REAL\"], title= \"TFIDF_Vecctorizer, Multinomial Naive Bayes\")"
2018-05-11 12:19:53 +02:00
]
},
{
"cell_type": "code",
2018-05-13 13:36:21 +02:00
"execution_count": 15,
2018-05-11 12:19:53 +02:00
"metadata": {},
"outputs": [
2018-05-09 19:13:08 +02:00
{
"name": "stdout",
"output_type": "stream",
"text": [
2018-05-13 13:36:21 +02:00
"'score: 0.9320143127762577'\n",
"Confusion matrix, without normalization\n",
"'score: 0.8838383838383839'\n",
2018-05-09 19:13:08 +02:00
"Confusion matrix, without normalization\n"
]
2018-05-11 12:19:53 +02:00
},
{
"data": {
2018-05-13 13:36:21 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUcAAAEmCAYAAADx4VKUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xec1NX1//HXmyqCShURQSyosSJ2TVAjIiLWb2whthgRa0xivl81xhiNqbZgjV00guaHJKhYsMWKioogCiJNQKSLNJFyfn/cO/DZZXZm2J3Zmdk9Tx6fBzOfemcHzt77KefIzHDOOVdRg2I3wDnnSpEHR+ecS8ODo3POpeHB0Tnn0vDg6JxzaXhwdM65NDw41jGSmkl6StJiSf+qwX76SXohn20rBknPSjqrmtv+QdJ8SV/lu12u9HlwLBJJP5Y0WtJSSbPjf+Lv52HXPwLaA23M7OTq7sTM/mlmvfLQngokHSbJJA2rNH+vOP/VHPdzraRHs61nZkeb2cPVaGdn4FfArma21cZu78qfB8cikPRL4Fbgj4RA1hm4Ezg+D7vfFvjMzFbnYV+FMg84SFKbxLyzgM/ydQAFNfn33RlYYGZzq3HsRjU4risVZuZTLU7AFsBS4OQM6zQlBM8v43Qr0DQuOwyYSejVzAVmA+fEZb8HvgNWxWOcC1wLPJrYdxfAgEbx/dnAFGAJMBXol5j/RmK7g4H3gMXx74MTy14FrgfejPt5AWhbxWdLtf9u4KI4ryEwC7gGeDWx7t+BGcA3wPvAD+L83pU+50eJdtwQ27EC2DHO+1lcfhcwNLH/vwAvAarUxp5x+7Vx/w/F+ccB44Gv436/l9hmGvB/wFhgZern61P5TkVvQH2b4n/s1Zn+8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matplotlib.figure.Figure at 0x7f458289be80>"
2018-05-11 12:19:53 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2018-05-13 13:36:21 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUAAAAEmCAYAAAATPUntAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmYFNXVx/Hvj31VNkUEFBcUt4hLFLeIoggogkZwZwkJatCY+BpjNPE1viYxauISo0YTFTRRiUrEXYMSxQgKsrgrKAQQ2QRcABE47x/3NjTjzHQzdE1v58NTz3Tfqq663c2cuffWrVMyM5xzrhzVyXcFnHMuXzwAOufKlgdA51zZ8gDonCtbHgCdc2XLA6Bzrmx5ACwxkhpLekzSCkn/2IL9nCnp2VzWLR8kPSVpcA1fe7WkJZI+yXW9XGHwAJgnks6QNFnSF5IWxF/Uw3Ow61OAtkBrMxtQ052Y2d/MrGcO6rMJSd0lmaQxFcr3jeXjs9zPlZLuy7SdmfU2s5E1qOcOwP8Ae5rZdpv7elccPADmgaSLgBuB3xCC1Q7ArUC/HOx+R+B9M1ubg30lZTFwiKTWaWWDgfdzdQAFW/L/ewdgqZktqsGx623BcV1tMjNfanEBtga+AAZUs01DQoD8OC43Ag3juu7APELrZBGwABga1/0KWAN8HY8xDLgSuC9t350AA+rF50OAD4HPgY+AM9PKJ6S97lDgNWBF/Hlo2rrxwP8BL8f9PAu0qeK9pep/OzAiltUF5gNXAOPTtr0JmAt8BkwBjojlvSq8z+lp9fh1rMcqYNdY9v24/jbg4bT9/w4YB6hCHY+Jr18f939PLD8ReAtYHve7R9prZgM/A2YAX6U+X18Ke8l7Bcptib+8a6v7BQGuAiYC2wLbAP8B/i+u6x5ffxVQH+gDrARaxvUVA16VARBoGoPL7nFdO2Cv+HhDAARa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adata": {},
"output_type": "display_data"
}
],
"source": [
2018-05-13 13:36:21 +02:00
"clf_a = MultinomialNB()\n",
2018-05-13 18:29:18 +02:00
"clf_a.fit(vec_train_1, y1)\n",
"test_classifier(labels=[\"FAKE\",\"REAL\"], title=\"Configuration 1, model a -- train\", Xt=vec_train_1,yt=y1, clf=clf_a)\n",
"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": [
"* try to get most important features"
]
},
{
"cell_type": "code",
2018-05-13 13:36:21 +02:00
"execution_count": 16,
2018-05-11 12:19:53 +02:00
"metadata": {},
"outputs": [
{
2018-05-13 10:12:19 +02:00
"data": {
"text/plain": [
2018-05-13 13:36:21 +02:00
"'\\ndef most_informative_feature_for_binary_classification(vectorizer, classifier, n=100):\\n \"\"\"\\n See: https://stackoverflow.com/a/26980472\\n \\n Identify most important features if given a vectorizer and binary classifier. Set n to the number\\n of weighted features you would like to show. (Note: current implementation merely prints and does not \\n return top classes.)\\n \"\"\"\\n\\n class_labels = classifier.classes_\\n feature_names = vectorizer.get_feature_names()\\n topn_class1 = sorted(zip(classifier.coef_[0], feature_names))[:n]\\n topn_class2 = sorted(zip(classifier.coef_[0], feature_names))[-n:]\\n \\n l = []\\n \\n for coef, feat in topn_class1:\\n l.append((class_labels[0], coef, feat))\\n\\n display(l)\\n\\n for coef, feat in reversed(topn_class2):\\n l.append((class_labels[1], coef, feat))\\n \\n display(l)\\n\\n\\nmost_informative_feature_for_binary_classification(tfidf_vectorizer_1, linear_clf, n=30)\\n'"
2018-05-13 10:12:19 +02:00
]
},
2018-05-13 13:36:21 +02:00
"execution_count": 16,
2018-05-13 10:12:19 +02:00
"metadata": {},
2018-05-13 13:36:21 +02:00
"output_type": "execute_result"
2018-05-11 12:19:53 +02:00
}
],
"source": [
2018-05-13 13:36:21 +02:00
"'''\n",
2018-05-11 12:19:53 +02:00
"def most_informative_feature_for_binary_classification(vectorizer, classifier, n=100):\n",
" \"\"\"\n",
" See: https://stackoverflow.com/a/26980472\n",
" \n",
" Identify most important features if given a vectorizer and binary classifier. Set n to the number\n",
" of weighted features you would like to show. (Note: current implementation merely prints and does not \n",
" return top classes.)\n",
" \"\"\"\n",
"\n",
" class_labels = classifier.classes_\n",
" feature_names = vectorizer.get_feature_names()\n",
" topn_class1 = sorted(zip(classifier.coef_[0], feature_names))[:n]\n",
" topn_class2 = sorted(zip(classifier.coef_[0], feature_names))[-n:]\n",
2018-05-13 10:12:19 +02:00
" \n",
" l = []\n",
" \n",
2018-05-11 12:19:53 +02:00
" for coef, feat in topn_class1:\n",
2018-05-13 10:12:19 +02:00
" l.append((class_labels[0], coef, feat))\n",
2018-05-11 12:19:53 +02:00
"\n",
2018-05-13 12:44:36 +02:00
" display(l)\n",
2018-05-11 12:19:53 +02:00
"\n",
" for coef, feat in reversed(topn_class2):\n",
2018-05-13 10:12:19 +02:00
" l.append((class_labels[1], coef, feat))\n",
" \n",
2018-05-13 12:44:36 +02:00
" display(l)\n",
2018-05-11 12:19:53 +02:00
"\n",
"\n",
2018-05-13 10:12:19 +02:00
"most_informative_feature_for_binary_classification(tfidf_vectorizer_1, linear_clf, n=30)\n",
2018-05-13 13:36:21 +02:00
"'''\n"
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-13 13:36:21 +02:00
"execution_count": 17,
2018-05-11 12:19:53 +02:00
"metadata": {},
"outputs": [
{
"data": {
2018-05-13 10:12:19 +02:00
"text/markdown": [
"----\n",
"#### Train Data:"
],
2018-05-11 12:19:53 +02:00
"text/plain": [
2018-05-13 10:12:19 +02:00
"<IPython.core.display.Markdown object>"
2018-05-11 12:19:53 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2018-05-13 10:12:19 +02:00
"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"
2018-05-13 13:36:21 +02:00
},
{
"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-13 13:36:21 +02:00
"execution_count": 18,
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-13 13:36:21 +02:00
"execution_count": 19,
2018-05-13 10:12:19 +02:00
"metadata": {},
"outputs": [],
"source": [
2018-05-13 18:29:18 +02:00
"vectorizer_2 = CountVectorizer(stop_words='english', max_df=0.7)\n",
"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-13 13:36:21 +02:00
"execution_count": 20,
2018-05-13 10:12:19 +02:00
"metadata": {},
2018-05-13 12:44:36 +02:00
"outputs": [
{
"data": {
"text/plain": [
"MultinomialNB(alpha=1.0, class_prior=None, fit_prior=True)"
]
},
2018-05-13 13:36:21 +02:00
"execution_count": 20,
2018-05-13 12:44:36 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
2018-05-13 10:12:19 +02:00
"source": [
2018-05-13 12:44:36 +02:00
"clf_b = MultinomialNB()\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-13 13:36:21 +02:00
"execution_count": 21,
2018-05-13 10:12:19 +02:00
"metadata": {},
2018-05-11 12:19:53 +02:00
"outputs": [
2018-05-13 10:12:19 +02:00
{
"name": "stdout",
"output_type": "stream",
"text": [
2018-05-13 18:29:18 +02:00
"'score: 0.8760555706891855'\n",
2018-05-13 13:36:21 +02:00
"Confusion matrix, without normalization\n",
2018-05-13 18:29:18 +02:00
"'score: 0.6105032822757112'\n",
2018-05-13 13:36:21 +02:00
"Confusion matrix, without normalization\n",
2018-05-13 18:29:18 +02:00
"'score: 0.6527777777777778'\n",
2018-05-13 10:12:19 +02:00
"Confusion matrix, without normalization\n"
]
},
2018-05-11 12:19:53 +02:00
{
"data": {
2018-05-13 18:29:18 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUYAAAEmCAYAAAAeIzmqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmcXfP9x/HXe2aIkEQQVUJE7UuRkNhqJ2IragtaS6lau9AWpbVG0KJNbfWr2KqxlVYJqS6q1Ba7WCLWbJrEkiZEBJ/fH+c7cedmZu6dyZm5c2feT4/zmHu/53vP+Z4Z95Pvcs73q4jAzMy+UFPpApiZdTQOjGZmRRwYzcyKODCamRVxYDQzK+LAaGZWxIGxE5HUXdJfJM2SdNsiHOcQSX/Ns2yVIOleSYe18rPnSZop6Z28y2UdnwNjBUg6WNI4SXMkTUtf4K/lcOj9gBWA5SJi/9YeJCJuioghOZSnAUnbSQpJdxalb5TSHyjzOGdJ+n2pfBGxa0Rc34py9gNOBtaLiC+39PNW/RwY25mkk4BfAeeTBbF+wBXAXjkcflVgQkR8msOx2soMYAtJyxWkHQZMyOsEyizK/9v9gHcjYnorzl23COe1jiIivLXTBiwNzAH2byZPN7LAOTVtvwK6pX3bAZPJajPTgWnAEWnf2cAnwPx0jiOBs4DfFxy7PxBAXXp/OPA6MBt4AzikIP2hgs9tCTwBzEo/tyzY9wBwLvBwOs5fgT5NXFt9+a8Cjk9ptcAU4OfAAwV5fw1MAv4HPAlsndKHFl3nswXlGJ7KMRdYI6UdlfZfCfyx4PgXAn8HVFTGndLnP0/Hvy6lfx0YD3yQjrtuwWfeBE4BngPm1f9+vVXvVvECdKUtfak/be6LA5wDPAp8CVge+A9wbtq3Xfr8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f98>"
2018-05-13 13:36:21 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2018-05-13 18:29:18 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUAAAAEmCAYAAAATPUntAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmcXFWZxvHf050NCIQlYQsJQUhYRxBCVJRFZdhEQUccEAUGMLKpjDuLggIKLjgiIqIgm7I4iqKAiDiIIFsEAoQ1gJBAJAmBQELWzjt/nNOh0unuqu7crqXr+fq5n1Sde+vcU9306zn3nvseRQRmZs2opdYNMDOrFQdAM2taDoBm1rQcAM2saTkAmlnTcgA0s6blANiPSFpN0u8lzZX0q1Wo51BJfyqybbUg6SZJh/fys2dKmi3pX0W3y+qHA2ANSPqYpEmS5kmakf9Q311A1R8BNgDWi4iDeltJRPwiIvYqoD0rkLSHpJB0XYfy7XP5bRXWc7qkK8sdFxH7RsRlvWjnaODzwDYRsWFPP2+NwwGwyiR9Dvgf4JukYDUauAA4oIDqNwWejIilBdTVV2YB75S0XknZ4cCTRZ1Ayar8tz0aeDkiZvbi3ANW4bxWbRHhrUobMAyYBxzUzTGDSQHyxbz9DzA479sDmE7qncwEZgD/lfd9HVgMLMnnOAo4HbiypO4xQAAD8vsjgGeA14FngUNLyu8o+dwuwH3A3PzvLiX7bgPOAO7M9fwJGN7Fd2tv/4XA8bmsFXgB+BpwW8mxPwCmAa8B/wB2zeX7dPiek0vacVZuxwJgi1x2dN7/Y+DXJfWfA9wKqEMb98yfX5brvzSXfxCYArya69265DP/BL4MPAQsav/5eqv/reYNaKYt//Eu7e4PBPgGcDewPjAC+DtwRt63R/78N4CBwH7AG8A6eX/HgNdlAATWyMFly7xvI2Db/Hp5AATWBV4BPpE/d0h+v17efxvwNDA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OlvSGpKGSHpX3ncV8N+SNpM0lDS0uqaL3mJP3EW6QXJCTmN1AGko3m4ysK2kHSQNIaWZL2dNYE5ELJQ0AfhYyb5ZpHRab+nis4Wl1ZI0EvgL6UZSX2Rc6ey7XAicJGnb3IZhkg7Kr3fOveOBpP9jWcibqcVeouufidWYA2AVREQb6VrXFqQ7jNNJ2ZgBLiElB72dNPdsIfDpAs65mHTj4yjSQj4fJwWbRXn/k6S1Rf4MPAXc0XlNKzgO+Iak10nX3ZZnVY6U1PQs4M48THxHh/YUmVbraFJQOb1kKDuvF/V0qrPvEhHXkRZSulrSa8AjwL75I2uRblS9QhrWvwx8J++7GNgm1/NbrK54InQTkXQPcGFEeM6cGe4B9muSdpe0YR5yHk6auvLHWrfLrF54Eef+bUvSMHUN0mJAH/H0DLM3eQhsZk3LQ2Aza1r9bgg8dO11Y90NR5Y/0Kpq3dUH1boJ1oXJD9w/OyJGFFVf61qbRixdUPa4WDDr5ojYp6jz9ka/C4DrbjiSL118fa2bYR0cssOo8gdZTQwfOrDjEzqrJJYuYPCWHy173MIHf1TpU0R9pt8FQDOrMQla6il7Wtd8DdDMiqeW8lu5KqRLJM2U9EiH8k9Lejw/0/3tkvKTJE2V9ISkvStppnuAZla8FR5B77VLSUkmLn+zWr2HlJps+4hYJGn9XL4NcDCwLSnxxp8ljctPYXXJPUAzK5gK6QFGxO2krDuljiXliWx/pHNmLj8AuDoiFkXEs6TcjRMowwHQzIol0jXAchsMlzSpZJtYQe3jgF0l3SPpr5J2zuUjWTF923RWTLXWKQ+BzaxgqnQIPDsixvew8gGk7OLvAHYGrpXU62w7DoBmVrwKhri9NB34TU70e6+kZaSkvC+wYr7LTagg16SHwGZWPKn81ju/Bd6
2018-05-13 13:36:21 +02:00
"text/plain": [
2018-05-13 18:29:18 +02:00
"<matplotlib.figure.Figure at 0x7f45828673c8>"
2018-05-13 13:36:21 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2018-05-13 18:29:18 +02:00
"image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4AXacR8h+Ac6Q1EvSIpIaB+3HAoelAfLeZAskXV1mpuhKPAR8ChysbOqqYWRd8UaTgSGS1k3jVydVUOdiwOyI+FDSRmRjdo1mkE2htXILn81tKi1J/YF7gPMjoqNmWbmVLGGfQvb30Tg9WLnpuZoVEa+SzexzsqSFla38t12Zj1kncgLsIOk+sO3IFud5jWwtjB+n3ZeSTQh6H9liRB8Ch+RwznnAD8kWRHqHbAqnm8nmriMinif75b4LeIHsIkc5BwKnSHqXbNzt85mU09XYkcCDkt6RtEmTePKcSutnZIn2pJKu7HvtqKdFabzverKFka4s2VVueq7W7ApsTDbl2Ik0M/2/VY+nw+riJI0HLo4I3zNn1oRbgF2MpC0kfSV1OfcA1iZrvZhZE17EuetZnayb2otsAaCdImJ6dUMyq03uAptZYbkLbGaF1eW6wEst3Sf6D/CtVrWmR3f/v7ZWPfbYozMjYtm86uu2+MCITz4oe1x8MOP2iNgmr/O2R5dLgP0HrMg141q6z9WqZeXlepU/yKqi50LK9emU+OQDeqz+o7LHfTjpgqpPDNHlEqCZVZkEDbU0k1rLnADNLH+Vr1lfVU6AZpY/lXtMujY4AZpZzuQWoJkVlPAYoJkVldwFNrMCcxfYzArLLUAzKyTfB2hmhVYnXeD6iNLM6ki6DabcVq4W6VJl62Y/VVK2rqSHJU2SNDEt04Ay50qaIukJSetXEqkToJnlr0Hlt/JGA00nS/gN2ZKx65It0fCbVL4tsFra9gUuqijMSg4yM6tY432A5bYy0jrKs5sW88WCVEuQrTwIMAy4PDIPA0tK6lf
2018-05-13 13:36:21 +02:00
"text/plain": [
2018-05-13 18:29:18 +02:00
"<matplotlib.figure.Figure at 0x7f457ff9bfd0>"
2018-05-11 12:19:53 +02:00
]
},
"metadata": {},
2018-05-13 10:12:19 +02:00
"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",
"test_classifier(labels=[\"true\", \"false\"], title=\"configuration 2 -- test\", Xt=vec_test_2, yt=yt2, clf=clf_b)\n",
"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-13 18:29:18 +02:00
"execution_count": 23,
2018-05-13 12:44:36 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2018-05-13 13:36:21 +02:00
"'score: 0.4617067833698031'\n",
2018-05-13 12:44:36 +02:00
"Confusion matrix, without normalization\n"
]
},
{
"data": {
2018-05-13 14:22:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUAAAAEmCAYAAAATPUntAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmYFNXVx/Hvb9hkE1Q2ZRFRAZUoKoJxxbjvu3GLoiiKS141aoxJXBKN5tWoUaMG426CmrjE3aivqBgQAVkTRRAQEAVUkEVA4Lx/3NvYtDPTPUPXdPf0+fDUw3RV9a3Ty5y599atWzIznHOuHFUUOgDnnCsUT4DOubLlCdA5V7Y8ATrnypYnQOdc2fIE6JwrW54A6xlJTSU9J2mRpL+vRzmnSPpXPmMrBEkvSTq9ls+9TtICSZ/lOy5XHDwBFoikkyWNlrRE0tz4i7pHHoo+DmgPbGJmx9e2EDP7q5kdkId41iGpvyST9HTG+h3i+mE5lnONpEez7WdmB5vZQ7WIswvwM2BbM+tQ0+e70uAJsAAkXQLcBvyOkKy6AHcBR+ah+M2BKWa2K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LEEJ8T+pAzzSd899K/J2tfT02n+YonaJ4kTMDaPu7/Ymp/M1tsZj8zs26EKfsvkbQv4X2bnvG+tTSzQyo7TmXi9/4+QtI81jImmK0PSikBjiL8stwoqbmkDSTtHrcNBS6WtIWkFoS/9I9XUVusiRGEEyQXxGmgjiQ0xVPGA9tJ6i1pA0K/SjYtgS/NbLmkvoS+tpT5hL64blU8N2/TUknaX9KOkhpI2pDQB/cVoZ8s36qM28xmEpq010pqrHBnvPQm/aOEpvKBMdYNFO4s1ym
2018-05-13 12:44:36 +02:00
"text/plain": [
2018-05-13 18:29:18 +02:00
"<matplotlib.figure.Figure at 0x7f457feb8eb8>"
2018-05-13 12:44:36 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"yt2_c3 = yt2.copy()\n",
"yt2_c3[yt2_c3 == \"true\"] = \"REAL\"\n",
"yt2_c3[yt2_c3 == \"false\"] = \"FAKE\"\n",
"\n",
2018-05-13 14:22:07 +02:00
"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-13 18:29:18 +02:00
"execution_count": 24,
2018-05-13 12:44:36 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2018-05-13 18:29:18 +02:00
"'score: 0.4962121212121212'\n",
2018-05-13 12:44:36 +02:00
"Confusion matrix, without normalization\n"
]
},
{
"data": {
2018-05-13 18:29:18 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUAAAAEmCAYAAAATPUntAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0c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U26ZraAJMs/hmMapryqNL+krYj1BA2I9Qwm/DruNZ8ypN4Wiozm6cwZnWapI0t/zTwU9Iez6/ieerc2crdBphplftgJxB+3xD6aHtISg/yywEv51nGpT9/M1sSuzfSU4s1J9SClyHpbWC7LMe+n/DHI1MbKv/eK713ST0JY7DbxVXNyJLmK8dn5l7Cz+pBSS0J450vJPzcliOkOUsdqgJP2bWMUqkBTgTaquo8elWlj1pE5S9kbUwG1s7o81k37XGlVFOqujM9c6D1/YTO93XNbGVCX0yuFE8phUpLBeFzsCKVg2lSspV7MrCKQkaa9G0pEwndGS3TlpXMLN+O+aW/L4XMMetQuU9rY0KLYBlm1sXMlLkQaqxTCN0EVZlM5c/J0vcjaT1Cd0wfQhdAS0ITOdtnoNrPTGyZXGJmmxCSsx5ASDA7kdDV0zrt59bCzFK3/XgCgKhUAuAIwgfrSkkrxc7fHeO2B4C/xM70ZoTJhgZXU1usibcIFwf6KKSBOpjKTZUxwKaSOklqSuhzyqU58IOZ/SypM5W/RNMIfXG/q+a1iaWlkrSXpC1jp3gLQvNwJvBJTY+Vh2rLbWYTCE3aSyQtrzAzXnptbxChqbx3LGtThQtV6+R57q0lHRr/cJ5JCApvQ7iAQOgze76G7+fvQG8
2018-05-13 12:44:36 +02:00
"text/plain": [
2018-05-13 18:29:18 +02:00
"<matplotlib.figure.Figure at 0x7f457fe43978>"
2018-05-13 12:44:36 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"yt1_c3 = yt1.copy()\n",
"yt1_c3[yt1_c3 == \"REAL\"] = \"true\"\n",
"yt1_c3[yt1_c3 == \"FAKE\"] = \"false\"\n",
"\n",
2018-05-13 14:22:07 +02:00
"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-13 18:29:18 +02:00
"execution_count": 25,
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",
" return train_test_split(df3['claim'], df3['y'], test_size=0.25, random_state=4222)\n",
" except Exception as e:\n",
" print(e)"
]
},
{
"cell_type": "code",
2018-05-13 18:29:18 +02:00
"execution_count": 26,
2018-05-13 13:36:21 +02:00
"metadata": {},
"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-13 18:29:18 +02:00
"{'mostly-true', 'pants-fire', 'half-true', 'barely-true', 'false', 'true'} 10240\n",
2018-05-13 13:36:21 +02:00
"1676\n",
"1995\n",
2018-05-13 14:22:07 +02:00
"{'true', 'false'} 3671\n",
2018-05-13 13:36:21 +02:00
"false 5159\n",
"true 4847\n",
"Name: y, dtype: int64\n",
"done\n"
]
}
],
"source": [
"X3, Xt3, y3, yt3 = get_dataset3_split('data/fake_or_real_news.csv', 'data/train.tsv')"
]
},
{
"cell_type": "code",
2018-05-13 18:29:18 +02:00
"execution_count": 28,
2018-05-13 13:36:21 +02:00
"metadata": {},
"outputs": [],
"source": [
2018-05-13 18:29:18 +02:00
"vectorizer_3 = CountVectorizer(stop_words='english')\n",
"vec_train_3 = vectorizer_3.fit_transform(X3)\n",
"vec_test_3 = vectorizer_3.transform(Xt3)"
2018-05-13 13:36:21 +02:00
]
},
{
"cell_type": "code",
2018-05-13 18:29:18 +02:00
"execution_count": 29,
2018-05-13 13:36:21 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MultinomialNB(alpha=1.0, class_prior=None, fit_prior=True)"
]
},
2018-05-13 18:29:18 +02:00
"execution_count": 29,
2018-05-13 13:36:21 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"clf_3 = MultinomialNB()\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-05-13 18:29:18 +02:00
"execution_count": 30,
2018-05-13 13:36:21 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'score: 0.8030383795309168'\n",
"Confusion matrix, without normalization\n",
"'score: 0.746203037569944'\n",
"Confusion matrix, without normalization\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUYAAAEmCAYAAAAeIzmqAAAABHNC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QPpPsQJZG8BfKLc9TFr7dxibKMkfVNSjzQ+eA7Z+NewMlfLrCI4MLZd25C91rS263pACbubZm2au9JmZnncYjQzy1Po5uOKpJouoY7dyl0Ny7PpequXuwrWgJEjX5waESuV6nzVK6wRsbDxUZuYM2VIROxZqnJLqe0Fxo7d6LTOIeWuhuV55vlryl0Fa0CXDhrfeK7ixcI5Rf0Ozn352mKfnGpxbS4wmlmZSVBV2SuzOTCaWem1viU8l4kDo5mVnir7sXEHRjMrMbnFaGZWh/AYo5lZXXJX2sxsKe5Km5nlcYvRzCyH72M0M6uHu9JmZrl8u46Z2dKqPMZoZvaFNnAfY2W3d82sFUpd6ca2xs4idZb0gqRRksZKuiClrynpeUnjJN1d+0ZHSZ3S93Fpf/+cc52d0t+Q9M3GynZgNLPSkxrfGjcP2CUial+Xu6ekrYHLgN9HxNpkb608NuU/FpiR0n+f8iFpfeBQYANgT+A6SQWbtA6MZlZ6JWgxRmZ2+tohbQHsAvwjpQ8CDkif90/fSft3laSUfldEzIuId4FxwJaFynZgNLPSqr2PsbGtqFOpWtLLwGRgKNkL3mZGxMKUZQLQL33uR/budtL+WUCv3PR6jqmXJ1/MrPSK6yr3ljQi5/uNEXFjboaIWARsIqkHcB+wbukq2TAHRjMrsaLvY5waEVsUkzEiZkp6guy1wD0k1aRW4arAxJRtIrAaMEFSDdAdmJaTXiv3mHq5K21mpVeCyRdJK6WWIpK6ALsDrwFPAAelbEcC96fPg9N30v7/RPZ+6MHAoWnWek1gAPB
"text/plain": [
2018-05-13 18:29:18 +02:00
"<matplotlib.figure.Figure at 0x7f457f9a8e10>"
2018-05-13 13:36:21 +02:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUYAAAEmCAYAAAAeIzmqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLC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kQXl+8GjSfOADDW6WWVNzYOz+PkMqb1oauu5U4HDTrFvyUNrMrIJ7jGZmFdq76bglqc+A0EKLNroZVmG9j6/Y6CbYfIwc+fDEiFiq+p616b3YShGzqs/WxIwJt0TENkWdt0jdLzAutCj91vh6o5thFe578OxGN8HmY0Bfja2+V+1i1oyafgffHXVOrU9M1V23C4xm1mAS9Ord6FYsEAdGMyte86Xu7BAHRjMrnlR9nybmwGhmBZN7jGZmbQjPMZqZtSUPpc3M5tLiQ+nWbr2ZNSep+lL1ELpI0nhJT5StW1LSbZKez1+XyOsl6SxJoyU9Jmn9svfsmfd/XtKetTTfgdHMilW6j7HaUt2fSYXRyh0J3B4RqwG359eQCrGtlpf9gfNSU7QkcAKwEanI3AmlYNoeB0YzK556VV+qiIi7SaVoy30FuDh/fzFzSoZ8BbgkF2l7ABgkaVngS8BtuYDZZOA25g62c/Eco5kVrObbdYZIGlH2+oKIuKDKe5aJiHH5+9dJpWohFVQrL9z2al43v/XtcmA0s+L1qumq9MSI+FRnTxERIalL8iZ6KG1mxSrdx7jgc4zz8kYeIpO/js/r/0eqOFmyQl43v/XtcmA0s4KpkDnG+bgOKF1Z3hP4Z9n6PfLV6Y2BqXnIfQuwtaQl8kWXrfO6dnkobWbFK+AGb0mXA1uQ5iJfJV1dPgW4StK
"text/plain": [
2018-05-13 18:29:18 +02:00
"<matplotlib.figure.Figure at 0x7f457fa31cf8>"
2018-05-13 13:36:21 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"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",
"test_classifier(labels=[\"true\",\"false\"], title=\"Configuration 4 -- test\", Xt=vec_test_3, yt=yt3, clf=clf_3)"
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
}