Created
March 9, 2016 11:18
-
-
Save puyokw/9092ce535f3f5f53b7e4 to your computer and use it in GitHub Desktop.
td_intern otto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div style=\"border-style: dashed; border-width: 1px;\">\n", | |
"<div style=\"color: #888;\"># issued at 2016-03-09T11:07:00Z</div>URL: <a href=\"https://console.treasuredata.com/jobs/54798777\" target=\"_blank\">https://console.treasuredata.com/jobs/54798777</a><br>\n", | |
"<div style=\"color: #888;\"># started at 2016-03-09T11:07:01Z</div><pre style=\"color: #c44;\">\n", | |
"** WARNING: time index filtering is not set on \n", | |
"** This query could be very slow as a result.\n", | |
"** Please see https://docs.treasuredata.com/articles/presto-performance-tuning#leveraging-time-based-partitioning</pre>\n", | |
"<pre>2016-03-09 11:07:06: rows pending running done / total\n", | |
" Stage-0: 144K 0 0 1 / 1\n", | |
" Stage-1: 144K 0 0 1 / 1</pre>Result size: 2,239,637 bytes<br>\n", | |
"Download: 2,239,637 / 2,239,637 bytes (100.00%)<br>\n", | |
"<div style=\"color: #888;\"># downloaded at 2016-03-09T11:07:15Z</div></div>\n" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"%matplotlib inline\n", | |
"\n", | |
"import os\n", | |
"import pandas as pd\n", | |
"import pandas_td as td\n", | |
"import matplotlib.pyplot as plt\n", | |
"\n", | |
"con = td.connect(apikey=os.environ['TD_API_KEY'],endpoint='https://api.treasuredata.com/')\n", | |
"engine = con.query_engine(database='kaggle_otto', type='presto')\n", | |
"submission=td.read_td_table('submission', engine, limit=144368)\n", | |
"del submission['time']" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>Id</th>\n", | |
" <th>Class_1</th>\n", | |
" <th>Class_2</th>\n", | |
" <th>Class_3</th>\n", | |
" <th>Class_4</th>\n", | |
" <th>Class_5</th>\n", | |
" <th>Class_6</th>\n", | |
" <th>Class_7</th>\n", | |
" <th>Class_8</th>\n", | |
" <th>Class_9</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>1</td>\n", | |
" <td>0.026</td>\n", | |
" <td>0.204</td>\n", | |
" <td>0.200</td>\n", | |
" <td>0.532</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.016</td>\n", | |
" <td>0.010</td>\n", | |
" <td>0.008</td>\n", | |
" <td>0.004</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>2</td>\n", | |
" <td>0.018</td>\n", | |
" <td>0.044</td>\n", | |
" <td>0.036</td>\n", | |
" <td>0.016</td>\n", | |
" <td>0.004</td>\n", | |
" <td>0.590</td>\n", | |
" <td>0.008</td>\n", | |
" <td>0.268</td>\n", | |
" <td>0.016</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>3</td>\n", | |
" <td>0.002</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.996</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.002</td>\n", | |
" <td>0.000</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>4</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.576</td>\n", | |
" <td>0.292</td>\n", | |
" <td>0.054</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.006</td>\n", | |
" <td>0.008</td>\n", | |
" <td>0.064</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>5</td>\n", | |
" <td>0.104</td>\n", | |
" <td>0.002</td>\n", | |
" <td>0.006</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.000</td>\n", | |
" <td>0.034</td>\n", | |
" <td>0.020</td>\n", | |
" <td>0.276</td>\n", | |
" <td>0.558</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Id Class_1 Class_2 Class_3 Class_4 Class_5 Class_6 Class_7 Class_8 \\\n", | |
"0 1 0.026 0.204 0.200 0.532 0.000 0.016 0.010 0.008 \n", | |
"1 2 0.018 0.044 0.036 0.016 0.004 0.590 0.008 0.268 \n", | |
"2 3 0.002 0.000 0.000 0.000 0.000 0.996 0.000 0.002 \n", | |
"3 4 0.000 0.576 0.292 0.054 0.000 0.000 0.006 0.008 \n", | |
"4 5 0.104 0.002 0.006 0.000 0.000 0.034 0.020 0.276 \n", | |
"\n", | |
" Class_9 \n", | |
"0 0.004 \n", | |
"1 0.016 \n", | |
"2 0.000 \n", | |
"3 0.064 \n", | |
"4 0.558 " | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"submission.columns=['Id','Class_1','Class_2','Class_3','Class_4','Class_5','Class_6','Class_7','Class_8','Class_9']\n", | |
"submission.head()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"submission.to_csv('./Downloads/otto_submission.csv', index=False)" | |
] | |
} | |
], | |
"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.5.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment