{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Classifying News Headlines with Naive Bayes\n", "Reference: Classifying News Headlines and Explaining the Result from Kaggle[^1]\n", "\n", "[^1]: http://nbviewer.jupyter.org/github/dreamgonfly/lime-examples/blob/master/Classifying%20News%20Headlines%20and%20Explaining%20the%20Result.ipynb\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "news = pd.read_csv('uci-news-aggregator.csv').sample(frac=0.1)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "42242" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(news)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | ID | \n", "TITLE | \n", "URL | \n", "PUBLISHER | \n", "CATEGORY | \n", "STORY | \n", "HOSTNAME | \n", "TIMESTAMP | \n", "
---|---|---|---|---|---|---|---|---|
24589 | \n", "24590 | \n", "Wal-Mart takes aim at $2B used video game mark... | \n", "http://www.wncn.com/story/25002497/wal-mart-ta... | \n", "WNCN | \n", "b | \n", "dxrStbpfnH5zjIM-2HS6xpt7arezM | \n", "www.wncn.com | \n", "1395317817464 | \n", "
114446 | \n", "114782 | \n", "You'll likely recognize this 'Fargo,' you betcha! | \n", "http://www.usatoday.com/story/life/tv/2014/04/... | \n", "USA TODAY | \n", "e | \n", "dHALsQo-hgLH_0MDzDRorxcN9BVnM | \n", "www.usatoday.com | \n", "1397520248385 | \n", "
357516 | \n", "357976 | \n", "Sentence for sex abuser Rolf Harris 'too lenient' | \n", "http://www.scotsman.com/news/sentence-for-sex-... | \n", "Scotsman \\(blog\\) | \n", "e | \n", "dDGfw8WpQ5GpyLMGzdY_Xi99sjNPM | \n", "www.scotsman.com | \n", "1404528720056 | \n", "
241734 | \n", "242180 | \n", "Google (GOOGL) Developing Tablet with Advanced... | \n", "http://wallstreetpit.com/104126-google-googl-d... | \n", "Wall Street Pit | \n", "t | \n", "duaEdk4hebuJCDM4aiSvC1Nv3ThrM | \n", "wallstreetpit.com | \n", "1400868306109 | \n", "
206956 | \n", "207392 | \n", "FDA : Advanced prosthetic arm is approved for ... | \n", "http://canadajournal.net/health/fda-advanced-p... | \n", "Canada News | \n", "m | \n", "dz-jKxOMO7HMK0M7xdtCAX5E1-UOM | \n", "canadajournal.net | \n", "1399927161820 | \n", "