cancel
Showing results for 
Search instead for 
Did you mean: 
Machine Learning
Dive into the world of machine learning on the Databricks platform. Explore discussions on algorithms, model training, deployment, and more. Connect with ML enthusiasts and experts.
cancel
Showing results for 
Search instead for 
Did you mean: 

Create Serving Endpoint with JAVA Runtime

prafull
New Contributor

Hello,

Trying to create a custom serving endpoint, using artifacts argument while logging the run/model to save .jar files. These files are called during when calling .predict. 

JAVA runtime 8 or higher is required to run the jar file, not sure how to create a serving endpoint that will have JAVA runtime.

# Model wrapper class
#this model will give prob of all classes, prediction, predictio prob
class ModelWrapper_custom_DataRobot_To_Linesense(mlflow.pyfunc.PythonModel😞
    # Initialize model in the constructor
    def __init__(self, model😞
        self.model = model

    # Prediction function
    def predict(self, context, model_input😞

        model = ScoringCodeModel(context.artifacts['model_jar'])

        model_output = model.predict(model_input)
   
        df_temp = pd.DataFrame()

        #Extract Probability values for selected prediction
        df_temp['prediction_probability'] = model_output.max(axis=1)

        # Find the column with maximum probability for each row
        df_temp['prediction'] = model_output.idxmax(axis=1)

        #remove NAN, this is required to avoid error in max find
        df_temp = df_temp.dropna()

        # Extract the middle value from the 'prediction' column
        df_temp['prediction'] = df_temp['prediction'].apply(lambda x: x.split('_')[1])

        #return
        return df_temp.to_json(orient='records')

This is a simplified version of model wrapper, when serving endpoint is deployed it cannot infer due to java runtime missing.

 

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group