{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import h2o\n",
"from h2o.estimators.gbm import H2OGradientBoostingEstimator"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"
H2O cluster uptime: | \n",
"5 seconds 730 milliseconds |
\n",
"H2O cluster version: | \n",
"3.7.0.99999 |
\n",
"H2O cluster name: | \n",
"spIdea |
\n",
"H2O cluster total nodes: | \n",
"1 |
\n",
"H2O cluster total free memory: | \n",
"12.44 GB |
\n",
"H2O cluster total cores: | \n",
"8 |
\n",
"H2O cluster allowed cores: | \n",
"8 |
\n",
"H2O cluster healthy: | \n",
"True |
\n",
"H2O Connection ip: | \n",
"127.0.0.1 |
\n",
"H2O Connection port: | \n",
"54321 |
\n",
"H2O Connection proxy: | \n",
"None |
\n",
"Python Version: | \n",
"3.5.0 |
"
],
"text/plain": [
"------------------------------ --------------------------\n",
"H2O cluster uptime: 5 seconds 730 milliseconds\n",
"H2O cluster version: 3.7.0.99999\n",
"H2O cluster name: spIdea\n",
"H2O cluster total nodes: 1\n",
"H2O cluster total free memory: 12.44 GB\n",
"H2O cluster total cores: 8\n",
"H2O cluster allowed cores: 8\n",
"H2O cluster healthy: True\n",
"H2O Connection ip: 127.0.0.1\n",
"H2O Connection port: 54321\n",
"H2O Connection proxy:\n",
"Python Version: 3.5.0\n",
"------------------------------ --------------------------"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Connect to a pre-existing cluster\n",
"h2o.init()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Parse Progress: [##################################################] 100%\n"
]
}
],
"source": [
"from h2o.utils.shared_utils import _locate # private function. used to find files within h2o git project directory.\n",
"\n",
"df = h2o.import_file(path=_locate(\"smalldata/logreg/prostate.csv\"))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Rows:380 Cols:9\n",
"\n",
"Chunk compression summary: \n"
]
},
{
"data": {
"text/html": [
"chunk_type | \n",
"chunk_name | \n",
"count | \n",
"count_percentage | \n",
"size | \n",
"size_percentage |
\n",
"CBS | \n",
"Bits | \n",
"1 | \n",
"11.111112 | \n",
" 118 B | \n",
"2.4210093 |
\n",
"C1N | \n",
"1-Byte Integers (w/o NAs) | \n",
"5 | \n",
"55.555557 | \n",
" 2.2 KB | \n",
"45.958145 |
\n",
"C2 | \n",
"2-Byte Integers | \n",
"1 | \n",
"11.111112 | \n",
" 828 B | \n",
"16.9881 |
\n",
"C2S | \n",
"2-Byte Fractions | \n",
"2 | \n",
"22.222223 | \n",
" 1.6 KB | \n",
"34.632744 |
"
],
"text/plain": [
"chunk_type chunk_name count count_percentage size size_percentage\n",
"------------ ------------------------- ------- ------------------ ------ -----------------\n",
"CBS Bits 1 11.1111 118 B 2.42101\n",
"C1N 1-Byte Integers (w/o NAs) 5 55.5556 2.2 KB 45.9581\n",
"C2 2-Byte Integers 1 11.1111 828 B 16.9881\n",
"C2S 2-Byte Fractions 2 22.2222 1.6 KB 34.6327"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Frame distribution summary: \n"
]
},
{
"data": {
"text/html": [
" | \n",
"size | \n",
"number_of_rows | \n",
"number_of_chunks_per_column | \n",
"number_of_chunks |
\n",
"172.16.2.84:54321 | \n",
" 4.8 KB | \n",
"380.0 | \n",
"1.0 | \n",
"9.0 |
\n",
"mean | \n",
" 4.8 KB | \n",
"380.0 | \n",
"1.0 | \n",
"9.0 |
\n",
"min | \n",
" 4.8 KB | \n",
"380.0 | \n",
"1.0 | \n",
"9.0 |
\n",
"max | \n",
" 4.8 KB | \n",
"380.0 | \n",
"1.0 | \n",
"9.0 |
\n",
"stddev | \n",
" 0 B | \n",
"0.0 | \n",
"0.0 | \n",
"0.0 |
\n",
"total | \n",
" 4.8 KB | \n",
"380.0 | \n",
"1.0 | \n",
"9.0 |
"
],
"text/plain": [
" size number_of_rows number_of_chunks_per_column number_of_chunks\n",
"----------------- ------ ---------------- ----------------------------- ------------------\n",
"172.16.2.84:54321 4.8 KB 380 1 9\n",
"mean 4.8 KB 380 1 9\n",
"min 4.8 KB 380 1 9\n",
"max 4.8 KB 380 1 9\n",
"stddev 0 B 0 0 0\n",
"total 4.8 KB 380 1 9"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n"
]
},
{
"data": {
"text/html": [
"\n",
" | ID | CAPSULE | AGE | RACE | DPROS | DCAPS | PSA | VOL | GLEASON |
\n",
"type | int | int | int | int | int | int | real | real | int |
\n",
"mins | 1.0 | 0.0 | 43.0 | 0.0 | 1.0 | 1.0 | 0.3 | 0.0 | 0.0 |
\n",
"mean | 190.5 | 0.4026315789473684 | 66.03947368421049 | 1.0868421052631572 | 2.2710526315789488 | 1.1078947368421048 | 15.408631578947375 | 15.812921052631573 | 6.3842105263157904 |
\n",
"maxs | 380.0 | 1.0 | 79.0 | 2.0 | 4.0 | 2.0 | 139.70000000000002 | 97.60000000000001 | 9.0 |
\n",
"sigma | 109.84079387914127 | 0.4910743389630552 | 6.527071269173311 | 0.3087732580252793 | 1.0001076181502861 | 0.3106564493514939 | 19.99757266856046 | 18.347619967271175 | 1.0919533744261092 |
\n",
"zeros | 0 | 227 | 0 | 3 | 0 | 0 | 0 | 167 | 2 |
\n",
"missing | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
\n",
"0 | 1.0 | 0.0 | 65.0 | 1.0 | 2.0 | 1.0 | 1.4000000000000001 | 0.0 | 6.0 |
\n",
"1 | 2.0 | 0.0 | 72.0 | 1.0 | 3.0 | 2.0 | 6.7 | 0.0 | 7.0 |
\n",
"2 | 3.0 | 0.0 | 70.0 | 1.0 | 1.0 | 2.0 | 4.9 | 0.0 | 6.0 |
\n",
"3 | 4.0 | 0.0 | 76.0 | 2.0 | 2.0 | 1.0 | 51.2 | 20.0 | 7.0 |
\n",
"4 | 5.0 | 0.0 | 69.0 | 1.0 | 1.0 | 1.0 | 12.3 | 55.9 | 6.0 |
\n",
"5 | 6.0 | 1.0 | 71.0 | 1.0 | 3.0 | 2.0 | 3.3000000000000003 | 0.0 | 8.0 |
\n",
"6 | 7.0 | 0.0 | 68.0 | 2.0 | 4.0 | 2.0 | 31.900000000000002 | 0.0 | 7.0 |
\n",
"7 | 8.0 | 0.0 | 61.0 | 2.0 | 4.0 | 2.0 | 66.7 | 27.2 | 7.0 |
\n",
"8 | 9.0 | 0.0 | 69.0 | 1.0 | 1.0 | 1.0 | 3.9 | 24.0 | 7.0 |
\n",
"9 | 10.0 | 0.0 | 68.0 | 2.0 | 1.0 | 2.0 | 13.0 | 0.0 | 6.0 |
\n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df.describe()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Remove ID from training frame\n",
"train = df.drop(\"ID\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# For VOL & GLEASON, a zero really means \"missing\"\n",
"vol = train['VOL']\n",
"vol[vol == 0] = None\n",
"gle = train['GLEASON']\n",
"gle[gle == 0] = None"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Convert CAPSULE to a logical factor\n",
"train['CAPSULE'] = train['CAPSULE'].asfactor()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Rows:380 Cols:8\n",
"\n",
"Chunk compression summary: \n"
]
},
{
"data": {
"text/html": [
"chunk_type | \n",
"chunk_name | \n",
"count | \n",
"count_percentage | \n",
"size | \n",
"size_percentage |
\n",
"CBS | \n",
"Bits | \n",
"1 | \n",
"12.5 | \n",
" 118 B | \n",
"2.9164608 |
\n",
"C1N | \n",
"1-Byte Integers (w/o NAs) | \n",
"5 | \n",
"62.5 | \n",
" 2.2 KB | \n",
"55.363323 |
\n",
"C2S | \n",
"2-Byte Fractions | \n",
"2 | \n",
"25.0 | \n",
" 1.6 KB | \n",
"41.72022 |
"
],
"text/plain": [
"chunk_type chunk_name count count_percentage size size_percentage\n",
"------------ ------------------------- ------- ------------------ ------ -----------------\n",
"CBS Bits 1 12.5 118 B 2.91646\n",
"C1N 1-Byte Integers (w/o NAs) 5 62.5 2.2 KB 55.3633\n",
"C2S 2-Byte Fractions 2 25 1.6 KB 41.7202"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Frame distribution summary: \n"
]
},
{
"data": {
"text/html": [
" | \n",
"size | \n",
"number_of_rows | \n",
"number_of_chunks_per_column | \n",
"number_of_chunks |
\n",
"172.16.2.84:54321 | \n",
" 4.0 KB | \n",
"380.0 | \n",
"1.0 | \n",
"8.0 |
\n",
"mean | \n",
" 4.0 KB | \n",
"380.0 | \n",
"1.0 | \n",
"8.0 |
\n",
"min | \n",
" 4.0 KB | \n",
"380.0 | \n",
"1.0 | \n",
"8.0 |
\n",
"max | \n",
" 4.0 KB | \n",
"380.0 | \n",
"1.0 | \n",
"8.0 |
\n",
"stddev | \n",
" 0 B | \n",
"0.0 | \n",
"0.0 | \n",
"0.0 |
\n",
"total | \n",
" 4.0 KB | \n",
"380.0 | \n",
"1.0 | \n",
"8.0 |
"
],
"text/plain": [
" size number_of_rows number_of_chunks_per_column number_of_chunks\n",
"----------------- ------ ---------------- ----------------------------- ------------------\n",
"172.16.2.84:54321 4.0 KB 380 1 8\n",
"mean 4.0 KB 380 1 8\n",
"min 4.0 KB 380 1 8\n",
"max 4.0 KB 380 1 8\n",
"stddev 0 B 0 0 0\n",
"total 4.0 KB 380 1 8"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n"
]
},
{
"data": {
"text/html": [
"\n",
" | CAPSULE | AGE | RACE | DPROS | DCAPS | PSA | VOL | GLEASON |
\n",
"type | enum | int | int | int | int | real | real | int |
\n",
"mins | 0.0 | 43.0 | 0.0 | 1.0 | 1.0 | 0.3 | 0.0 | 0.0 |
\n",
"mean | 0.4026315789473684 | 66.03947368421049 | 1.0868421052631572 | 2.2710526315789488 | 1.1078947368421048 | 15.408631578947375 | 15.812921052631573 | 6.3842105263157904 |
\n",
"maxs | 1.0 | 79.0 | 2.0 | 4.0 | 2.0 | 139.70000000000002 | 97.60000000000001 | 9.0 |
\n",
"sigma | 0.4910743389630552 | 6.527071269173311 | 0.3087732580252793 | 1.0001076181502861 | 0.3106564493514939 | 19.99757266856046 | 18.347619967271175 | 1.0919533744261092 |
\n",
"zeros | 227 | 0 | 3 | 0 | 0 | 0 | 167 | 2 |
\n",
"missing | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
\n",
"0 | 0 | 65.0 | 1.0 | 2.0 | 1.0 | 1.4000000000000001 | 0.0 | 6.0 |
\n",
"1 | 0 | 72.0 | 1.0 | 3.0 | 2.0 | 6.7 | 0.0 | 7.0 |
\n",
"2 | 0 | 70.0 | 1.0 | 1.0 | 2.0 | 4.9 | 0.0 | 6.0 |
\n",
"3 | 0 | 76.0 | 2.0 | 2.0 | 1.0 | 51.2 | 20.0 | 7.0 |
\n",
"4 | 0 | 69.0 | 1.0 | 1.0 | 1.0 | 12.3 | 55.9 | 6.0 |
\n",
"5 | 1 | 71.0 | 1.0 | 3.0 | 2.0 | 3.3000000000000003 | 0.0 | 8.0 |
\n",
"6 | 0 | 68.0 | 2.0 | 4.0 | 2.0 | 31.900000000000002 | 0.0 | 7.0 |
\n",
"7 | 0 | 61.0 | 2.0 | 4.0 | 2.0 | 66.7 | 27.2 | 7.0 |
\n",
"8 | 0 | 69.0 | 1.0 | 1.0 | 1.0 | 3.9 | 24.0 | 7.0 |
\n",
"9 | 0 | 68.0 | 2.0 | 1.0 | 2.0 | 13.0 | 0.0 | 6.0 |
\n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# See that the data is ready\n",
"train.describe()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"gbm Model Build Progress: [##################################################] 100%\n"
]
}
],
"source": [
"# Run GBM\n",
"my_gbm = H2OGradientBoostingEstimator(distribution = \"bernoulli\", ntrees=50, learn_rate=0.1)\n",
"\n",
"my_gbm.train(x=list(range(1,train.ncol)), y=\"CAPSULE\", training_frame=train, validation_frame=train)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"ModelMetricsBinomial: gbm\n",
"** Reported on test data. **\n",
"\n",
"MSE: 0.07584147467507414\n",
"R^2: 0.6846762562816877\n",
"LogLoss: 0.2744668128481441\n",
"AUC: 0.9780311537243385\n",
"Gini: 0.9560623074486769\n",
"\n",
"Confusion Matrix (Act/Pred) for max f1 @ threshold = 0.4549496668047897: \n"
]
},
{
"data": {
"text/html": [
" | \n",
"0 | \n",
"1 | \n",
"Error | \n",
"Rate |
\n",
"0 | \n",
"216.0 | \n",
"11.0 | \n",
"0.0485 | \n",
" (11.0/227.0) |
\n",
"1 | \n",
"14.0 | \n",
"139.0 | \n",
"0.0915 | \n",
" (14.0/153.0) |
\n",
"Total | \n",
"230.0 | \n",
"150.0 | \n",
"0.0658 | \n",
" (25.0/380.0) |
"
],
"text/plain": [
" 0 1 Error Rate\n",
"----- --- --- ------- ------------\n",
"0 216 11 0.0485 (11.0/227.0)\n",
"1 14 139 0.0915 (14.0/153.0)\n",
"Total 230 150 0.0658 (25.0/380.0)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Maximum Metrics: Maximum metrics at their respective thresholds\n",
"\n"
]
},
{
"data": {
"text/html": [
"metric | \n",
"threshold | \n",
"value | \n",
"idx |
\n",
"max f1 | \n",
"0.4549497 | \n",
"0.9174917 | \n",
"149.0 |
\n",
"max f2 | \n",
"0.3032010 | \n",
"0.9394314 | \n",
"196.0 |
\n",
"max f0point5 | \n",
"0.4728313 | \n",
"0.9244265 | \n",
"146.0 |
\n",
"max accuracy | \n",
"0.4549497 | \n",
"0.9342105 | \n",
"149.0 |
\n",
"max precision | \n",
"0.9747938 | \n",
"1.0 | \n",
"0.0 |
\n",
"max absolute_MCC | \n",
"0.4549497 | \n",
"0.8629130 | \n",
"149.0 |
\n",
"max min_per_class_accuracy | \n",
"0.4373995 | \n",
"0.9215686 | \n",
"156.0 |
"
],
"text/plain": [
"metric threshold value idx\n",
"-------------------------- ----------- -------- -----\n",
"max f1 0.45495 0.917492 149\n",
"max f2 0.303201 0.939431 196\n",
"max f0point5 0.472831 0.924426 146\n",
"max accuracy 0.45495 0.934211 149\n",
"max precision 0.974794 1 0\n",
"max absolute_MCC 0.45495 0.862913 149\n",
"max min_per_class_accuracy 0.437399 0.921569 156"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Gains/Lift Table: Avg response rate: 40.26 %\n",
"\n"
]
},
{
"data": {
"text/html": [
" | \n",
"group | \n",
"lower_threshold | \n",
"cumulative_data_fraction | \n",
"response_rate | \n",
"cumulative_response_rate | \n",
"capture_rate | \n",
"cumulative_capture_rate | \n",
"lift | \n",
"cumulative_lift | \n",
"gain | \n",
"cumulative_gain |
\n",
" | \n",
"1 | \n",
"0.9405750 | \n",
"0.05 | \n",
"1.0 | \n",
"1.0 | \n",
"0.1241830 | \n",
"0.1241830 | \n",
"2.4836601 | \n",
"2.4836601 | \n",
"148.3660131 | \n",
"148.3660131 |
\n",
" | \n",
"2 | \n",
"0.8921980 | \n",
"0.1 | \n",
"1.0 | \n",
"1.0 | \n",
"0.1241830 | \n",
"0.2483660 | \n",
"2.4836601 | \n",
"2.4836601 | \n",
"148.3660131 | \n",
"148.3660131 |
\n",
" | \n",
"3 | \n",
"0.8263695 | \n",
"0.15 | \n",
"1.0 | \n",
"1.0 | \n",
"0.1241830 | \n",
"0.3725490 | \n",
"2.4836601 | \n",
"2.4836601 | \n",
"148.3660131 | \n",
"148.3660131 |
\n",
" | \n",
"4 | \n",
"0.7595460 | \n",
"0.2 | \n",
"0.9473684 | \n",
"0.9868421 | \n",
"0.1176471 | \n",
"0.4901961 | \n",
"2.3529412 | \n",
"2.4509804 | \n",
"135.2941176 | \n",
"145.0980392 |
\n",
" | \n",
"5 | \n",
"0.7081926 | \n",
"0.25 | \n",
"1.0 | \n",
"0.9894737 | \n",
"0.1241830 | \n",
"0.6143791 | \n",
"2.4836601 | \n",
"2.4575163 | \n",
"148.3660131 | \n",
"145.7516340 |
\n",
" | \n",
"6 | \n",
"0.6364312 | \n",
"0.3 | \n",
"0.8947368 | \n",
"0.9736842 | \n",
"0.1111111 | \n",
"0.7254902 | \n",
"2.2222222 | \n",
"2.4183007 | \n",
"122.2222222 | \n",
"141.8300654 |
\n",
" | \n",
"7 | \n",
"0.5478651 | \n",
"0.35 | \n",
"0.6842105 | \n",
"0.9323308 | \n",
"0.0849673 | \n",
"0.8104575 | \n",
"1.6993464 | \n",
"2.3155929 | \n",
"69.9346405 | \n",
"131.5592904 |
\n",
" | \n",
"8 | \n",
"0.4499827 | \n",
"0.4 | \n",
"0.7894737 | \n",
"0.9144737 | \n",
"0.0980392 | \n",
"0.9084967 | \n",
"1.9607843 | \n",
"2.2712418 | \n",
"96.0784314 | \n",
"127.1241830 |
\n",
" | \n",
"9 | \n",
"0.3927870 | \n",
"0.45 | \n",
"0.2105263 | \n",
"0.8362573 | \n",
"0.0261438 | \n",
"0.9346405 | \n",
"0.5228758 | \n",
"2.0769789 | \n",
"-47.7124183 | \n",
"107.6978940 |
\n",
" | \n",
"10 | \n",
"0.3207657 | \n",
"0.5 | \n",
"0.3157895 | \n",
"0.7842105 | \n",
"0.0392157 | \n",
"0.9738562 | \n",
"0.7843137 | \n",
"1.9477124 | \n",
"-21.5686275 | \n",
"94.7712418 |
\n",
" | \n",
"11 | \n",
"0.2425744 | \n",
"0.55 | \n",
"0.1578947 | \n",
"0.7272727 | \n",
"0.0196078 | \n",
"0.9934641 | \n",
"0.3921569 | \n",
"1.8062983 | \n",
"-60.7843137 | \n",
"80.6298277 |
\n",
" | \n",
"12 | \n",
"0.1977616 | \n",
"0.6 | \n",
"0.0 | \n",
"0.6666667 | \n",
"0.0 | \n",
"0.9934641 | \n",
"0.0 | \n",
"1.6557734 | \n",
"-100.0 | \n",
"65.5773420 |
\n",
" | \n",
"13 | \n",
"0.1586941 | \n",
"0.65 | \n",
"0.0526316 | \n",
"0.6194332 | \n",
"0.0065359 | \n",
"1.0 | \n",
"0.1307190 | \n",
"1.5384615 | \n",
"-86.9281046 | \n",
"53.8461538 |
\n",
" | \n",
"14 | \n",
"0.1353591 | \n",
"0.7 | \n",
"0.0 | \n",
"0.5751880 | \n",
"0.0 | \n",
"1.0 | \n",
"0.0 | \n",
"1.4285714 | \n",
"-100.0 | \n",
"42.8571429 |
\n",
" | \n",
"15 | \n",
"0.1094101 | \n",
"0.75 | \n",
"0.0 | \n",
"0.5368421 | \n",
"0.0 | \n",
"1.0 | \n",
"0.0 | \n",
"1.3333333 | \n",
"-100.0 | \n",
"33.3333333 |
\n",
" | \n",
"16 | \n",
"0.0923828 | \n",
"0.8 | \n",
"0.0 | \n",
"0.5032895 | \n",
"0.0 | \n",
"1.0 | \n",
"0.0 | \n",
"1.25 | \n",
"-100.0 | \n",
"25.0 |
\n",
" | \n",
"17 | \n",
"0.0665933 | \n",
"0.85 | \n",
"0.0 | \n",
"0.4736842 | \n",
"0.0 | \n",
"1.0 | \n",
"0.0 | \n",
"1.1764706 | \n",
"-100.0 | \n",
"17.6470588 |
\n",
" | \n",
"18 | \n",
"0.0477968 | \n",
"0.9 | \n",
"0.0 | \n",
"0.4473684 | \n",
"0.0 | \n",
"1.0 | \n",
"0.0 | \n",
"1.1111111 | \n",
"-100.0 | \n",
"11.1111111 |
\n",
" | \n",
"19 | \n",
"0.0276973 | \n",
"0.95 | \n",
"0.0 | \n",
"0.4238227 | \n",
"0.0 | \n",
"1.0 | \n",
"0.0 | \n",
"1.0526316 | \n",
"-100.0 | \n",
"5.2631579 |
\n",
" | \n",
"20 | \n",
"0.0125566 | \n",
"1.0 | \n",
"0.0 | \n",
"0.4026316 | \n",
"0.0 | \n",
"1.0 | \n",
"0.0 | \n",
"1.0 | \n",
"-100.0 | \n",
"0.0 |
"
],
"text/plain": [
" group lower_threshold cumulative_data_fraction response_rate cumulative_response_rate capture_rate cumulative_capture_rate lift cumulative_lift gain cumulative_gain\n",
"-- ------- ----------------- -------------------------- --------------- -------------------------- -------------- ------------------------- -------- ----------------- -------- -----------------\n",
" 1 0.940575 0.05 1 1 0.124183 0.124183 2.48366 2.48366 148.366 148.366\n",
" 2 0.892198 0.1 1 1 0.124183 0.248366 2.48366 2.48366 148.366 148.366\n",
" 3 0.82637 0.15 1 1 0.124183 0.372549 2.48366 2.48366 148.366 148.366\n",
" 4 0.759546 0.2 0.947368 0.986842 0.117647 0.490196 2.35294 2.45098 135.294 145.098\n",
" 5 0.708193 0.25 1 0.989474 0.124183 0.614379 2.48366 2.45752 148.366 145.752\n",
" 6 0.636431 0.3 0.894737 0.973684 0.111111 0.72549 2.22222 2.4183 122.222 141.83\n",
" 7 0.547865 0.35 0.684211 0.932331 0.0849673 0.810458 1.69935 2.31559 69.9346 131.559\n",
" 8 0.449983 0.4 0.789474 0.914474 0.0980392 0.908497 1.96078 2.27124 96.0784 127.124\n",
" 9 0.392787 0.45 0.210526 0.836257 0.0261438 0.934641 0.522876 2.07698 -47.7124 107.698\n",
" 10 0.320766 0.5 0.315789 0.784211 0.0392157 0.973856 0.784314 1.94771 -21.5686 94.7712\n",
" 11 0.242574 0.55 0.157895 0.727273 0.0196078 0.993464 0.392157 1.8063 -60.7843 80.6298\n",
" 12 0.197762 0.6 0 0.666667 0 0.993464 0 1.65577 -100 65.5773\n",
" 13 0.158694 0.65 0.0526316 0.619433 0.00653595 1 0.130719 1.53846 -86.9281 53.8462\n",
" 14 0.135359 0.7 0 0.575188 0 1 0 1.42857 -100 42.8571\n",
" 15 0.10941 0.75 0 0.536842 0 1 0 1.33333 -100 33.3333\n",
" 16 0.0923828 0.8 0 0.503289 0 1 0 1.25 -100 25\n",
" 17 0.0665933 0.85 0 0.473684 0 1 0 1.17647 -100 17.6471\n",
" 18 0.0477968 0.9 0 0.447368 0 1 0 1.11111 -100 11.1111\n",
" 19 0.0276973 0.95 0 0.423823 0 1 0 1.05263 -100 5.26316\n",
" 20 0.0125566 1 0 0.402632 0 1 0 1 -100 0"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"my_gbm_metrics = my_gbm.model_performance(train)\n",
"my_gbm_metrics.show()"
]
}
],
"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.0"
}
},
"nbformat": 4,
"nbformat_minor": 0
}