Skip to content

Instantly share code, notes, and snippets.

@triestpa
Created June 7, 2016 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save triestpa/0ccb42341d6f45a3acd456360d527b14 to your computer and use it in GitHub Desktop.
Save triestpa/0ccb42341d6f45a3acd456360d527b14 to your computer and use it in GitHub Desktop.
Sample Setup
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"passengers_set_1 = titanic_df[titanic_df.pclass == 1].iloc[:20,:].copy()\n",
"passengers_set_2 = titanic_df[titanic_df.pclass == 2].iloc[:20,:].copy()\n",
"passengers_set_3 = titanic_df[titanic_df.pclass == 3].iloc[:20,:].copy()\n",
"passenger_set = pd.concat([passengers_set_1,passengers_set_2,passengers_set_3])\n",
"testing_set = preprocess_titanic_df(passenger_set)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"training_set = pd.concat([titanic_df, passenger_set]).drop_duplicates(keep=False)\n",
"training_set = preprocess_titanic_df(training_set)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"X_train = training_set.drop(['survived'], axis=1).values\n",
"y_train = training_set['survived'].values\n",
"X_test = testing_set.drop(['survived'], axis=1).values\n",
"y_test = testing_set['survived'].values"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Step #100, epoch #25, avg. train loss: 0.64422\n",
"Step #200, epoch #50, avg. train loss: 0.60906\n",
"Step #300, epoch #75, avg. train loss: 0.59641\n",
"Step #400, epoch #100, avg. train loss: 0.58298\n",
"Step #500, epoch #125, avg. train loss: 0.56000\n",
"Step #600, epoch #150, avg. train loss: 0.53058\n",
"Step #700, epoch #175, avg. train loss: 0.50669\n",
"Step #800, epoch #200, avg. train loss: 0.48891\n",
"Step #900, epoch #225, avg. train loss: 0.47792\n",
"Step #1000, epoch #250, avg. train loss: 0.46642\n"
]
},
{
"data": {
"text/plain": [
"0.78333333333333333"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tf_clf_dnn.fit (X_train, y_train)\n",
"tf_clf_dnn.score (X_test, y_test)"
]
}
],
"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.4.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment