-
Home / Old / Documentation / Learn / Examples / Binary Classification / Index
VerticaPy
Example: Methods in a Binary Classification Model¶
In this example, we use the 'Titanic' dataset to demonstrate the methods available to binary classification models.
from verticapy.datasets import load_titanic
titanic = load_titanic()
display(titanic)
123 pclassInt | 123 survivedInt | Abc Varchar(96) | Abc genderChar(1) | 123 ageNumeric(6,3) | 123 sibspInt | 123 parchInt | Abc ticketVarchar(24) | 123 fareNumeric(7,4) | Abc cabinChar(10) | Abc embarkedChar(1) | Abc boatChar(4) | 123 bodyInt | Abc homedestVarchar(64) | 123 splitFloat | |
1 | 1 | 0 | f | 2.000 | 1 | 2 | 113781 | 151.5500 | C22 C26 | S | [null] | [null] | Montreal, PQ / Chesterville, ON | 0.663092836970463 | |
2 | 1 | 0 | m | 30.000 | 1 | 2 | 113781 | 151.5500 | C22 C26 | S | [null] | 135 | Montreal, PQ / Chesterville, ON | 0.161721162730828 | |
3 | 1 | 0 | f | 25.000 | 1 | 2 | 113781 | 151.5500 | C22 C26 | S | [null] | [null] | Montreal, PQ / Chesterville, ON | 0.527904006186873 | |
4 | 1 | 0 | m | 39.000 | 0 | 0 | 112050 | 0.0000 | A36 | S | [null] | [null] | Belfast, NI | 0.936014187755063 | |
5 | 1 | 0 | m | 71.000 | 0 | 0 | PC 17609 | 49.5042 | [null] | C | [null] | 22 | Montevideo, Uruguay | 0.40874306159094 | |
6 | 1 | 0 | m | 47.000 | 1 | 0 | PC 17757 | 227.5250 | C62 C64 | C | [null] | 124 | New York, NY | 0.0771260927431285 | |
7 | 1 | 0 | m | [null] | 0 | 0 | PC 17318 | 25.9250 | [null] | S | [null] | [null] | New York, NY | 0.360885151894763 | |
8 | 1 | 0 | m | 24.000 | 0 | 1 | PC 17558 | 247.5208 | B58 B60 | C | [null] | [null] | Montreal, PQ | 0.78418595273979 | |
9 | 1 | 0 | m | 36.000 | 0 | 0 | 13050 | 75.2417 | C6 | C | A | [null] | Winnipeg, MN | 0.392075354699045 | |
10 | 1 | 0 | m | 25.000 | 0 | 0 | 13905 | 26.0000 | [null] | C | [null] | 148 | San Francisco, CA | 0.760954634286463 | |
11 | 1 | 0 | m | 45.000 | 0 | 0 | 113784 | 35.5000 | T | S | [null] | [null] | Trenton, NJ | 0.083728444064036 | |
12 | 1 | 0 | m | 42.000 | 0 | 0 | 110489 | 26.5500 | D22 | S | [null] | [null] | London / Winnipeg, MB | 0.187408909434453 | |
13 | 1 | 0 | m | 41.000 | 0 | 0 | 113054 | 30.5000 | A21 | S | [null] | [null] | Pomeroy, WA | 0.464197367895395 | |
14 | 1 | 0 | m | 48.000 | 0 | 0 | PC 17591 | 50.4958 | B10 | C | [null] | 208 | Omaha, NE | 0.989756429567933 | |
15 | 1 | 0 | m | [null] | 0 | 0 | 112379 | 39.6000 | [null] | C | [null] | [null] | Philadelphia, PA | 0.197682256577536 | |
16 | 1 | 0 | m | 45.000 | 0 | 0 | 113050 | 26.5500 | B38 | S | [null] | [null] | Washington, DC | 0.567665293579921 | |
17 | 1 | 0 | m | [null] | 0 | 0 | 113798 | 31.0000 | [null] | S | [null] | [null] | [null] | 0.221641422947869 | |
18 | 1 | 0 | m | 33.000 | 0 | 0 | 695 | 5.0000 | B51 B53 B5 | S | [null] | [null] | New York, NY | 0.738475721329451 | |
19 | 1 | 0 | m | 28.000 | 0 | 0 | 113059 | 47.1000 | [null] | S | [null] | [null] | Montevideo, Uruguay | 0.366747971624136 | |
20 | 1 | 0 | m | 17.000 | 0 | 0 | 113059 | 47.1000 | [null] | S | [null] | [null] | Montevideo, Uruguay | 0.268853009678423 | |
21 | 1 | 0 | m | 49.000 | 0 | 0 | 19924 | 26.0000 | [null] | S | [null] | [null] | Ascot, Berkshire / Rochester, NY | 0.513710137922317 | |
22 | 1 | 0 | m | 36.000 | 1 | 0 | 19877 | 78.8500 | C46 | S | [null] | 172 | Little Onn Hall, Staffs | 0.453328180825338 | |
23 | 1 | 0 | m | 46.000 | 1 | 0 | W.E.P. 5734 | 61.1750 | E31 | S | [null] | [null] | Amenia, ND | 0.169697929639369 | |
24 | 1 | 0 | m | [null] | 0 | 0 | 112051 | 0.0000 | [null] | S | [null] | [null] | Liverpool, England / Belfast | 0.0851756541524082 | |
25 | 1 | 0 | m | 27.000 | 1 | 0 | 13508 | 136.7792 | C89 | C | [null] | [null] | Los Angeles, CA | 0.0152691958937794 | |
26 | 1 | 0 | m | [null] | 0 | 0 | 110465 | 52.0000 | A14 | S | [null] | [null] | Stoughton, MA | 0.916533817071468 | |
27 | 1 | 0 | m | 47.000 | 0 | 0 | 5727 | 25.5875 | E58 | S | [null] | [null] | Victoria, BC | 0.568090511020273 | |
28 | 1 | 0 | m | 37.000 | 1 | 1 | PC 17756 | 83.1583 | E52 | C | [null] | [null] | Lakewood, NJ | 0.627309911651537 | |
29 | 1 | 0 | m | [null] | 0 | 0 | 113791 | 26.5500 | [null] | S | [null] | [null] | Roachdale, IN | 0.747528738109395 | |
30 | 1 | 0 | m | 70.000 | 1 | 1 | WE/P 5735 | 71.0000 | B22 | S | [null] | 269 | Milwaukee, WI | 0.335725951706991 | |
31 | 1 | 0 | m | 39.000 | 1 | 0 | PC 17599 | 71.2833 | C85 | C | [null] | [null] | New York, NY | 0.481107967440039 | |
32 | 1 | 0 | m | 31.000 | 1 | 0 | F.C. 12750 | 52.0000 | B71 | S | [null] | [null] | Montreal, PQ | 0.0527018732391298 | |
33 | 1 | 0 | m | 50.000 | 1 | 0 | PC 17761 | 106.4250 | C86 | C | [null] | 62 | Deephaven, MN / Cedar Rapids, IA | 0.97885028552264 | |
34 | 1 | 0 | m | 39.000 | 0 | 0 | PC 17580 | 29.7000 | A18 | C | [null] | 133 | Philadelphia, PA | 0.157812902005389 | |
35 | 1 | 0 | f | 36.000 | 0 | 0 | PC 17531 | 31.6792 | A29 | C | [null] | [null] | New York, NY | 0.644055349286646 | |
36 | 1 | 0 | m | [null] | 0 | 0 | PC 17483 | 221.7792 | C95 | S | [null] | [null] | [null] | 0.279342690482736 | |
37 | 1 | 0 | m | 30.000 | 0 | 0 | 113051 | 27.7500 | C111 | C | [null] | [null] | New York, NY | 0.767035169992596 | |
38 | 1 | 0 | m | 19.000 | 3 | 2 | 19950 | 263.0000 | C23 C25 C2 | S | [null] | [null] | Winnipeg, MB | 0.490231013158336 | |
39 | 1 | 0 | m | 64.000 | 1 | 4 | 19950 | 263.0000 | C23 C25 C2 | S | [null] | [null] | Winnipeg, MB | 0.235716909635812 | |
40 | 1 | 0 | m | [null] | 0 | 0 | 113778 | 26.5500 | D34 | S | [null] | [null] | Westcliff-on-Sea, Essex | 0.390792083926499 | |
41 | 1 | 0 | m | [null] | 0 | 0 | 112058 | 0.0000 | B102 | S | [null] | [null] | [null] | 0.71977791050449 | |
42 | 1 | 0 | m | 37.000 | 1 | 0 | 113803 | 53.1000 | C123 | S | [null] | [null] | Scituate, MA | 0.114295000443235 | |
43 | 1 | 0 | m | 47.000 | 0 | 0 | 111320 | 38.5000 | E63 | S | [null] | 275 | St Anne's-on-Sea, Lancashire | 0.831041638739407 | |
44 | 1 | 0 | m | 24.000 | 0 | 0 | PC 17593 | 79.2000 | B86 | C | [null] | [null] | [null] | 0.967385483207181 | |
45 | 1 | 0 | m | 71.000 | 0 | 0 | PC 17754 | 34.6542 | A5 | C | [null] | [null] | New York, NY | 0.591355679091066 | |
46 | 1 | 0 | m | 38.000 | 0 | 1 | PC 17582 | 153.4625 | C91 | S | [null] | 147 | Winnipeg, MB | 0.870173128321767 | |
47 | 1 | 0 | m | 46.000 | 0 | 0 | PC 17593 | 79.2000 | B82 B84 | C | [null] | [null] | New York, NY | 0.99003749457188 | |
48 | 1 | 0 | m | [null] | 0 | 0 | 113796 | 42.4000 | [null] | S | [null] | [null] | [null] | 0.403090257197618 | |
49 | 1 | 0 | m | 45.000 | 1 | 0 | 36973 | 83.4750 | C83 | S | [null] | [null] | New York, NY | 0.323395622661337 | |
50 | 1 | 0 | m | 40.000 | 0 | 0 | 112059 | 0.0000 | B94 | S | [null] | 110 | [null] | 0.170912061352283 | |
51 | 1 | 0 | m | 55.000 | 1 | 1 | 12749 | 93.5000 | B69 | S | [null] | 307 | Montreal, PQ | 0.737730374792591 | |
52 | 1 | 0 | m | 42.000 | 0 | 0 | 113038 | 42.5000 | B11 | S | [null] | [null] | London / Middlesex | 0.356435600901023 | |
53 | 1 | 0 | m | [null] | 0 | 0 | 17463 | 51.8625 | E46 | S | [null] | [null] | Brighton, MA | 0.61207019072026 | |
54 | 1 | 0 | m | 55.000 | 0 | 0 | 680 | 50.0000 | C39 | S | [null] | [null] | London / Birmingham | 0.96926672779955 | |
55 | 1 | 0 | m | 42.000 | 1 | 0 | 113789 | 52.0000 | [null] | S | [null] | 38 | New York, NY | 0.536786375567317 | |
56 | 1 | 0 | m | [null] | 0 | 0 | PC 17600 | 30.6958 | [null] | C | 14 | [null] | New York, NY | 0.56807480356656 | |
57 | 1 | 0 | f | 50.000 | 0 | 0 | PC 17595 | 28.7125 | C49 | C | [null] | [null] | Paris, France New York, NY | 0.809493057662621 | |
58 | 1 | 0 | m | 46.000 | 0 | 0 | 694 | 26.0000 | [null] | S | [null] | 80 | Bennington, VT | 0.982430178439245 | |
59 | 1 | 0 | m | 50.000 | 0 | 0 | 113044 | 26.0000 | E60 | S | [null] | [null] | London | 0.696268314495683 | |
60 | 1 | 0 | m | 32.500 | 0 | 0 | 113503 | 211.5000 | C132 | C | [null] | 45 | [null] | 0.267956059193239 | |
61 | 1 | 0 | m | 58.000 | 0 | 0 | 11771 | 29.7000 | B37 | C | [null] | 258 | Buffalo, NY | 0.533579262206331 | |
62 | 1 | 0 | m | 41.000 | 1 | 0 | 17464 | 51.8625 | D21 | S | [null] | [null] | Southington / Noank, CT | 0.596509403316304 | |
63 | 1 | 0 | m | [null] | 0 | 0 | 113028 | 26.5500 | C124 | S | [null] | [null] | Portland, OR | 0.430671361740679 | |
64 | 1 | 0 | m | [null] | 0 | 0 | PC 17612 | 27.7208 | [null] | C | [null] | [null] | Chicago, IL | 0.355260608484969 | |
65 | 1 | 0 | m | 29.000 | 0 | 0 | 113501 | 30.0000 | D6 | S | [null] | 126 | Springfield, MA | 0.0263086690101773 | |
66 | 1 | 0 | m | 30.000 | 0 | 0 | 113801 | 45.5000 | [null] | S | [null] | [null] | London / New York, NY | 0.309636837337166 | |
67 | 1 | 0 | m | 30.000 | 0 | 0 | 110469 | 26.0000 | C106 | S | [null] | [null] | Brockton, MA | 0.0152337534818798 | |
68 | 1 | 0 | m | 19.000 | 1 | 0 | 113773 | 53.1000 | D30 | S | [null] | [null] | New York, NY | 0.364044237649068 | |
69 | 1 | 0 | m | 46.000 | 0 | 0 | 13050 | 75.2417 | C6 | C | [null] | 292 | Vancouver, BC | 0.475262716412544 | |
70 | 1 | 0 | m | 54.000 | 0 | 0 | 17463 | 51.8625 | E46 | S | [null] | 175 | Dorchester, MA | 0.30979929654859 | |
71 | 1 | 0 | m | 28.000 | 1 | 0 | PC 17604 | 82.1708 | [null] | C | [null] | [null] | New York, NY | 0.408943912014365 | |
72 | 1 | 0 | m | 65.000 | 0 | 0 | 13509 | 26.5500 | E38 | S | [null] | 249 | East Bridgewater, MA | 0.478623170405626 | |
73 | 1 | 0 | m | 44.000 | 2 | 0 | 19928 | 90.0000 | C78 | Q | [null] | 230 | Fond du Lac, WI | 0.148798908572644 | |
74 | 1 | 0 | m | 55.000 | 0 | 0 | 113787 | 30.5000 | C30 | S | [null] | [null] | Montreal, PQ | 0.126385363517329 | |
75 | 1 | 0 | m | 47.000 | 0 | 0 | 113796 | 42.4000 | [null] | S | [null] | [null] | Washington, DC | 0.625826764851809 | |
76 | 1 | 0 | m | 37.000 | 0 | 1 | PC 17596 | 29.7000 | C118 | C | [null] | [null] | Brooklyn, NY | 0.980584268225357 | |
77 | 1 | 0 | m | 58.000 | 0 | 2 | 35273 | 113.2750 | D48 | C | [null] | 122 | Lexington, MA | 0.496911391615868 | |
78 | 1 | 0 | m | 64.000 | 0 | 0 | 693 | 26.0000 | [null] | S | [null] | 263 | Isle of Wight, England | 0.189228599891067 | |
79 | 1 | 0 | m | 65.000 | 0 | 1 | 113509 | 61.9792 | B30 | C | [null] | 234 | Providence, RI | 0.280916610732675 | |
80 | 1 | 0 | m | 28.500 | 0 | 0 | PC 17562 | 27.7208 | D43 | C | [null] | 189 | ?Havana, Cuba | 0.485971889225766 | |
81 | 1 | 0 | m | [null] | 0 | 0 | 112052 | 0.0000 | [null] | S | [null] | [null] | Belfast | 0.392282282235101 | |
82 | 1 | 0 | m | 45.500 | 0 | 0 | 113043 | 28.5000 | C124 | S | [null] | 166 | Surbiton Hill, Surrey | 0.0708799788262695 | |
83 | 1 | 0 | m | 23.000 | 0 | 0 | 12749 | 93.5000 | B24 | S | [null] | [null] | Montreal, PQ | 0.089022418949753 | |
84 | 1 | 0 | m | 29.000 | 1 | 0 | 113776 | 66.6000 | C2 | S | [null] | [null] | Isleworth, England | 0.545445928815752 | |
85 | 1 | 0 | m | 18.000 | 1 | 0 | PC 17758 | 108.9000 | C65 | C | [null] | [null] | Madrid, Spain | 0.513165891636163 | |
86 | 1 | 0 | m | 47.000 | 0 | 0 | 110465 | 52.0000 | C110 | S | [null] | 207 | Worcester, MA | 0.164120414061472 | |
87 | 1 | 0 | m | 38.000 | 0 | 0 | 19972 | 0.0000 | [null] | S | [null] | [null] | Rotterdam, Netherlands | 0.431144091999158 | |
88 | 1 | 0 | m | 22.000 | 0 | 0 | PC 17760 | 135.6333 | [null] | C | [null] | 232 | [null] | 0.174215304432437 | |
89 | 1 | 0 | m | [null] | 0 | 0 | PC 17757 | 227.5250 | [null] | C | [null] | [null] | [null] | 0.641582700423896 | |
90 | 1 | 0 | m | 31.000 | 0 | 0 | PC 17590 | 50.4958 | A24 | S | [null] | [null] | Trenton, NJ | 0.814205173403025 | |
91 | 1 | 0 | m | [null] | 0 | 0 | 113767 | 50.0000 | A32 | S | [null] | [null] | Seattle, WA | 0.195884848246351 | |
92 | 1 | 0 | m | 36.000 | 0 | 0 | 13049 | 40.1250 | A10 | C | [null] | [null] | Winnipeg, MB | 0.653516355436295 | |
93 | 1 | 0 | m | 55.000 | 1 | 0 | PC 17603 | 59.4000 | [null] | C | [null] | [null] | New York, NY | 0.10073209204711 | |
94 | 1 | 0 | m | 33.000 | 0 | 0 | 113790 | 26.5500 | [null] | S | [null] | 109 | London | 0.278607521904632 | |
95 | 1 | 0 | m | 61.000 | 1 | 3 | PC 17608 | 262.3750 | B57 B59 B6 | C | [null] | [null] | Haverford, PA / Cooperstown, NY | 0.0629091840237379 | |
96 | 1 | 0 | m | 50.000 | 1 | 0 | 13507 | 55.9000 | E44 | S | [null] | [null] | Duluth, MN | 0.963238372234628 | |
97 | 1 | 0 | m | 56.000 | 0 | 0 | 113792 | 26.5500 | [null] | S | [null] | [null] | New York, NY | 0.462777572218329 | |
98 | 1 | 0 | m | 56.000 | 0 | 0 | 17764 | 30.6958 | A7 | C | [null] | [null] | St James, Long Island, NY | 0.0639691490214318 | |
99 | 1 | 0 | m | 24.000 | 1 | 0 | 13695 | 60.0000 | C31 | S | [null] | [null] | Huntington, WV | 0.0569538441486657 | |
100 | 1 | 0 | m | [null] | 0 | 0 | 113056 | 26.0000 | A19 | S | [null] | [null] | Streatham, Surrey | 0.725290278671309 |
Rows: 1-100 of 1234 | Columns: 15
Let's create a logistic regression to predict the survival of the passengers. We'll use the age and the fare as predictors.
from verticapy.learn.linear_model import LogisticRegression
model = LogisticRegression("public.LR_titanic")
model.fit("public.titanic", ["age", "fare"], "survived")
======= details ======= predictor|coefficient|std_err |z_value |p_value ---------+-----------+--------+--------+-------- Intercept| -0.09135 | 0.15559|-0.58709| 0.55714 age | -0.01439 | 0.00475|-3.02599| 0.00248 fare | 0.01546 | 0.00212| 7.29445| 0.00000 ============== regularization ============== type| lambda ----+-------- l2 | 1.00000 =========== call_string =========== logistic_reg('public.LR_titanic', 'public.titanic', '"survived"', '"age", "fare"' USING PARAMETERS optimizer='cgd', epsilon=0.0001, max_iterations=100, regularization='l2', lambda=1, alpha=0) =============== Additional Info =============== Name |Value ------------------+----- iteration_count | 5 rejected_row_count| 238 accepted_row_count| 996
Fitting the model creates new model attributes, making methods easier to use.
model.X
['"age"', '"fare"']
model.y
'"survived"'
model.input_relation
'public.titanic'
model.test_relation
'public.titanic'
Since we didn't write a test relation when fitting the model, the model will use the training relation as the test relation.
Let's compute the accuracy of the model.
model.score(method = "accuracy")
0.6969205834683955
The 'score' method uses the 'y' attribute and the model prediction in the 'test_relation' to compute the accuracy of the model. You can change these attributes at any time to deploy the models on different columns.
Models have many useful attributes. For example, the 'coef_' attribute gives us the p-value of the model.
model.coef_
Abc predictorVarchar(65000) | 123 coefficientFloat | 123 std_errFloat | 123 z_valueFloat | 123 p_valueFloat | |
1 | Intercept | -0.0913487583375232 | 0.155594583418985 | -0.587094719689177 | 0.557140093691283 |
2 | age | -0.0143850235204285 | 0.00475381848744904 | -3.02599343210255 | 0.00247817685818187 |
3 | fare | 0.0154603623341147 | 0.00211946971061135 | 7.29444835031647 | 2.99885239324488e-13 |
You can view other attributes using the 'get_attr' method.
model.get_attr()
Abc attr_nameVarchar(128) | Abc Long varchar(32000000) | 123 #_of_rowsInteger | |
1 | details | 3 | |
2 | regularization | 1 | |
3 | iteration_count | 1 | |
4 | rejected_row_count | 1 | |
5 | accepted_row_count | 1 | |
6 | call_string | 1 |
PRC, ROC or lift charts can help you visualize your model.
model.roc_curve()
model.prc_curve()
model.lift_chart()
Let's look at the SQL query for our model.
display(model.deploySQL())
PREDICT_LOGISTIC_REG("age", "fare" USING PARAMETERS model_name = 'public.LR_titanic', type = 'probability', match_by_pos = 'true')
You can evaluate the quality of your model with the 'report' method.
model.report()
value | |
auc | 0.6974762740166146 |
prc_auc | 0.6003540469187277 |
accuracy | 0.6969205834683955 |
log_loss | 0.281741003041208 |
precision | 0.6194968553459119 |
recall | 0.43777777777777777 |
f1_score | 0.5769062584198693 |
mcc | 0.31193616529653234 |
informedness | 0.2834410430839003 |
markedness | 0.34329598198346645 |
csi | 0.3450087565674256 |
cutoff | 0.999 |
You can also add the prediction to your vDataFrame.
model.predict(titanic, name = "pred_survived")
123 pclassInt | 123 survivedInt | Abc Varchar(96) | Abc genderChar(1) | 123 ageNumeric(6,3) | 123 sibspInt | 123 parchInt | Abc ticketVarchar(24) | 123 fareNumeric(7,4) | Abc cabinChar(10) | Abc embarkedChar(1) | Abc boatChar(4) | 123 bodyInt | Abc homedestVarchar(64) | 123 splitFloat | 123 pred_survivedFloat | |
1 | 1 | 0 | f | 2.000 | 1 | 2 | 113781 | 151.5500 | C22 C26 | S | [null] | [null] | Montreal, PQ / Chesterville, ON | 0.663092836970463 | 0.902287093955018 | |
2 | 1 | 0 | m | 30.000 | 1 | 2 | 113781 | 151.5500 | C22 C26 | S | [null] | 135 | Montreal, PQ / Chesterville, ON | 0.161721162730828 | 0.860580339225997 | |
3 | 1 | 0 | f | 25.000 | 1 | 2 | 113781 | 151.5500 | C22 C26 | S | [null] | [null] | Montreal, PQ / Chesterville, ON | 0.527904006186873 | 0.868988361039809 | |
4 | 1 | 0 | m | 39.000 | 0 | 0 | 112050 | 0.0000 | A36 | S | [null] | [null] | Belfast, NI | 0.936014187755063 | 0.342456861096143 | |
5 | 1 | 0 | m | 71.000 | 0 | 0 | PC 17609 | 49.5042 | [null] | C | [null] | 22 | Montevideo, Uruguay | 0.40874306159094 | 0.414029417624538 | |
6 | 1 | 0 | m | 47.000 | 1 | 0 | PC 17757 | 227.5250 | C62 C64 | C | [null] | 124 | New York, NY | 0.0771260927431285 | 0.939923180247281 | |
7 | 1 | 0 | m | [null] | 0 | 0 | PC 17318 | 25.9250 | [null] | S | [null] | [null] | New York, NY | 0.360885151894763 | [null] | |
8 | 1 | 0 | m | 24.000 | 0 | 1 | PC 17558 | 247.5208 | B58 B60 | C | [null] | [null] | Montreal, PQ | 0.78418595273979 | 0.967395967987415 | |
9 | 1 | 0 | m | 36.000 | 0 | 0 | 13050 | 75.2417 | C6 | C | A | [null] | Winnipeg, MN | 0.392075354699045 | 0.635075716220126 | |
10 | 1 | 0 | m | 25.000 | 0 | 0 | 13905 | 26.0000 | [null] | C | [null] | 148 | San Francisco, CA | 0.760954634286463 | 0.487751219756109 | |
11 | 1 | 0 | m | 45.000 | 0 | 0 | 113784 | 35.5000 | T | S | [null] | [null] | Trenton, NJ | 0.083728444064036 | 0.45268401682983 | |
12 | 1 | 0 | m | 42.000 | 0 | 0 | 110489 | 26.5500 | D22 | S | [null] | [null] | London / Winnipeg, MB | 0.187408909434453 | 0.429216842625225 | |
13 | 1 | 0 | m | 41.000 | 0 | 0 | 113054 | 30.5000 | A21 | S | [null] | [null] | Pomeroy, WA | 0.464197367895395 | 0.447792562926084 | |
14 | 1 | 0 | m | 48.000 | 0 | 0 | PC 17591 | 50.4958 | B10 | C | [null] | 208 | Omaha, NE | 0.989756429567933 | 0.499713369289623 | |
15 | 1 | 0 | m | [null] | 0 | 0 | 112379 | 39.6000 | [null] | C | [null] | [null] | Philadelphia, PA | 0.197682256577536 | [null] | |
16 | 1 | 0 | m | 45.000 | 0 | 0 | 113050 | 26.5500 | B38 | S | [null] | [null] | Washington, DC | 0.567665293579921 | 0.418678120562726 | |
17 | 1 | 0 | m | [null] | 0 | 0 | 113798 | 31.0000 | [null] | S | [null] | [null] | [null] | 0.221641422947869 | [null] | |
18 | 1 | 0 | m | 33.000 | 0 | 0 | 695 | 5.0000 | B51 B53 B5 | S | [null] | [null] | New York, NY | 0.738475721329451 | 0.380187438266754 | |
19 | 1 | 0 | m | 28.000 | 0 | 0 | 113059 | 47.1000 | [null] | S | [null] | [null] | Montevideo, Uruguay | 0.366747971624136 | 0.558247748355842 | |
20 | 1 | 0 | m | 17.000 | 0 | 0 | 113059 | 47.1000 | [null] | S | [null] | [null] | Montevideo, Uruguay | 0.268853009678423 | 0.59683358559402 | |
21 | 1 | 0 | m | 49.000 | 0 | 0 | 19924 | 26.0000 | [null] | S | [null] | [null] | Ascot, Berkshire / Rochester, NY | 0.513710137922317 | 0.40269570450922 | |
22 | 1 | 0 | m | 36.000 | 1 | 0 | 19877 | 78.8500 | C46 | S | [null] | 172 | Little Onn Hall, Staffs | 0.453328180825338 | 0.647904295062985 | |
23 | 1 | 0 | m | 46.000 | 1 | 0 | W.E.P. 5734 | 61.1750 | E31 | S | [null] | [null] | Amenia, ND | 0.169697929639369 | 0.548033368992097 | |
24 | 1 | 0 | m | [null] | 0 | 0 | 112051 | 0.0000 | [null] | S | [null] | [null] | Liverpool, England / Belfast | 0.0851756541524082 | [null] | |
25 | 1 | 0 | m | 27.000 | 1 | 0 | 13508 | 136.7792 | C89 | C | [null] | [null] | Los Angeles, CA | 0.0152691958937794 | 0.836841368048104 | |
26 | 1 | 0 | m | [null] | 0 | 0 | 110465 | 52.0000 | A14 | S | [null] | [null] | Stoughton, MA | 0.916533817071468 | [null] | |
27 | 1 | 0 | m | 47.000 | 0 | 0 | 5727 | 25.5875 | E58 | S | [null] | [null] | Victoria, BC | 0.568090511020273 | 0.408093385463076 | |
28 | 1 | 0 | m | 37.000 | 1 | 1 | PC 17756 | 83.1583 | E52 | C | [null] | [null] | Lakewood, NJ | 0.627309911651537 | 0.659723620113947 | |
29 | 1 | 0 | m | [null] | 0 | 0 | 113791 | 26.5500 | [null] | S | [null] | [null] | Roachdale, IN | 0.747528738109395 | [null] | |
30 | 1 | 0 | m | 70.000 | 1 | 1 | WE/P 5735 | 71.0000 | B22 | S | [null] | 269 | Milwaukee, WI | 0.335725951706991 | 0.499846330243495 | |
31 | 1 | 0 | m | 39.000 | 1 | 0 | PC 17599 | 71.2833 | C85 | C | [null] | [null] | New York, NY | 0.481107967440039 | 0.610568134710964 | |
32 | 1 | 0 | m | 31.000 | 1 | 0 | F.C. 12750 | 52.0000 | B71 | S | [null] | [null] | Montreal, PQ | 0.0527018732391298 | 0.566271370083388 | |
33 | 1 | 0 | m | 50.000 | 1 | 0 | PC 17761 | 106.4250 | C86 | C | [null] | 62 | Deephaven, MN / Cedar Rapids, IA | 0.97885028552264 | 0.69736239132171 | |
34 | 1 | 0 | m | 39.000 | 0 | 0 | PC 17580 | 29.7000 | A18 | C | [null] | 133 | Philadelphia, PA | 0.157812902005389 | 0.451851682120462 | |
35 | 1 | 0 | f | 36.000 | 0 | 0 | PC 17531 | 31.6792 | A29 | C | [null] | [null] | New York, NY | 0.644055349286646 | 0.470176022074582 | |
36 | 1 | 0 | m | [null] | 0 | 0 | PC 17483 | 221.7792 | C95 | S | [null] | [null] | [null] | 0.279342690482736 | [null] | |
37 | 1 | 0 | m | 30.000 | 0 | 0 | 113051 | 27.7500 | C111 | C | [null] | [null] | New York, NY | 0.767035169992596 | 0.476548617099486 | |
38 | 1 | 0 | m | 19.000 | 3 | 2 | 19950 | 263.0000 | C23 C25 C2 | S | [null] | [null] | Winnipeg, MB | 0.490231013158336 | 0.975906180234669 | |
39 | 1 | 0 | m | 64.000 | 1 | 4 | 19950 | 263.0000 | C23 C25 C2 | S | [null] | [null] | Winnipeg, MB | 0.235716909635812 | 0.954958561645637 | |
40 | 1 | 0 | m | [null] | 0 | 0 | 113778 | 26.5500 | D34 | S | [null] | [null] | Westcliff-on-Sea, Essex | 0.390792083926499 | [null] | |
41 | 1 | 0 | m | [null] | 0 | 0 | 112058 | 0.0000 | B102 | S | [null] | [null] | [null] | 0.71977791050449 | [null] | |
42 | 1 | 0 | m | 37.000 | 1 | 0 | 113803 | 53.1000 | C123 | S | [null] | [null] | Scituate, MA | 0.114295000443235 | 0.549178143505082 | |
43 | 1 | 0 | m | 47.000 | 0 | 0 | 111320 | 38.5000 | E63 | S | [null] | 275 | St Anne's-on-Sea, Lancashire | 0.831041638739407 | 0.457050875151761 | |
44 | 1 | 0 | m | 24.000 | 0 | 0 | PC 17593 | 79.2000 | B86 | C | [null] | [null] | [null] | 0.967385483207181 | 0.687374090669011 | |
45 | 1 | 0 | m | 71.000 | 0 | 0 | PC 17754 | 34.6542 | A5 | C | [null] | [null] | New York, NY | 0.591355679091066 | 0.359641853265752 | |
46 | 1 | 0 | m | 38.000 | 0 | 1 | PC 17582 | 153.4625 | C91 | S | [null] | 147 | Winnipeg, MB | 0.870173128321767 | 0.850000656266457 | |
47 | 1 | 0 | m | 46.000 | 0 | 0 | PC 17593 | 79.2000 | B82 B84 | C | [null] | [null] | New York, NY | 0.99003749457188 | 0.615715266719299 | |
48 | 1 | 0 | m | [null] | 0 | 0 | 113796 | 42.4000 | [null] | S | [null] | [null] | [null] | 0.403090257197618 | [null] | |
49 | 1 | 0 | m | 45.000 | 1 | 0 | 36973 | 83.4750 | C83 | S | [null] | [null] | New York, NY | 0.323395622661337 | 0.634571406951772 | |
50 | 1 | 0 | m | 40.000 | 0 | 0 | 112059 | 0.0000 | B94 | S | [null] | 110 | [null] | 0.170912061352283 | 0.339225019136842 | |
51 | 1 | 0 | m | 55.000 | 1 | 1 | 12749 | 93.5000 | B69 | S | [null] | 307 | Montreal, PQ | 0.737730374792591 | 0.637150750290462 | |
52 | 1 | 0 | m | 42.000 | 0 | 0 | 113038 | 42.5000 | B11 | S | [null] | [null] | London / Middlesex | 0.356435600901023 | 0.490387597739646 | |
53 | 1 | 0 | m | [null] | 0 | 0 | 17463 | 51.8625 | E46 | S | [null] | [null] | Brighton, MA | 0.61207019072026 | [null] | |
54 | 1 | 0 | m | 55.000 | 0 | 0 | 680 | 50.0000 | C39 | S | [null] | [null] | London / Birmingham | 0.96926672779955 | 0.472650591374252 | |
55 | 1 | 0 | m | 42.000 | 1 | 0 | 113789 | 52.0000 | [null] | S | [null] | 38 | New York, NY | 0.536786375567317 | 0.5270782542596 | |
56 | 1 | 0 | m | [null] | 0 | 0 | PC 17600 | 30.6958 | [null] | C | 14 | [null] | New York, NY | 0.56807480356656 | [null] | |
57 | 1 | 0 | f | 50.000 | 0 | 0 | PC 17595 | 28.7125 | C49 | C | [null] | [null] | Paris, France New York, NY | 0.809493057662621 | 0.409340040706095 | |
58 | 1 | 0 | m | 46.000 | 0 | 0 | 694 | 26.0000 | [null] | S | [null] | 80 | Bennington, VT | 0.982430178439245 | 0.413118022171097 | |
59 | 1 | 0 | m | 50.000 | 0 | 0 | 113044 | 26.0000 | E60 | S | [null] | [null] | London | 0.696268314495683 | 0.399240543697541 | |
60 | 1 | 0 | m | 32.500 | 0 | 0 | 113503 | 211.5000 | C132 | C | [null] | 45 | [null] | 0.267956059193239 | 0.937672886359139 | |
61 | 1 | 0 | m | 58.000 | 0 | 0 | 11771 | 29.7000 | B37 | C | [null] | 258 | Buffalo, NY | 0.533579262206331 | 0.385443236804805 | |
62 | 1 | 0 | m | 41.000 | 1 | 0 | 17464 | 51.8625 | D21 | S | [null] | [null] | Southington / Noank, CT | 0.596509403316304 | 0.530133019018482 | |
63 | 1 | 0 | m | [null] | 0 | 0 | 113028 | 26.5500 | C124 | S | [null] | [null] | Portland, OR | 0.430671361740679 | [null] | |
64 | 1 | 0 | m | [null] | 0 | 0 | PC 17612 | 27.7208 | [null] | C | [null] | [null] | Chicago, IL | 0.355260608484969 | [null] | |
65 | 1 | 0 | m | 29.000 | 0 | 0 | 113501 | 30.0000 | D6 | S | [null] | 126 | Springfield, MA | 0.0263086690101773 | 0.488825968193734 | |
66 | 1 | 0 | m | 30.000 | 0 | 0 | 113801 | 45.5000 | [null] | S | [null] | [null] | London / New York, NY | 0.309636837337166 | 0.54501454283726 | |
67 | 1 | 0 | m | 30.000 | 0 | 0 | 110469 | 26.0000 | C106 | S | [null] | [null] | Brockton, MA | 0.0152337534818798 | 0.469804278926542 | |
68 | 1 | 0 | m | 19.000 | 1 | 0 | 113773 | 53.1000 | D30 | S | [null] | [null] | New York, NY | 0.364044237649068 | 0.6121315642608 | |
69 | 1 | 0 | m | 46.000 | 0 | 0 | 13050 | 75.2417 | C6 | C | [null] | 292 | Vancouver, BC | 0.475262716412544 | 0.601136818234549 | |
70 | 1 | 0 | m | 54.000 | 0 | 0 | 17463 | 51.8625 | E46 | S | [null] | 175 | Dorchester, MA | 0.30979929654859 | 0.483424329568936 | |
71 | 1 | 0 | m | 28.000 | 1 | 0 | PC 17604 | 82.1708 | [null] | C | [null] | [null] | New York, NY | 0.408943912014365 | 0.684873698601698 | |
72 | 1 | 0 | m | 65.000 | 0 | 0 | 13509 | 26.5500 | E38 | S | [null] | 249 | East Bridgewater, MA | 0.478623170405626 | 0.350713898416137 | |
73 | 1 | 0 | m | 44.000 | 2 | 0 | 19928 | 90.0000 | C78 | Q | [null] | 230 | Fond du Lac, WI | 0.148798908572644 | 0.660863093173368 | |
74 | 1 | 0 | m | 55.000 | 0 | 0 | 113787 | 30.5000 | C30 | S | [null] | [null] | Montreal, PQ | 0.126385363517329 | 0.398676199712231 | |
75 | 1 | 0 | m | 47.000 | 0 | 0 | 113796 | 42.4000 | [null] | S | [null] | [null] | Washington, DC | 0.625826764851809 | 0.472047799209853 | |
76 | 1 | 0 | m | 37.000 | 0 | 1 | PC 17596 | 29.7000 | C118 | C | [null] | [null] | Brooklyn, NY | 0.980584268225357 | 0.458986889161578 | |
77 | 1 | 0 | m | 58.000 | 0 | 2 | 35273 | 113.2750 | D48 | C | [null] | 122 | Lexington, MA | 0.496911391615868 | 0.695422164643373 | |
78 | 1 | 0 | m | 64.000 | 0 | 0 | 693 | 26.0000 | [null] | S | [null] | 263 | Isle of Wight, England | 0.189228599891067 | 0.352054443373522 | |
79 | 1 | 0 | m | 65.000 | 0 | 1 | 113509 | 61.9792 | B30 | C | [null] | 234 | Providence, RI | 0.280916610732675 | 0.48296799283024 | |
80 | 1 | 0 | m | 28.500 | 0 | 0 | PC 17562 | 27.7208 | D43 | C | [null] | 189 | ?Havana, Cuba | 0.485971889225766 | 0.481820937620929 | |
81 | 1 | 0 | m | [null] | 0 | 0 | 112052 | 0.0000 | [null] | S | [null] | [null] | Belfast | 0.392282282235101 | [null] | |
82 | 1 | 0 | m | 45.500 | 0 | 0 | 113043 | 28.5000 | C124 | S | [null] | 166 | Surbiton Hill, Surrey | 0.0708799788262695 | 0.424275313696333 | |
83 | 1 | 0 | m | 23.000 | 0 | 0 | 12749 | 93.5000 | B24 | S | [null] | [null] | Montreal, PQ | 0.089022418949753 | 0.735622598294104 | |
84 | 1 | 0 | m | 29.000 | 1 | 0 | 113776 | 66.6000 | C2 | S | [null] | [null] | Isleworth, England | 0.545445928815752 | 0.627415628143111 | |
85 | 1 | 0 | m | 18.000 | 1 | 0 | PC 17758 | 108.9000 | C65 | C | [null] | [null] | Madrid, Spain | 0.513165891636163 | 0.79139493017806 | |
86 | 1 | 0 | m | 47.000 | 0 | 0 | 110465 | 52.0000 | C110 | S | [null] | 207 | Worcester, MA | 0.164120414061472 | 0.509122481965186 | |
87 | 1 | 0 | m | 38.000 | 0 | 0 | 19972 | 0.0000 | [null] | S | [null] | [null] | Rotterdam, Netherlands | 0.431144091999158 | 0.3457033844739 | |
88 | 1 | 0 | m | 22.000 | 0 | 0 | PC 17760 | 135.6333 | [null] | C | [null] | 232 | [null] | 0.174215304432437 | 0.844108486630076 | |
89 | 1 | 0 | m | [null] | 0 | 0 | PC 17757 | 227.5250 | [null] | C | [null] | [null] | [null] | 0.641582700423896 | [null] | |
90 | 1 | 0 | m | 31.000 | 0 | 0 | PC 17590 | 50.4958 | A24 | S | [null] | [null] | Trenton, NJ | 0.814205173403025 | 0.560551078274049 | |
91 | 1 | 0 | m | [null] | 0 | 0 | 113767 | 50.0000 | A32 | S | [null] | [null] | Seattle, WA | 0.195884848246351 | [null] | |
92 | 1 | 0 | m | 36.000 | 0 | 0 | 13049 | 40.1250 | A10 | C | [null] | [null] | Winnipeg, MB | 0.653516355436295 | 0.50278432961466 | |
93 | 1 | 0 | m | 55.000 | 1 | 0 | PC 17603 | 59.4000 | [null] | C | [null] | [null] | New York, NY | 0.10073209204711 | 0.508954160263652 | |
94 | 1 | 0 | m | 33.000 | 0 | 0 | 113790 | 26.5500 | [null] | S | [null] | 109 | London | 0.278607521904632 | 0.461182789710717 | |
95 | 1 | 0 | m | 61.000 | 1 | 3 | PC 17608 | 262.3750 | B57 B59 B6 | C | [null] | [null] | Haverford, PA / Cooperstown, NY | 0.0629091840237379 | 0.956377405589915 | |
96 | 1 | 0 | m | 50.000 | 1 | 0 | 13507 | 55.9000 | E44 | S | [null] | [null] | Duluth, MN | 0.963238372234628 | 0.513405366648753 | |
97 | 1 | 0 | m | 56.000 | 0 | 0 | 113792 | 26.5500 | [null] | S | [null] | [null] | New York, NY | 0.462777572218329 | 0.38073317046246 | |
98 | 1 | 0 | m | 56.000 | 0 | 0 | 17764 | 30.6958 | A7 | C | [null] | [null] | St James, Long Island, NY | 0.0639691490214318 | 0.395956493572703 | |
99 | 1 | 0 | m | 24.000 | 1 | 0 | 13695 | 60.0000 | C31 | S | [null] | [null] | Huntington, WV | 0.0569538441486657 | 0.620349613280365 | |
100 | 1 | 0 | m | [null] | 0 | 0 | 113056 | 26.0000 | A19 | S | [null] | [null] | Streatham, Surrey | 0.725290278671309 | [null] |
Rows: 1-100 of 1234 | Columns: 16
The vDataFrame has its own 'score' method to evaluate your models.
titanic.score("survived", "pred_survived", method = "auc")
0.6974762740166146
titanic["pred_survived"].boxplot(by = "survived")
Some binary classifiers let you check the significance of its predictors.
model.features_importance()
importance | |
fare | 87.36 |
age | 12.64 |
You can plot these with the 'plot' method.
model.plot()