NightOwl API

Last updated: April 9th, 2020

Introduction

The following is a brief layout of the nightowl API and future plan.

  1. URI changed: nightowl_ver2
  2. Response JSON changed

Deploy

The easiest way to deploy would be:

  1. Generate an os image of the training server,
  2. Instantiate that image at the API server, so that all the model, data, source, config files are intact and in place.

Future plan

The whole API will ultimately move to accept integer fields only instead of current string fields, including

  1. Use wider spanned data that can reflect the desired performance seasonality
  2. Look back the history of the whole database to derive fields
  3. Post the number of available post list, which is desirable from the perspective of prediction
  4. Share interger encoding between the backend and the API for maximal computational efficiency

Using the API

Post Request URL to API server (eventually):

      ## API server
      http://3.133.193.34/api/nightowl_ver2

      ## Training server
      http://3.137.34.107/api/nightowl_ver2
										  
Request Example:
{
        "lead": {
            "id": 10190375237756,
            "date_weekday": "2",
            "date_h": "16",
            "dups_short": 0,
            "dups_long": 130,
            "dups_long_90": 130,
            "body_loanAmount_min": 100,
            "body_dob_year": 1986,
            "body_monthsAtBank": 12,
            "body_monthsAtAddress": 42,
            "body_monthsEmployed": 42,
            "body_monthlyIncome": 3300,
            "body_employmentType": "employed",
            "useragent_ismobile": "0",
            "type": 2,
            "body_domain": "yahoo.com",
            "body_bankRoutingNumber": 73972181,
            "body_state": "TX",
            "campaign": 321098,
            "body_homeOwnership": "rent",
            "useragent_parent": "DefaultProperties",
            "webmaster": 65230,
            "subid1": 0,
            "body_payType": "direct_deposit",
            "subaccount": 1022941746942,
            "body_payFrequency": "biweekly",
            "useragent_platform": "unknown",
            "body_military": 0,
            "body_zip": 77418,
            "useragent_browser": "Default Browser",
            "body_creditScore": "poor",
            "body_loanPurpose": "major"
        }
}
									  
Response Example:

      Server: nginx/1.12.2
      Date: Tue, 09 Apr 2020 23:13:05 GMT
      Content-Type: application/json
      Content-Length: 134
      Connection: keep-alive
      {
       'clf_model': 'tenth_goodleads.cbm',
       'idno': 77683028,
       'lead_value': -1.5060571453728926,
       'prob': 0.07385023755112542,
       'regr_MAE': 10.35,
       'regr_model': 'regr_40_wo_lender_depth6_rmse.cbm',
       'response_time': 0.017893166999860114
      }
									  

Response Fields

Request Details
Field Name Fied Type Description
clf_model String Name of the classifier: data size, depth, fields, ...
idno Integer the lead ID as posted for cross check
lead_value Float The predicted value from historical regression
prob Float The predicted probability of lead value larger than USD 6
regr_MAE Float The Mean Absolute Error of the regressor
regr_model String The name of regression model: data size, attributes, ...
response_time Float The time cost of the predition