Mlflow with Helm and serve Train Model on kubernetes

Dounpct
3 min readApr 15, 2023

--

Part 3: Expose example api on Local Machine

Expose API

  • From mlflow tracking server
  • Copy full path of model
  • Run serve model
mlflow models serve -m mlflow-artifacts:/905199336240427925/4e9807502bad4255a1d2dcdb6272cd75/artifacts/model -p 1234
  • Let test api with PostMan
    
http://127.0.0.1:1234/invocations

{"dataframe_split": {"data":[[

0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0

]]}}
### RESULT ###
{
"predictions": [
"yes"
]
}
  • Let change data
http://127.0.0.1:1234/invocations

{"dataframe_split": {"data":[[

0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0

]]}}
{
"predictions": [
"no"
]
}
  • Let test API with curl
curl -X POST -H "Content-Type:application/json"                     \
--data "{\"dataframe_split\": {\"data\":[[ \
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0]]}}" \
http://127.0.0.1:1234/invocations | jq
{
"predictions": [
"yes"
]
}
  • Have fun !!!

Note data

        0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0

Come from Transform and OneHotEncoder

First “0.0” 42 item from 42 mt.ads_country_dst

And

Last “0.0” 2 item from is_OfficeHour(yes/no)

— — — — — — — — — — — — — — — — — — — — — — — — — — — — —

Credit : TrueDigitalGroup

— — — — — — — — — — — — — — — — — — — — — — — — — — — — —

--

--

Dounpct
Dounpct

Written by Dounpct

I work for TrueDigitalGroup in DevOps x Automation Team

No responses yet