h2oai/app-consumer-loan

Name: app-consumer-loan

Owner: H2O.ai

Description: null

Created: 2015-09-28 18:01:40.0

Updated: 2017-11-03 09:31:46.0

Pushed: 2016-11-22 19:49:46.0

Homepage: null

Size: 20672

Language: HTML

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

H2O generated POJO model WebApp Example

This example shows a generated Java POJO being called using a REST API from a JavaScript Web application.

The application simulates the experience of a consumer applying for a loan. The consumer provides some information about themselves and is either offered a loan or denied.

H2O World 2015 Presentation

The “Building a Smarter Application” presentation given at H2O World 2015 references this repo.

Pieces at work
Processes

(Front-end)

  1. Web browser

(Back-end)

  1. Jetty servlet container

Note: Not to be confused with the H2O embedded web port (default 54321) which is also powered by Jetty.

Files

(Offline)

(Front-end)

(Back-end)

Steps to run
Step 1: Create the gradle wrapper to get a stable version of gradle.
adle wrapper
Step 2: Install H2O's R package if you don't have it yet.

http://h2o-release.s3.amazonaws.com/h2o/rel-tibshirani/2/index.html#R

Step 3: Build the project.
gradlew build
Step 4: Deploy the .war file in a Jetty servlet container.
gradlew jettyRunWar -x generateModels

(If you don't include the -x generateModels above, you will build the models again, which is time consuming.)

Step 5: Visit the webapp in a browser.

http://localhost:8080/

Underneath the hood

Make a prediction with curl and get a JSON response.

rl "localhost:8080/predict?loan_amnt=10000&term=36+months&emp_length=5&home_ownership=RENT&annual_inc=60000&verification_status=verified&purpose=debt_consolidation&addr_state=FL&dti=3&delinq_2yrs=0&revol_util=35&total_acc=4&longest_credit_length=10"

abelIndex" : 0,
abel" : "0",
lassProbabilities" : [
0.8581645524025798,
0.14183544759742012


nterestRate" : 12.079950220424134

Notes:

rl "localhost:8080/predict?loan_amnt=10000&term=36+months&emp_length=5&home_ownership=RENT&annual_inc=60000&verification_status=blahblah&purpose=debt_consolidation&addr_state=FL&dti=3&delinq_2yrs=0&revol_util=35&total_acc=4&longest_credit_length=10"
 HTTP error response simplified below ...]
own categorical level (verification_status,blahblah)
Performance
  1. Set VERBOSE to false in src/main/java/org/gradle/PredictServlet.java

  2. ./gradlew jettyRunWar -x war

  3. Run apachebench as shown here:

 -k -c 8 -n 10000 "localhost:8080/predict?loan_amnt=10000&term=36+months&emp_length=5&home_ownership=RENT&annual_inc=60000&verification_status=VERIFIED+-+income&purpose=debt_consolidation&addr_state=FL&dti=3&delinq_2yrs=0&revol_util=35&total_acc=4&longest_credit_length=10"
 is ApacheBench, Version 2.3 <$Revision: 655654 $>
right 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
nsed to The Apache Software Foundation, http://www.apache.org/

hmarking localhost (be patient)
leted 1000 requests
leted 2000 requests
leted 3000 requests
leted 4000 requests
leted 5000 requests
leted 6000 requests
leted 7000 requests
leted 8000 requests
leted 9000 requests
leted 10000 requests
shed 10000 requests


er Software:        Jetty(6.1.25)
er Hostname:        localhost
er Port:            8080

ment Path:          /predict?loan_amnt=10000&term=36+months&emp_length=5&home_ownership=RENT&annual_inc=60000&verification_status=VERIFIED+-+income&purpose=debt_consolidation&addr_state=FL&dti=3&delinq_2yrs=0&revol_util=35&total_acc=4&longest_credit_length=10
ment Length:        160 bytes

urrency Level:      8
 taken for tests:   3.151 seconds
lete requests:      10000
ed requests:        0
e errors:           0
-Alive requests:    10000
l transferred:      2470247 bytes
 transferred:       1600160 bytes
ests per second:    3173.23 [#/sec] (mean)
 per request:       2.521 [ms] (mean)
 per request:       0.315 [ms] (mean, across all concurrent requests)
sfer rate:          765.49 [Kbytes/sec] received

ection Times (ms)
          min  mean[+/-sd] median   max
ect:        0    0   0.0      0       0
essing:     0    3  10.5      0      52
ing:        0    3  10.5      0      52
l:          0    3  10.5      0      52

entage of the requests served within a certain time (ms)
%      0
%      0
%      0
%      0
%      0
%      1
%     51
%     51
%     52 (longest request)

On a Macbook Pro with a 2.7 GHz Intel Core i7 this run gives:

Data

The original data can be downloaded at https://www.lendingclub.com/info/download-data.action and it is all the data from 2007 to June 30, 2015. This does not incorporate the declined loan data set which does not have the same feature set. Note that some munging was done to distill the data to what is in this git repository.

References

The starting point for this example was taken from the gradle distribution. It shows how to do basic war and jetty plugin operations.

  1. https://services.gradle.org/distributions/gradle-2.7-all.zip
  2. unzip gradle-2.7-all
  3. cd gradle-2.7/samples/webApplication/customized

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.