Skip to content
This repository was archived by the owner on Jun 12, 2019. It is now read-only.

Commit bd1f52f

Browse files
author
Tyler Hutcherson
authored
Merge pull request #6 from MetisMachine/th_hotfix
hotfix on data condition
2 parents 95682be + 5a5cce7 commit bd1f52f

File tree

2 files changed

+63
-23
lines changed

2 files changed

+63
-23
lines changed

bitcoinRNN.ipynb

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
{
44
"cell_type": "code",
55
"execution_count": 1,
6-
"metadata": {},
6+
"metadata": {
7+
"collapsed": false,
8+
"scrolled": true
9+
},
710
"outputs": [
811
{
912
"name": "stdout",
@@ -35,7 +38,10 @@
3538
{
3639
"cell_type": "code",
3740
"execution_count": 2,
38-
"metadata": {},
41+
"metadata": {
42+
"collapsed": false,
43+
"scrolled": true
44+
},
3945
"outputs": [
4046
{
4147
"name": "stdout",
@@ -77,7 +83,9 @@
7783
{
7884
"cell_type": "code",
7985
"execution_count": 18,
80-
"metadata": {},
86+
"metadata": {
87+
"collapsed": true
88+
},
8189
"outputs": [],
8290
"source": [
8391
"# # Bitcoin Price Prediction \n",
@@ -118,7 +126,9 @@
118126
{
119127
"cell_type": "code",
120128
"execution_count": 163,
121-
"metadata": {},
129+
"metadata": {
130+
"collapsed": false
131+
},
122132
"outputs": [
123133
{
124134
"name": "stdout",
@@ -162,7 +172,9 @@
162172
{
163173
"cell_type": "code",
164174
"execution_count": 164,
165-
"metadata": {},
175+
"metadata": {
176+
"collapsed": false
177+
},
166178
"outputs": [
167179
{
168180
"name": "stdout",
@@ -184,7 +196,9 @@
184196
{
185197
"cell_type": "code",
186198
"execution_count": 165,
187-
"metadata": {},
199+
"metadata": {
200+
"collapsed": false
201+
},
188202
"outputs": [
189203
{
190204
"name": "stdout",
@@ -201,9 +215,11 @@
201215
"print(\"Validating a single record:\", flush=True)\n",
202216
"print(gtrends_json['data'][0], flush=True)\n",
203217
"\n",
204-
"# Convert to pandas df\n",
218+
"# Convert to pandas df and handle string NaN's coming through data engine\n",
205219
"gtrends = pd.DataFrame.from_records(gtrends_json['data'])\\\n",
206-
" .pivot(index='date', values='interest', columns='keyword')\n",
220+
" .pivot(index='date', values='interest', columns='keyword')\\\n",
221+
" .replace({'NaN': None})\\\n",
222+
" .fillna(method='pad')\n",
207223
"\n",
208224
"# Set proper date format\n",
209225
"gtrends.index = pd.to_datetime(gtrends.index)\n",
@@ -215,7 +231,9 @@
215231
{
216232
"cell_type": "code",
217233
"execution_count": 108,
218-
"metadata": {},
234+
"metadata": {
235+
"collapsed": false
236+
},
219237
"outputs": [
220238
{
221239
"name": "stdout",
@@ -245,7 +263,9 @@
245263
{
246264
"cell_type": "code",
247265
"execution_count": 109,
248-
"metadata": {},
266+
"metadata": {
267+
"collapsed": true
268+
},
249269
"outputs": [],
250270
"source": [
251271
"# Join google trends with quandl coin data\n",
@@ -292,7 +312,9 @@
292312
{
293313
"cell_type": "code",
294314
"execution_count": 113,
295-
"metadata": {},
315+
"metadata": {
316+
"collapsed": true
317+
},
296318
"outputs": [],
297319
"source": [
298320
"# ## Recurrent Neural Network Model\n",
@@ -317,7 +339,9 @@
317339
{
318340
"cell_type": "code",
319341
"execution_count": 140,
320-
"metadata": {},
342+
"metadata": {
343+
"collapsed": false
344+
},
321345
"outputs": [
322346
{
323347
"name": "stdout",
@@ -444,7 +468,9 @@
444468
{
445469
"cell_type": "code",
446470
"execution_count": 141,
447-
"metadata": {},
471+
"metadata": {
472+
"collapsed": true
473+
},
448474
"outputs": [],
449475
"source": [
450476
"# Predict over the holdout test set and retain the hidden state\n",
@@ -462,7 +488,9 @@
462488
{
463489
"cell_type": "code",
464490
"execution_count": 142,
465-
"metadata": {},
491+
"metadata": {
492+
"collapsed": true
493+
},
466494
"outputs": [],
467495
"source": [
468496
"# Get the prediction and date value\n",
@@ -473,7 +501,9 @@
473501
{
474502
"cell_type": "code",
475503
"execution_count": 143,
476-
"metadata": {},
504+
"metadata": {
505+
"collapsed": false
506+
},
477507
"outputs": [
478508
{
479509
"name": "stdout",
@@ -492,7 +522,9 @@
492522
{
493523
"cell_type": "code",
494524
"execution_count": 160,
495-
"metadata": {},
525+
"metadata": {
526+
"collapsed": true
527+
},
496528
"outputs": [],
497529
"source": [
498530
"data_out = [{'price_prediction': predicted_price,\n",
@@ -504,7 +536,9 @@
504536
{
505537
"cell_type": "code",
506538
"execution_count": 161,
507-
"metadata": {},
539+
"metadata": {
540+
"collapsed": true
541+
},
508542
"outputs": [],
509543
"source": [
510544
"# # Persist Predictions\n",
@@ -528,7 +562,9 @@
528562
{
529563
"cell_type": "code",
530564
"execution_count": 162,
531-
"metadata": {},
565+
"metadata": {
566+
"collapsed": false
567+
},
532568
"outputs": [
533569
{
534570
"name": "stdout",
@@ -550,10 +586,11 @@
550586
}
551587
],
552588
"metadata": {
589+
"anaconda-cloud": {},
553590
"kernelspec": {
554-
"display_name": "Python 3",
591+
"display_name": "Python [Root]",
555592
"language": "python",
556-
"name": "python3"
593+
"name": "Python [Root]"
557594
},
558595
"language_info": {
559596
"codemirror_mode": {
@@ -565,7 +602,7 @@
565602
"name": "python",
566603
"nbconvert_exporter": "python",
567604
"pygments_lexer": "ipython3",
568-
"version": "3.6.2"
605+
"version": "3.5.4"
569606
}
570607
},
571608
"nbformat": 4,

main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@
4848
print("Validating a single record:", flush=True)
4949
print(gtrends_json['data'][0], flush=True)
5050

51-
# Convert to pandas df
52-
gtrends = pd.DataFrame.from_records(gtrends_json['data']) .pivot(index='date', values='interest', columns='keyword')
51+
# Convert to pandas df and handles string NaN's coming through data engine
52+
gtrends = pd.DataFrame.from_records(gtrends_json['data'])\
53+
.pivot(index='date', values='interest', columns='keyword')\
54+
.replace({'NaN': None})\
55+
.fillna(method='pad')
5356

5457
# Set proper date format
5558
gtrends.index = pd.to_datetime(gtrends.index)

0 commit comments

Comments
 (0)