{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Classifying News Headlines and Explaining the Result\n", "Reference: Classifying News Headlines and Explaining the Result from [Kaggle](http://nbviewer.jupyter.org/github/dreamgonfly/lime-examples/blob/master/Classifying%20News%20Headlines%20and%20Explaining%20the%20Result.ipynb)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd\n", "# using Kaggle API https://github.com/Kaggle/kaggle-api\n", "DATA_FILE = \"~/.kaggle/datasets/uciml/news-aggregator-dataset/uci-news-aggregator.csv\"\n", "news = pd.read_csv(DATA_FILE).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", "
---|---|---|---|---|---|---|---|---|
13529 | \n", "13530 | \n", "Robotic fish designed to perform escape maneuv... | \n", "http://www.ecnmag.com/news/2014/03/robotic-fis... | \n", "ECNmag.com | \n", "t | \n", "dSmJK-WR4xv2inMKmnmxaRfd6cf1M | \n", "www.ecnmag.com | \n", "1395059947658 | \n", "
254251 | \n", "254697 | \n", "Faces & names: 'X-Men' climbs to $302 million ... | \n", "http://www.duluthnewstribune.com/content/faces... | \n", "Duluth News Tribune | \n", "e | \n", "d5poaO2w8Yffx6MDgPRQSF5POXCXM | \n", "www.duluthnewstribune.com | \n", "1401174011596 | \n", "
27785 | \n", "27786 | \n", "Which 'Divergent' Starlet Skipped Underwear fo... | \n", "http://www.cambio.com/2014/03/19/which-diverge... | \n", "Cambio | \n", "e | \n", "d55mX4D4wN3d5vMMYF9GgviF21QlM | \n", "www.cambio.com | \n", "1395333837043 | \n", "