API Serving
Use MMLSpark
Load in required libraries
from pyspark.ml.tuning import CrossValidatorModel
from pyspark.ml import PipelineModel
from pyspark.sql.types import IntegerType
from pyspark.sql.functions import col, round
import sys
import numpy as np
import pandas as pd
import mmlspark
from pyspark.sql.functions import col, from_json
from pyspark.sql.types import *
import uuid
from mmlspark import request_to_string, string_to_responseLoad in transformation pipeline and trained model
## Load in the transformation pipeline
mypipeline = PipelineModel.load("/mnt/trainedmodels/pipeline/")
## Load in trained model
mymodel = CrossValidatorModel.load("/mnt/trainedmodels/lr")Define username, key, and IP address
Define input schema
Set up streaming DataFrame
Set up server
Test the webservice
You may need to run sudo netstat -tulpn to see what port is open if you're running inside Databricks.
Use this command to look for the port that was opened by the server.
Resources:
Microsoft MMLSpark on GitHub: https://github.com/Azure/mmlspark
Last updated
Was this helpful?