Skip to content

Instantly share code, notes, and snippets.

@crawles
Last active August 24, 2016 18:29
Show Gist options
  • Save crawles/dbc1c655b0ded929c181a80879cbcc78 to your computer and use it in GitHub Desktop.
Save crawles/dbc1c655b0ded929c181a80879cbcc78 to your computer and use it in GitHub Desktop.
Doesn't work with CF
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"ExecuteTime": {
"end_time": "2016-08-24T11:16:17.753340",
"start_time": "2016-08-24T11:16:17.733692"
},
"collapsed": false
},
"outputs": [],
"source": [
"import json\n",
"\n",
"import dill\n",
"import pandas as pd\n",
"import sklearn\n",
"import urllib.request"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"f = urllib.request.urlopen(\"https://github.com/crawles/sentiment_analysis_twitter_model/raw/master/twitter_sentiment_model.pkl\")\n",
"cl = dill.load(f)\n",
"f.close()\n",
"\n",
"# Doesn't work.\n",
"# Error message in Cloud Foundry:\n",
"\n",
"# 2016-08-24T14:13:28.29-0400 [APP/0] ERR [KernelGatewayApp] Kernel started: d91d61c7-581f-4526-adcf-f63c91579392\n",
"# 2016-08-24T14:13:35.32-0400 [APP/0] ERR [KernelGatewayApp] Kernel shutdown: d91d61c7-581f-4526-adcf-f63c91579392\n",
"\n",
"# ...\n",
"# <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)>'], 'user_expressions': {}, 'evalue': '<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)>', 'payload': [], 'ename': 'URLError', 'status': 'error', 'execution_count': 2})\n",
"# ..."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2016-08-22T17:52:15.653020",
"start_time": "2016-08-22T17:52:15.636712"
},
"collapsed": false
},
"outputs": [],
"source": [
"# POST /polarity_compute\n",
"req = json.loads(REQUEST)\n",
"print(cl.predict_proba(req['body']['data'])[:][:,1])"
]
}
],
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment