Machine Learning API

Last updated: July 20th, 2020

Introduction

The following is a brief layout of the Machine Learning API to reflect our coordinated efforts on data refresh and future plan.

  1. URI changed: mlrefresh_ver1 for general scoring, and mlrefresh_ver1_awl for AWL specific prediction
  2. The API accept post call in a batched format
  3. Response JSON changed accordingly

Deploy

The easiest/smooth 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.
  3. Migrate all previous backend settings (routing to 3.133.193.34) to the new endpoint

Future plan

The whole API will ultimately move to more scalable Google's TensorFlow framework, including

  1. Post the number of available post list, which is desirable from the perspective of prediction
  2. Share interger encoding between the backend and the API for maximal computational efficiency

Using the API

Post Request URL to API server, maybe a fresh new server (eventually):

      ## API server
      http://3.133.193.34/api/mlrefresh_ver1
      http://3.133.193.34/api/mlrefresh_ver1_awl

      ## Training server
      https://708510.fi3tux40.asia/api/mlrefresh_ver1
      https://708510.fi3tux40.asia/api/mlrefresh_ver1_awl
										  
Request Example:
{
"16271226":
    {
    "local_date_ymd":"2019-02-15",
    "local_date_weekday":5,
    "local_date_h":11,
    "useragent_parent":"Mobile Safari 12.0",
    "useragent_platform":"iOS",
    "useragent_platform.1":"iOS",
    "useragent_browser":"Safari",
    "useragent_ismobile":1,
    "type":1,
    "dups_short":1,
    "dups_long":4,
    "dups_long_90":null,
    "webmaster":1060,
    "campaign":6519,
    "subaccount":510583.0,
    "subid1":23584,
    "body_domain":"yahoo.com",
    "body_loanAmount_min":1000,
    "body_loanAmount_max":1000,
    "body_dob_year":1976,
    "body_zip":84081,
    "body_state":"UT",
    "body_monthsAtAddress":24,
    "body_homeOwnership":"own",
    "body_driversLicenseState":"UT",
    "body_employmentType":"employed",
    "body_military":0,
    "body_monthlyIncome":3000,
    "body_payFrequency":"biweekly",
    "body_payType":"direct_deposit",
    "body_bankRoutingNumber":324079500,
    "body_monthsAtBank":48,
    "body_creditScore":"good",
    "body_loanPurpose":"debt_consolidation",
    "hash_ssn":7940819,
    "hash_email":8744716,
    "hash_phone":9103142,
    "post_list":"10220,10222,10223,10224,10029,10225,10098,10226,10227,10067,10228,10229,10080,10230",
    "accept_list":10230.0,
    "accept":1,
    "amount":100.0,
    "last_mp":100.0,
    "prev_lead_days":0.0,
    "prev_accept_days":1.0,
    "prev_last_mp":230.0,
    "prev_amount":null,
    "prev_max_amount":0.0,
    "prev_max_amount_days":0.0,
    "prev_sales_count":0,
    "prev_sales_count_90days":0,
    "prev_sales_count_30days":0,
    "dups_hard_5min":1,
    "dups_hard_30days":4,
    "dups_hard_90days":4},
    "17728782":{"local_date_ymd":"2019-02-20",
    "local_date_weekday":3,
    "local_date_h":12,
    "useragent_parent":"Samsung Browser 8.2",
    "useragent_platform":"Android",
    "useragent_platform.1":"Android",
    "useragent_browser":"Samsung Browser",
    "useragent_ismobile":1,
    "type":1,
    "dups_short":0,
    "dups_long":0,
    "dups_long_90":null,
    "webmaster":4221,
    "campaign":5134,
    "subaccount":840008.0,
    "subid1":6,
    "body_domain":"yahoo.com",
    "body_loanAmount_min":1000,
    "body_loanAmount_max":1000,
    "body_dob_year":1978,
    "body_zip":65802,
    "body_state":"MO",
    "body_monthsAtAddress":24,
    "body_homeOwnership":"rent",
    "body_driversLicenseState":"MO",
    "body_employmentType":"benefits",
    "body_military":0,
    "body_monthlyIncome":3000,
    "body_payFrequency":"monthly",
    "body_payType":"direct_deposit",
    "body_bankRoutingNumber":81000210,
    "body_monthsAtBank":30,
    "body_creditScore":null,
    "body_loanPurpose":null,
    "hash_ssn":2573300,
    "hash_email":8714992,
    "hash_phone":2814868,
    "post_list":"10220,10222,10223,10224,10225,10226,10227,10228,10229,10230",
    "accept_list":10230.0,
    "accept":1,
    "amount":100.0,
    "last_mp":100.0,
    "prev_lead_days":null,
    "prev_accept_days":null,
    "prev_last_mp":null,
    "prev_amount":null,
    "prev_max_amount":null,
    "prev_max_amount_days":null,
    "prev_sales_count":0,
    "prev_sales_count_90days":0,
    "prev_sales_count_30days":0,
    "dups_hard_5min":0,
    "dups_hard_30days":0,
    "dups_hard_90days":0
    }
}
									  
Response Example:
{
    "clf_model":"awl_goodleads_500.cbm",
    "idno":["16271226","17728782"],
    "lead_value":[43.46786817004011,34.56923438321187],
    "prob":[0.704313187654389,0.7706395606898652],
    "regr_MAE":13.0,
    "regr_model":"regr_awl_500.cbm",
    "reponse_time":0.02844645400000445
}
									  

Response Fields

Request Details
Field Name Fied Type Description
clf_model String Name of the classifier: data size, depth, fields, ...
idno String Array the lead ID as posted for cross check
lead_value Float Array The predicted value from historical regression
prob Float Array 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