|
25 | 25 | {
|
26 | 26 | "cell_type": "code",
|
27 | 27 | "execution_count": null,
|
28 |
| - "metadata": { |
29 |
| - "collapsed": false |
30 |
| - }, |
| 28 | + "metadata": {}, |
31 | 29 | "outputs": [],
|
32 | 30 | "source": [
|
33 | 31 | "# Import libraries necessary for this project\n",
|
|
73 | 71 | {
|
74 | 72 | "cell_type": "code",
|
75 | 73 | "execution_count": null,
|
76 |
| - "metadata": { |
77 |
| - "collapsed": false |
78 |
| - }, |
| 74 | + "metadata": {}, |
79 | 75 | "outputs": [],
|
80 | 76 | "source": [
|
81 | 77 | "# Store the 'Survived' feature in a new variable and remove it from the dataset\n",
|
|
100 | 96 | {
|
101 | 97 | "cell_type": "code",
|
102 | 98 | "execution_count": null,
|
103 |
| - "metadata": { |
104 |
| - "collapsed": false |
105 |
| - }, |
| 99 | + "metadata": {}, |
106 | 100 | "outputs": [],
|
107 | 101 | "source": [
|
108 | 102 | "def accuracy_score(truth, pred):\n",
|
|
137 | 131 | {
|
138 | 132 | "cell_type": "code",
|
139 | 133 | "execution_count": null,
|
140 |
| - "metadata": { |
141 |
| - "collapsed": false |
142 |
| - }, |
| 134 | + "metadata": {}, |
143 | 135 | "outputs": [],
|
144 | 136 | "source": [
|
145 | 137 | "def predictions_0(data):\n",
|
|
170 | 162 | {
|
171 | 163 | "cell_type": "code",
|
172 | 164 | "execution_count": null,
|
173 |
| - "metadata": { |
174 |
| - "collapsed": false |
175 |
| - }, |
| 165 | + "metadata": {}, |
176 | 166 | "outputs": [],
|
177 | 167 | "source": [
|
178 | 168 | "print accuracy_score(outcomes, predictions)"
|
|
190 | 180 | "metadata": {},
|
191 | 181 | "source": [
|
192 | 182 | "***\n",
|
193 |
| - "Let's take a look at whether the feature **Sex** has any indication of survival rates among passengers using the `survival_stats` function. This function is defined in the `titanic_visualizations.py` Python script included with this project. The first two parameters passed to the function are the RMS Titanic data and passenger survival outcomes, respectively. The third parameter indicates which feature we want to plot survival statistics across. \n", |
| 183 | + "Let's take a look at whether the feature **Sex** has any indication of survival rates among passengers using the `survival_stats` function. This function is defined in the `visuals.py` Python script included with this project. The first two parameters passed to the function are the RMS Titanic data and passenger survival outcomes, respectively. The third parameter indicates which feature we want to plot survival statistics across. \n", |
194 | 184 | "Run the code cell below to plot the survival outcomes of passengers based on their sex."
|
195 | 185 | ]
|
196 | 186 | },
|
197 | 187 | {
|
198 | 188 | "cell_type": "code",
|
199 | 189 | "execution_count": null,
|
200 |
| - "metadata": { |
201 |
| - "collapsed": false |
202 |
| - }, |
| 190 | + "metadata": {}, |
203 | 191 | "outputs": [],
|
204 | 192 | "source": [
|
205 | 193 | "vs.survival_stats(data, outcomes, 'Sex')"
|
|
217 | 205 | {
|
218 | 206 | "cell_type": "code",
|
219 | 207 | "execution_count": null,
|
220 |
| - "metadata": { |
221 |
| - "collapsed": false |
222 |
| - }, |
| 208 | + "metadata": {}, |
223 | 209 | "outputs": [],
|
224 | 210 | "source": [
|
225 | 211 | "def predictions_1(data):\n",
|
|
252 | 238 | {
|
253 | 239 | "cell_type": "code",
|
254 | 240 | "execution_count": null,
|
255 |
| - "metadata": { |
256 |
| - "collapsed": false |
257 |
| - }, |
| 241 | + "metadata": {}, |
258 | 242 | "outputs": [],
|
259 | 243 | "source": [
|
260 | 244 | "print accuracy_score(outcomes, predictions)"
|
|
279 | 263 | {
|
280 | 264 | "cell_type": "code",
|
281 | 265 | "execution_count": null,
|
282 |
| - "metadata": { |
283 |
| - "collapsed": false |
284 |
| - }, |
| 266 | + "metadata": {}, |
285 | 267 | "outputs": [],
|
286 | 268 | "source": [
|
287 | 269 | "vs.survival_stats(data, outcomes, 'Age', [\"Sex == 'male'\"])"
|
|
301 | 283 | {
|
302 | 284 | "cell_type": "code",
|
303 | 285 | "execution_count": null,
|
304 |
| - "metadata": { |
305 |
| - "collapsed": false |
306 |
| - }, |
| 286 | + "metadata": {}, |
307 | 287 | "outputs": [],
|
308 | 288 | "source": [
|
309 | 289 | "def predictions_2(data):\n",
|
|
337 | 317 | {
|
338 | 318 | "cell_type": "code",
|
339 | 319 | "execution_count": null,
|
340 |
| - "metadata": { |
341 |
| - "collapsed": false |
342 |
| - }, |
| 320 | + "metadata": {}, |
343 | 321 | "outputs": [],
|
344 | 322 | "source": [
|
345 | 323 | "print accuracy_score(outcomes, predictions)"
|
|
369 | 347 | {
|
370 | 348 | "cell_type": "code",
|
371 | 349 | "execution_count": null,
|
372 |
| - "metadata": { |
373 |
| - "collapsed": false |
374 |
| - }, |
| 350 | + "metadata": {}, |
375 | 351 | "outputs": [],
|
376 | 352 | "source": [
|
377 | 353 | "vs.survival_stats(data, outcomes, 'Age', [\"Sex == 'male'\", \"Age < 18\"])"
|
|
389 | 365 | {
|
390 | 366 | "cell_type": "code",
|
391 | 367 | "execution_count": null,
|
392 |
| - "metadata": { |
393 |
| - "collapsed": false |
394 |
| - }, |
| 368 | + "metadata": {}, |
395 | 369 | "outputs": [],
|
396 | 370 | "source": [
|
397 | 371 | "def predictions_3(data):\n",
|
|
423 | 397 | {
|
424 | 398 | "cell_type": "code",
|
425 | 399 | "execution_count": null,
|
426 |
| - "metadata": { |
427 |
| - "collapsed": false |
428 |
| - }, |
| 400 | + "metadata": {}, |
429 | 401 | "outputs": [],
|
430 | 402 | "source": [
|
431 | 403 | "print accuracy_score(outcomes, predictions)"
|
|
472 | 444 | ],
|
473 | 445 | "metadata": {
|
474 | 446 | "kernelspec": {
|
475 |
| - "display_name": "Python 2", |
| 447 | + "display_name": "Python 3", |
476 | 448 | "language": "python",
|
477 |
| - "name": "python2" |
| 449 | + "name": "python3" |
478 | 450 | },
|
479 | 451 | "language_info": {
|
480 | 452 | "codemirror_mode": {
|
481 | 453 | "name": "ipython",
|
482 |
| - "version": 2 |
| 454 | + "version": 3 |
483 | 455 | },
|
484 | 456 | "file_extension": ".py",
|
485 | 457 | "mimetype": "text/x-python",
|
486 | 458 | "name": "python",
|
487 | 459 | "nbconvert_exporter": "python",
|
488 |
| - "pygments_lexer": "ipython2", |
489 |
| - "version": "2.7.11" |
| 460 | + "pygments_lexer": "ipython3", |
| 461 | + "version": "3.6.0" |
490 | 462 | }
|
491 | 463 | },
|
492 | 464 | "nbformat": 4,
|
493 |
| - "nbformat_minor": 0 |
| 465 | + "nbformat_minor": 1 |
494 | 466 | }
|
0 commit comments